[Chromium学习笔记]了解Chromium的基础知识

背景:

    Chrome浏览器,不用多说,家喻户晓。其背后就是开源项目The Chromium Project,包括了Chromium以及ChromiumOS。Chromium的目的是给用户打造一个安全、快速以及稳定的Web体验。Chromium官网地址如下:

http://www.chromium.org/Home

这里面有大量的Chromium资料,包括如何下载源代码、如何在不同的平台上build,如何提交代码以及报告BUG,还提供了部分Chromium的设计文档,当然有些设计文档是针对早期的Chromium,后续的版本可能已经变更了,不过对于了解Chromium的基本架构还是有很大的帮助。


---------------------------------------------------------------------------------------------------------------------------------------------------


本次笔记主题:Chromium进程模型,基本架构,源码结构

    1. 进程模型

    为了提高Chromium的稳定性,减少不同网页之间的影响以及网页对Chromium浏览器本身的影响。Chromium采用了一个多进程的架构模式,这些进程包括:

  • Browser进程:Chromium主进程,Chromium启动时创建的进程。
  • Render进程:网页渲染进程,每个打开的网页都会为器创建一个Render进程
  • GPU进程:顾名思义,是Graphic相关的进程,主要和GPU打交道。Chromium还提供了启动参数,可以设置GPU线程,即将GPU进程的工作放到Browser内部的GPU线程里。

    下面是来自Chromium官网的一张进程模型图:
     [Chromium学习笔记]了解Chromium的基础知识_第1张图片
    
    以上图片很直观地说明了Chromium Browser和Render之间的关系以及沟通方式。详细内容就不多翻译了,官方提供了高质量的设计文档,所以直接参考官方资料:
     http://www.chromium.org/developers/design-documents/multi-process-architecture

    2. Chromium架构示意图
     [Chromium学习笔记]了解Chromium的基础知识_第2张图片
    如上是Chromium的基本架构示意图,包括了浏览器引擎(WebKit,V8)、网络模块等等,值得一提的是,一般移植的时候不会把整理Chromium都移植过来,而是把上图最上层的Chrome去掉,因为这一块涉及到了浏览器周边功能以及本地窗口UI,一般会将其替换成自己系统的NaviteUI或者是干脆用WebUI来代替掉。content已经提供了完整的浏览器功能API,可以加以封装或者是直接使用,所以我们可以将content以及以下的模块移植到自己的系统中作为一个Web引擎。

    3. Chromium源码结构
    Chromium作为一个现代浏览器,其源码庞大而且十分复杂。然而要研究一个开源项目,阅读其内部的代码是不可避免的,在阅读代码之前,需要先了解其源代码的结构,否则可能会无从下手,尤其像Chromium这种庞大的开源项目。以下是代码目录结构和简要介绍(来自官网):

  • android_webview: Provides a facade over src/content suitable for integration into the android platform. NOT intended for usage in individual android applications (APK). More information about the Android WebView source code organization.
  • apps: Chrome packaged apps.
  • base: Common code shared between all sub-projects. This contains things like string manipulation, generic utilities, etc. Add things here only if it must be shared between more than one other top-level project. 
  • breakpad: Google's open source crash reporting project. This is pulled directly from Google Code's Subversion repository.
  • build: Build-related configuration shared by all projects.
  • cc: The Chromium compositor implementation.
  • chrome: The Chromium browser (see below).
  • chrome/test/data: Data files for running certain tests.
  • components:  directory for components that have the Content Module as the uppermost layer they depend on.
  • content: The core code needed for a multi-process sandboxed browser (see below). More information about why we have separated out this code.
  • device: Cross-platform abstractions of common low-level hardware APIs.
  • net: The networking library developed for Chromium. This can be used separately from Chromium when running our simple test_shell in the webkit repository. See also chrome/common/net.
  • sandbox: The sandbox project which tries to prevent a hacked renderer from modifying the system.
  • skia: Google's Skia graphics library developed for Android. This is a copy from Android's tree. Our additional classes in ui/gfx wrap Skia.
  • sql: Our wrap around sqlite.
  • testing: Contains Google's open-sourced GTest code which we use for unit testing.
  • third_party: A bunch of external libraries such as image decoders and compression libraries. There are also some Chrome-specific third-party libraries in chrome/third_party. Adding new packages.
  • tools
  • ui/gfx: Shared graphics classes. These form the base of Chromium's UI graphics.
  • ui/views: A simple framework for doing UI development, providing rendering, layout and event handling. Most of the browser UI is implemented in this system. This directory contains the base objects. Some more browser-specific objects are in chrome/browser/ui/views.
  • url: Google's open source URL parsing and canonicalization library.
  • v8: The V8 Javascript library. This is pulled directly from Google Code's Subversion repository.
  • webkit:
    官网资料链接:
     http://www.chromium.org/developers/how-tos/getting-around-the-chrome-source-code

    OK,本次的Chromium学习笔记就记录到此,下一篇开始学习源码:base。

    

你可能感兴趣的:(C/C++,Chromium,Web)