[Chromium] Chromium Android webview Layer Design

Source: Internet
Author: User

Chromium Android WebView is a Chromium designed for Android WebView to provide a package layer for content. As a whole, it can be understood as a specialized embedder, which can be summed up as:1. The content and partial browser components are packaged into Java implementations for WebView functions Aosp WebView calls. 2. Implement the single-process rendering architecture used by Android WebView. 3. Configure the network module and implement the scheme resolution for the specific needs.
content as a competency provider, so its API is also known as the SPI, which is the service Provider Interface. CAW on the one hand to invoke the content interface to perform operations, on the other hand, extending the content requires Embedder implementation interface (client class and Observer Class).
the structure is as follows:     
The interior consists of 6 parts:Native & Java : package CAW is Java implementation for AOSP WebView in the upper layer. contentmaindelegate (awmaindelegate): Like the other Embedder, the startup manager Contentmainrunner with the content to provide a startup function. Component Clients: Provides client-side code for the browser components used. For example, AutoFill client awautofillclient, and one is webcontentsdelegate. Renderer: is responsible for the use of the Renderer process extension mechanism (basically observers), the Renderer intervention. Browser: The business logic responsible for implementing the Browser process, which also includes net and Renderer_host two sub-projects. *caw also need to use the network module. The network module itself is a common base component. * Using Renderer/browser's directory naming to differentiate the implementation of functions under different processes is also common in other modules, such as components.
The code namespace is under Android_webview.
contentmaindelegatethe code is in Src/android_webview/lib/main.
Contentmaindelegate is the central interface to the content interaction, responsible for the specific execution of the boot process, as well as the need to create a different process/thread interaction with the four clients, responsible for the content of the initial configuration.
key features include:1. Corresponds to the first three functions in the above class diagram. It can interfere with the startup process, especially when the boot process specifies some function switches. For example, the file System API is disabled, WebRTC hardware decoding, and so on. The following is the starting process:
2. Corresponds to the following four functions in the above class diagram. You can let Embedder customize the behavior of content. Contentrendererclient and Contentbrowserclient, for example, are extended mechanisms for renderer and browser processes, respectively. The following will be expanded.

API (Native & Java)contents: Src/android_webview/java and Src/android_webview/nativeAOSP WebView provides a webview control externally, while CAW is responsible for providing awcontents functionality needed for WebView encapsulation contents. As shown in the following:

Another example, Cookiemanager, is the bridge that implements the Net::cookiemonster:

The main interface classes include Awbrowserprocess, which is responsible for loading initialization operations such as the native library, as well as several core classes around Awcontents, both directly registered with the content Layer's observer implementation ( Awcontentsclient), there are also native operating content (awsettings):
where awcontentsclient is the result of a combination of two important notification interface conentviewclient,contentvideoviewclient from the content layer, Webcontentsobserver will be transferred to the awcontentsclient, and then to the AOSP layer. Awbrowsercontext Stores some of the objects needed for browser, such as sharedpreferences (an XML-based storage mechanism for Android), Cookiemanager, and so on.
(Sharedpreferences is mainly used for awgeolocationpermissions stored in each domain name of the switch settings, whether it can be integrated into the unified settings? or global Settings reference sharedpreferences to achieve?)
In addition, some related classes defined in WebView can find corresponding implementations on this layer. android.webview.WebStorage <--> awquotamanagerbridge <-JNI-> storage::quotamanagerandroid.webview.CookieManager <--> Awcookiemanager <-jni->net::cookiemonster


Rendererthe means of interaction are mainly based on renderer extensions, including observer, client, and IPC mechanisms. the class diagram involved:
all kinds of responsibilities can be seen from the definition of their methods, not to repeat them.
can reflect the mechanism of Renderviewobserver:
* Where Awrenderviewhostext is a similar class that belongs to the implementation of the browser process.  Main timing Diagram:


BrowserCAW's Browser module implements most of CAW's business logic, including encapsulation calls to content, and implementation of a single-process rendering architecture. The portion of the rendering and the encapsulation of the network module are explained separately below.
content encapsulation is mainly the content API in the browser process part of encapsulation, implementation, is as a embedder necessary part, involving more analogies, of which awcontentbrowserclient as the core. (Look back at the Awmaindelegate class diagram.) )



Renderingfrom the evolution of chromium WebView hardware rendering mode, where 1&2 can reflect CAW need to be responsible for WebView OnDraw operation and synchronous compositor connection.


The above figures have illustrated the entire drawing process. Simplified view CAW's rendering is based on the Android View OnDraw () operation and then back to Android View's viewroot.

The following are the main class diagrams:


Network
The main class diagram is as follows:
Awnetworkdelegate adds x-requested-with to the header of the request to identify the request that is being sent by the current package. Awurlrequestcontextgetter also designates browserthread as a network thread, in addition to initializing the network context, including the parser that specifies the Android specific scheme.

the creation process is triggered when a urlrequestcontext is first acquired and a network context is established. The load request can then be initiated based on it. As shown in the following:

Android Special schemes processingNet::urlrequestinterceptingjobfactory uses layers of nested job factory to compose the parse chain of different schemes of needles. Such as:

Key points:1. Implements the Androidstreamreaderurlrequestjob support request to read data in Java Stream's method. 2. Androidrequestinterceptorbase implements task control and registers the Awurlrequestcontextgetter to the network layer for content: and asset (file:///android_ Asset/and file:///android_res/) protocol interpreter.



CAW's reliance on components

Reprint Please specify Source: http://blog.csdn.net/horkychen


[Chromium] Chromium Android webview Layer Design

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.