读书人

Chromium Design Document学习及通译之

发布时间: 2013-03-21 10:08:17 作者: rapoo

Chromium Design Document学习及翻译之Multi-process Architecture
Chromium Design Document学习及翻译之Multi-process Architecture
http://www.chromium.org/developers/design-documents/multi-process-architecture

Multi-process Architecture

This document describes Chromium's high-level architecture.

Problem

It's nearly impossible to build a rendering engine that never crashesor hangs. It's also nearly impossible to build a rendering engine thatis perfectly secure.

In some ways, the current state of web browsers is like that of the single-user, co-operatively multi-tasked operating systems of the past. As a misbehaving application in such an operating system could take down the entire system, so can a misbehaving web page in a modern web browser. All it takes is one browser or plug-in bug to bring down the entire browser and all of the currently running tabs.

Modern operating systems are morerobust because they put applications into separate processes that arewalled off from one another. A crash in one application generally doesnot impair other applications or the integrity of the operating system, and each user's access to other users' data is restricted.

以上皆浮云,飘过

Architectural overview

We use separate processes for browser tabs to protect theoverall application from bugs and glitches in the rendering engine. We also restrict access from each rendering engine process to others and to the rest of the system. In some ways, this brings to web browsing the benefits that memory protection and access control brought to operating systems.


我们对browser的各个tabs分别分配各自的process,从而使得某个rendering engine(即对应下文的BRender)出现问题而导致整个浏览器应用程序崩溃。我们限制各个rendering engine process之间的下相互访问及访问浏览器中的其它系统。通过这些方法,使得浏览器能够获得由操作系统提供的内存安全及访问控制所带来的好处。

译注:这里的tabs管理,在启动chromium的时候,可以通过命令行参数来觉得如何管理所有的rendering engine,你是可以要求所有相关的domain内的页面都使用同一个rendering engine process。参看 --process-per-tab。参看下文的Sharing the render process
http://peter.sh/experiments/chromium-command-line-switches/中有所有chromium支持的启动参数。

We refer to the main process that runs the UI and manages tab and plugin processes as the "browser process" or "browser." Likewise, the tab-specific processes are called "render processes" or "renderers." The renderers use theWebKit open-source layout engine for interpreting and laying out HTML.

我们把运行UI,管理tab及plugin process的主process称为browser process或者browser. 同样各个tab的process我们称为render process或者renders。renders使用webkit作为layout engine来处理及解释HTML。


译注:一定注意browser和各个render之间都是通过相应的IPC机制间接通信的。
对这张图更详细的讲解,参看http://www.youtube.com/watch?v=A0Z0ybTCHKs
http://blog.marcchung.com/2008/09/05/chromes-process-model-explained.html, 着重解释了per-prcess-xxx的意思。
http://archrometects.files.wordpress.com/2009/10/assignment-01-conceptual-architecture-of-google-chrome-archrometects.pdf


Chromium Design Document学习及通译之Multi-process Architecture


Managing render processes

Each render process has a global RenderProcess object that manages communication with the parent browser process and maintains global state. The browser maintains a correspondingRenderProcessHost for each render process, which manages browser state andcommunication for the renderer. The browser and the rendererscommunicate usingChromium's IPC system.

管理render processes
每个render process都有一个全局的RenderProcess对象来管理它所对应的父browser process的交互及维护它的全局状态。父的browser process维护了对应于它所管理的render processes所需要的各个RenderProcessHost,用它来跟各个render通信。详细参看Chromium's IPC system.


Each render process has one or more RenderView objects, managed by theRenderProcess, which correspond to tabs of content. The correspondingRenderProcessHost maintains aRenderViewHost corresponding to each view in the renderer. Each view is given a viewID that is used to differentiate multiple views in the same renderer.These IDs are unique inside one renderer but not within the browser, soidentifying a view requires aRenderProcessHost and a view ID. Communication from the browser to a specific tab of content is done through theseRenderViewHost objects, which know how to send messages through theirRenderProcessHost to theRenderProcess and on to theRenderView.


管理Views
每个render process都有一个或多个RenderView对象,它们被对应着各个tab的内容的RenderProcess所管理。 每个RenderProcess在Browser进程都有其对应的RenderProceeHost,它又维护着与RenderView一一对应的RenderViewHost。同一个Render中的多个RenderView都有一个唯一的相互标识的View ID。在Browser进程中要想唯一的找到一个RenderView,需要view id和其对应的RenderProcessHost才行。Browser和各个Render之间的View的通信,需要经由RenderViewHost对象,从它找到对应的RenderProcessHost再到对应的RenderProcess最后确定想要通信的RenderView。


Components and interfaces

In the render process:

The RenderProcess handles IPC with the corresponding RenderProcessHost in the browser. There is exactly oneRenderProcess object per render process. This is how all browser ? renderer communication happens.
RenderProcess用来处理跟Browser侧的IPC交互,一个render process对对应唯一的一个RenderProcess。
The RenderView object communicates with its corresponding RenderViewHost in the browser process (via the RenderProcess), and our WebKit embedding layer. This object represents the contents of one web page in a tab or popup window
RenderView通过RenderProcess来与Browser Process中的RenderViewHost通信,同时也负责与Render内的Webkit layer的通信。一个Render Process可以有多个RenderView,它们分别对应一个tab内的一个或多个page或者popup window。


In the browser process:

读书人网 >软件架构设计

热点推荐