Google's Chromium browser source learning--base Public General Library (a)

Source: Internet
Author: User

Google's excellent C + + open source projects, including the Chromium browser project can be said to be very representative, in addition to its third open source Library or its own excellent open source library, can be as needed to extract their own parts of interest. In the study, learning the current time to obtain the need to obtain a copy of Google's chromium source code, can refer to: http://blog.csdn.net/kuerjinjin/article/details/23563059, if not available and intended to use VS The IDE can be downloaded from here: http://blog.csdn.net/kuerjinjin/article/details/23563059 get the source with the solution, compile the success may need to modify some of the project configuration, because its source code later changed, However, the main part of the content changes little, in addition, because the study need not need to seek the latest version of the source code, here will adopt the Chromium39.0.2132.2 version as a reference; Chromium source structure can be consulted: http://blog.csdn.net/ blessyou312/article/details/6253050;

Due to learning needs to stand in the perspective of high-level, such as design patterns, models, threading processes and other communication details; just as a beginner or I study records, from the bottom details of the entire Google Chromium source, later will gradually learn high-level content; In addition to the Google source style can be borrowed from , the specific use of programming, source style can be based on their own interests or the company's internal requirements for development.

Once you get the chromium code, you'll find a lot of top-level catalogs with base libraries: Common code common to all sub-projects. It includes a common library of string operations, files, threads, messages, memory management, and so on, which is common to all other top-level projects. It is also a good practice to be interested in extracting the base library from a single study or applying it to your own projects as part of the available public library. Due to the internal content of the project is scattered, we will follow the module division of the way to understand, learn, first list other files rely on the most basic files, and then for each module detailed analysis, learning.

Base_export.h: Mainly used to define the import and export libraries related macros for different platforms: Base_export; The macro will run through the base library.

Basictypes.h: Mainly based on the support of different platforms to define a simple alias of variable type such as typedef int Int32, etc., the maximum minimum variable definition of various common types (8, 16, 32, 64-bit symbol and unsigned integer); macro declaration Disallow_copy, Disallow_assign, Disallow_copy_and_assign, disallow_implicit_constructors, etc. are used in the private access control domain of the class, respectively, for non-copy, non-assignable assignment, Non-copy and assignment, as well as non-copy assignment and construction, the default C + + class has copy and default constructors, and many times we often use disallow_copy_and_assign to prevent objects from being copied and assigned, to prevent errors such as pointer release due to deep-level copying, etc. , disallow_implicit_constructors can also do this and prevent the default constructor, which is commonly used in singleton mode, allowing only one instance of the scenario to exist; simple Accessibility tools: Arraysize,arraysize_ Unsafe is used to obtain the size of an array of objects in the compiler; Type conversions: Implicit_cast as a secure version of static_cast or const_cast; compile-time assertion tool: Compile_assert, It is mainly through the internal can not be negative as the index of the array to judge; conversion by byte in different types of conversions: Bit_cast, the substitution of reinterpret_cast conversion will produce warning prompts, bit_cast internal use memcpy, it can quickly transform Used in an unsafe situation where return values are not required and return values are returned: Ignore_result, the return value is ignored, in fact, nothing is done in its inner function body; Create a static pointer object: Cr_define_static_local, This operation may result in a memory resource leak that requires normal handling of the released operation and can use the Lazy_ Instance.h in the lazyinstance, can be a safe release of resources, the specific principle is: In the static class contains a static helper object, which is responsible for deleting the object, releasing resources.

Build_config.h: The corresponding macros are defined primarily for different platforms and are used for compile-time differentiation, including operating systems: Windows, Mac, Linux, POSIX series, compilers: MSVC, GCC, and processor X86, X64, etc.

Port.h: For different compilers, declare variable type long integer, 8, 16, 32, 64-bit, and unsigned integer, before use in valist: Gg_va_copy, to determine if the type supports copying (the inside is actually a simple copy operation) In Windows, the contract for the API function is reduced: Api_call macro, that is, __stdcall (the argument is passed from right to left through the stack, and the function call is cleaned up by the callee before it is returned).

In the future, the modules are ranked without primary and secondary, according to the alphabetical index respectively; the next one will analyze the allocator allocator of Chrominum, which will be studied and studied in detail in its memory manager Jemalloc and Tcmalloc, where jemalloc For BSD-provided memory allocation management and Tcmalloc is Google's memory allocation management module .

Google's Chromium browser source learning--base Public General Library (a)

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.