Before the beginning of the article, I want to talk about a few words, a look at the chrome code, almost dizzy, touch to touch the mind, and finally looked at a little bit of code, but like elephant, can not view the whole world, the following this small article, a brief introduction of one of the important module--component design, Open the idea for us to read Google's code.
Overview The Chrome browser component is a Google project that is used to constantly block Chrome's code. Extracting the entire content module from the Src/chrome directory, despite the efforts of the component project, the directory (Src/chrome) is still the largest interdependent module so far. As a result, extracting the src/chrome submodule remains one of the next steps for the Google team.
The goal is well known that the Chrome project has grown a lot over the last few years, both in code and in complexity. The number of people who contributed code to the project has also increased, and Google has added many target platforms and configurations that were not foreseen by them early in the project's inception. It's getting harder for everyone to understand the whole architecture, not to mention all the code. The Chrome browser component project introduces modularity and enforcement, with the following objectives:
- Scaling up the architecture makes the browser more suitable for changes in requirements, such as: Browsers using the Src/chrome/browser module want to switch off or re-implement certain modules, such as Chrome on Android;
- By further implementing the dependency graph, the architecture we want to implement becomes clearer. Those dependency rules indicate which sub-modules are allowed and which are disallowed.
- Greatly simplifies the dependency diagram of the Src/chrome submodule, so that they do not cycle dependence;
- Accelerate the developer's browser build process by adding many independent components such as unit test executable programs. Reduce the maximum component connection time, such as the browser component. The unit test program is smaller, which is useful for debugging code with GDB, or for quickly facilitating code through printf.
- The approach mentioned above should reduce concerns and make it easier for the Google team to work together, making the architecture less misunderstood and less prone to writing bad architectures that often make us more efficient.
Design Overview
1 Extract the Src/chrome directory of components, these components become a goal, they have their own independent unit test target, clearly specify their dependence, no cyclic dependence.
2 No cyclic dependencies
Refers to components that do not recognize their own users (Embedder)-modules that embed components such as src/chrome. If a component needs to obtain information and services from its own users, they can get it at initialization time, or the runtime is obtained through an abstract client interface, which is implemented by the component definition, the user (Embedder).
Where are the 3 components?
In Src/components/'s subdirectory.
- Note: Some modules are more like an abstraction layer-such as src/content, or more like a product-such as src/chrome, which should have their own top-level directories instead of being placed in the Src/components directory.
4 where is the client interface?
Their statements are in each component and are implemented in the user of the component.
Does the 5 component need to provide the API to the component's consumer calls?
A: Generally speaking, the following usage is not a problem: the user of the component uses a specific class of C + + class to use the component, in which case the API is very simple, no matter what the build class is-the component receives a pointer to implement a delegate interface from the consumer. In some cases, Google introduces a completely abstract API to the user invocation of the component, which hides the implementation details of the component, just as they did for the src/content component. In some other cases, they classify the component's C + + specific classes, part of the internal class, and part of the public class. Both internal and external, they should be present in the component directory, for example: src/components/mycomponent/public/. If the public classification of a component exists, the client interface of the component should exist there. Section reference: Http://www.chromium.org/developers/content-module
This article is original, reproduced please indicate the source, offenders must investigate
Follow Chromium group 480089700, or public platform: Programmer Interaction Alliance (coder_online), you can get original technical articles first, and (Java/c/c++/android/windows/linux) technology Daniel to be friends, Online communication programming experience, get programming basics, solve programming problems. Programmer Interactive Alliance, Developer's own home.
Chromium Browser Component Design intent