OVERVIEW: Chromium Source Tree

33
Chromium Source Tree Overview

description

Rough study log #1. Overview of Chromium SourceTree.

Transcript of OVERVIEW: Chromium Source Tree

Page 1: OVERVIEW: Chromium Source Tree

ChromiumSource Tree Overview

Page 3: OVERVIEW: Chromium Source Tree

CAUTION!

Many documents being mentioned from this slide are outdated. Don’t believe everything. =)

Page 4: OVERVIEW: Chromium Source Tree

Overall Top-Projects

Page 5: OVERVIEW: Chromium Source Tree

Simplified top-projectsProject Description

android_webview Integration of /content into android.

base Common code shared between all sub-projects.

build Build Configurations shared by all projects

cc chrome Compositor implementations

components components for Content Module layer

content Core code for multi-process sandboxed browser

net Network libraries for Chromium

sandbox Sandbox for preventing hacked renderer from modified system.

skia skia Graphics library, some classes in ui/gfx wrap skia

third_party External libaries such as blink, decoders, compression, ...

ui ● /gfx: Shared graphics lib, base of Chromium UI grp.● /views: frameworks for UI; rendering, layout, event

handling.○ ALSO CHECK! chrome/browser/ui/view

v8 V8 JavaScript Engine

webkit WebKit glues & some web features

Page 6: OVERVIEW: Chromium Source Tree

Historical changes ofChromium Dependency Diagram

Page 7: OVERVIEW: Chromium Source Tree

Dependency diagram: V1/chrome

/net

/base /third_party//webkit

/V8

WebKit API/webkit

Page 8: OVERVIEW: Chromium Source Tree

Dependency diagram: V2/chrome

/content

/webkit/net

/base /third_party//webkit

/V8

Content API

WebKit API

Page 9: OVERVIEW: Chromium Source Tree

Dependency diagram: V3/chrome OR /android_webview OR ...

/components

/content

/webkit/net

/base /third_party//webkit

/V8

Content API

WebKit API

Page 10: OVERVIEW: Chromium Source Tree

Dependency diagram: V3/chrome OR /android_webview OR ...

/components

/content

/webkit/net

/base /third_party//webkit

/V8

Content API

WebKitAPI

Common code to be shared between all

sub-projects

Network libraries for Chromium

WebKit glue.NEED RESEARCH

SOMEMORE

Chromium browser implementation

Shared codes between browser

implemetations

Blink PART

All the web platform features, HW acc. except

Chrome features

Page 11: OVERVIEW: Chromium Source Tree

Overview of Top-level projects

Page 12: OVERVIEW: Chromium Source Tree

/android_webview

● Facades over src/content to integrate into Android○ References

■ Java Resource on Android● http://www.chromium.org/developers/design-documents/java-

resources-on-android■ JNI on Chromium for Android

● http://www.chromium.org/developers/design-documents/android-jni

● WARNING! Use jar_file_jni_generator.gypi for generating

JNI of system classes instead of system_classes_jni_generator.gypi

■ Organization of code for Android WebView● https://docs.google.

com/document/d/1a_cUP1dGIlRQFUSic8bhAOxfclj4Xzw-yRDljVk1wB0/edit

Page 13: OVERVIEW: Chromium Source Tree

/base

● Common code shared betweeen sub-projects○ e.g. String manipulations, file, …

● Guideline○ Adding things under /base, only if that code must be

shared between more than 1 other top-level project.

Page 14: OVERVIEW: Chromium Source Tree

● Build-related configuration shared by all projects○ NOTE:

■ gyp_chromium● Wrapper of gyp for chromium build

■ all.gyp● Everything starts at here!!!

■ android● jni_generator.gypi

○ JNI generator for user-defined class● jar_file_jni_generator.gypi

○ JNI generator for system class

/build

Page 15: OVERVIEW: Chromium Source Tree

● Chrome compositor implementations○ References:

■ GPU Accelerated Compositing in Chrome● http://www.chromium.org/developers/design-documents/gpu-

accelerated-compositing-in-chrome■ Compositing in Blink/Webcore [slide]

● https://docs.google.

com/presentation/d/1dDE5u76ZBIKmsqkWi2apx3BqV8HOcNf4xxBdyNywZR8/edit#slide=id.gccb6cccc_0709

■ Compositor Thread Architecture● http://www.chromium.org/developers/design-

documents/compositor-thread-architecture

NOTE: Implementations in ‘cc’ don’t have whole part in above references.

/cc

Page 16: OVERVIEW: Chromium Source Tree

/chrome

● Chromium browser implementations○ e.g. Extensions, NaCl, ChromeFrame, SpellCheck,

Autofill, Sync, Prerendering, Safe Browsing, Translate, ...

● See also:○ chrome.gyp○ chrome_browser.gypi○ chrome_browser_ui.gypi○ chrome_browser_ui_views.gypi○ chrome_android.gypi

Page 17: OVERVIEW: Chromium Source Tree

/components

● Features for reusing across # of targets○ for browser features, NOT the web!

■ e.g. Bookmarks, autofill, autocomplete, search engine, history, …

● Guidelines○ By default, depend only on the lower layers of the

Chromium codebase( /base, /net, etc)■ Individually, allow additional dependencies on the

content API and IPC

Page 18: OVERVIEW: Chromium Source Tree

/components

● Guidelines○ Directory & Subdirectories

■ Directory could have● DEPS : Dependencies such as rules, include_dir, ...● OWNERS● {DIR}.gypi

■ subdirectories● Components need to live in different processes should

separate the code into different subdirectories.components/foo DEPS, OWNERS, foo.gypi

components/foo/browser Code that needs the browser process

components/foo/renderer IPC constants, ...

components/foo/common Code that needs renderer process

Page 19: OVERVIEW: Chromium Source Tree

/components

● Guidelines○ Directory & Subdirectories (cont’d)

■ Subdirectory should have DEPS file● with the relevant restrictions in place

○ i.e. only components/*/browser should be allowed to #include from content/public/browser.

○ Naming conventions■ namespace = the name of the component.

● e.g. //components/foo○ code should be in the foo:: namespace

Page 20: OVERVIEW: Chromium Source Tree

/components

● Guidelines○ Android

■ 'android' subdirectory with a Java source● SHOULD BE: code structure = package name

● Reference○ http://www.chromium.org/developers/design-

documents/structure-of-layered-components-within-the-chromium-codebase

components/foo/android/OWNERScomponents/foo/android/DEPScomponents/foo/android/java/src/org/chromium/components/foo/browser/components/foo/android/javatests/src/org/chromium/components/foo/browser/

Page 22: OVERVIEW: Chromium Source Tree

● Core code for multi-process sandboxed browser.○ The core code needed to render a page using a

multi-process sandboxed browser.○ Includes all the web platform features and GPU

acceleration except Chrome features.

● The goal○ Being able to build a browser by starting with

content, and then pick and choose Chrome features.

/content

Page 23: OVERVIEW: Chromium Source Tree

/content

● Historical motivation○ Consensus was reached to move the core

Chrome code into src\content.■ Hard to figure out what the "best" way, because

the APIs and features were together in the same directory.

■ To add a clear separation between the core pieces of the code that render a page using a multi-process browser

■ Not chrome features!!

Page 24: OVERVIEW: Chromium Source Tree

/ipc

● IPC(Inter-Process Communication) module for communcation between chromium processes.

● Reference○ Multi-process architecture

■ http://www.chromium.org/developers/design-documents/multi-process-architecture

Page 25: OVERVIEW: Chromium Source Tree

● New project for isolating components of chromium multi-process architecture that are concerned with ‘Process management’, ‘Sandboxing’, ‘IPC’.○ 3Q 2013, started & in progress○ Similar with ‘IDL’ based generating & binding

system.

● Currently, out of our focus :)

/mojo

Page 26: OVERVIEW: Chromium Source Tree

/net

● The neworking library developed for Chromium○ can be used seperately from Chromium.

■ see also: chrome/common/net○ Mostly single-threaded cross-platform library

primarily for resource fetching

http://www.chromium.org/developers/design-documents/network-stack

Page 27: OVERVIEW: Chromium Source Tree

● Code layout

/net

Directory Descriptions

base net utilities. e.g. host resolution, cookies, network change detection, SSL.

disk_cache Cache for web resources.

websockets WebSockets implementation.

url_request URLRequest, URLRequestContext, URLRequestJob implementations.

spdy SPDY implementation.

socket_stream socket streams for WebSockets

socket Cross-platform implementations of TCP sockets, "SSL sockets", and socket pools.

proxy Proxy (SOCKS and HTTP) configuration, resolution, script fetching, etc.

Page 28: OVERVIEW: Chromium Source Tree

/sandbox

● To prevent a hacked renderer from modifying system○ C++ library for the creation of sandboxed processes

■ processes that execute within a very restrictive environment.

■ The only resources sandboxed processes can freely use are CPU cycles and memory.● e.g. Chromium renderers are sandboxed processes.

http://www.chromium.org/developers/design-documents/sandbox

Page 29: OVERVIEW: Chromium Source Tree

/skia

● Google’s skia graphics library○ /skia has configurations only.

■ Skia implemetation is located in● /third_party/skia

○ https://code.google.com/p/skia/○ See also: some wrappers in /ui/gfx

Page 30: OVERVIEW: Chromium Source Tree

/third_party

● All third-party libraries that Chrome used.○ /third_party/webkit

■ webkit fork, known as ‘blink’○ /third_party/webrtc○ /third_party/webgl○ /third_party/libc++○ /third_party/flac○ …

● Not only C/C++, Java libraries○ You can find js project or python tools in this

directories. :)

Page 31: OVERVIEW: Chromium Source Tree

/ui

● Contains discrete components used to build Chromium’s user interfaces○ each subdir has to have isolated component.

■ 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.○ Contains the base objects.

● See also:○ /chrome/browser/ui/views.

Page 32: OVERVIEW: Chromium Source Tree

/v8

● Google JavaScript Engine○ except Chrome for iOS

■ The iOS security model does not allow an app to execute native code from writeable memory.

■ Memory is either writeable or executable (but read-only).

■ However, V8 is a pure compiler, and doesn't have an interpreter.

○ Project Home:■ https://code.google.com/p/v8/

Page 33: OVERVIEW: Chromium Source Tree

/webkit

● All of Chromium's Webkit related stuff○ But, currently there’re quite many actions are that

moving to out of ‘/webkit’■ e.g. /content, /chrome, …

○ Will be deprecated? Maybe?!