[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 Browser和Render之間的關係以及溝通方式。詳細內容就不多翻譯了,官方提供了高質量的設計文檔,所以直接參考官方資料:

    2. Chromium架構示意圖
    
    如上是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.
  • appsChrome 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_partyAdding 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:
    官網資料鏈接:

    OK,本次的Chromium學習筆記就記錄到此,下一篇開始學習源碼:base。

    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章