Chromium multi-process resource loading

Source: Internet
Author: User

WebKit notes, mainly from Ju Yongsheng "WebKit Technology Insider" study notes, reproduced on the original, the book is the only WebKit core books, learning a good mentor, recommend interested friends can buy

Multi-process

The actual loading of resources has different implementations in each WebKit port. Chromium uses a multi-process resource-loading mechanism

According to the resource loading process with the resource caching mechanism, the parts under the Resourcehandle class are different implementations of the migration to get the resources.

In chromium, the way to get a resource is to use a multi-process resource to load the schema. For example, describes how chromium uses a multi-process architecture to complete the loading of resources, mostly multiple Renderer processes

and the browser process between the call design main class.

The render process needs to acquire resources during the loading of the Web page, but because of security (in fact, when the sandbox model is open, the render process is not authorized to get the resources) and efficiency (resource sharing, etc.) considerations, The resource acquisition of the render process is actually done by passing the task to the browser process through interprocess communication, and the browser process has permission to get the resource from the network or locally

In the renderer process in the Chromium schema, the Resourcehandleinternal class communicates by Ipcresourceloaderbridge a similar Browser process

The Ipcresourceloaderbridge class inherits from the Resourceloaderbridge class, which is responsible for initiating the requested object and interpreting the results of the reply, and receiving and distributing the actual messages to the Resourcedispatcher class to handle

In the Browser process, the message of the renderer process is first filtered by the Resourcemessagefilter class, and if it is related to a resource request, the filter class forwards the request to the Resourcedispatcherhostimpl class. The Resourcedispatcherhostimpl class is then created to handle the Resourceloader object in the Browser process.

Resourceloader class is the actual resource load class of Chromium browser, it is responsible for managing the request to the network, receiving the authentication request from the network, requesting the reply management and so on. Because each of these has a special category of old responsibility, but all are managed by the Resourceloader class.

The URLRequest class, which reads information from a network or local file, actually assumes the task of establishing a network connection, sending request data, and receiving reply data, and urlrequest the work to the protocol stack.

How to work and share resources

Resource requests are available in both synchronous and asynchronous ways.

The Resourceloader class takes on the overall management of resources in the browser process, and for both synchronous and asynchronous resource requests, the Resourceloader class uses Syncresourcehandle classes and

The Asyncresourcehandle class sends status messages to the render process and receives feedback from the render process on these messages, describing the relationships between these classes:

The figure also has two resourcehandle subclasses, the first is the Layeredresourcehandle class, it is not the same as the Syncresourcehandle class and the Asyncresourcehandle class, they do not directly participate in the processing of resources, Instead, the processing is transferred to another Resourcehandle object.

The Layeredresourcehandle class has no practical meaning, only the Bufferresourcehandle parent class. This buffer class is used to buffer the network or the data transmitted by the file until the data is sufficient to meet the requirements and then transferred to another Resourcehandle object set.

The Throttling-resourcehandle class uses only one URLRequest object to obtain resources when confronted with many resource requests, which can effectively reduce network overhead because there is no need to reestablish multiple network connections

In addition, there are many resourcehandle subclasses in chromium, which have different roles.

Redirecttofileresourcehandler: Inherits from the Layeredresourcehandle class, when the received data is transferred to another Resourcehandle class, it is dumped to the file

Streamresourcehandler: Inherits from the Layeredresourcehandle class, while the received data is transferred to another resourcehandle, the dumped data stream

Certificateresourcehandler: Resource requests that primarily handle certificate classes

Resource unification is given to the browser process, which makes it easy to share resources across different Web pages.

Next comes a problem, because each Renderer process may have multiple requests in a certain period of time, as well as multiple Renderer processes, and the browser process needs to handle a large number of resource requests, which requires a scheduler that handles these requests, which is the Chromium Resourcescheduler.

The object that the Resourcescheduler class manages is the topmost class Net::urlrequest object. The Resourcescheduler class Dispatches URLRequest objects based on urlrequest flags and priorities, each

The URLRequest object has a child and a routeid to mark which renderer process belongs to. There is a hash table in the Resourceschedule class that organizes the URLRequest objects according to the process.

The following types of network requests are immediately issued by Chromium:

1 High-priority requests

2 Synchronization Requests

3 Server with SPDY capability

Chromium multi-process resource loading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.