For Developers‎ > ‎

Learning your way around the code

There is lots to learn about the chromium code base, both at a macro level (how the processes are laid out, how IPC works, the flow of a URL load), and at a micro level (code idioms such as smart pointer usage guidelines, message loops, common threads, threading guidelines, string usage guidelines, etc).

Learning to do things the chromium way:
Coding style: http://www.chromium.org/developers/coding-style. If you’ve coded elsewhere, the chrome guidelines (and code reviewer comments) might seem hardcore and nitpicky.  For example, extra spaces at the end of lines are forbidden. All comments should be legitimate English sentences, including the ending period.  There is a strict 80 column limit (with exceptions for things that can’t possibly be broken up).

A personal learning plan:
Eventually you’ll have your build setup, and want to get to work.  In a perfect world, we would have all the time we needed to read every line of code and understand it before writing our first line of code.  In practice, we’d have a hard time reading just the checkins that happen in one day if we did nothing else, so none of us will ever be able to read all of the code.  So, what can we do? We suggest you develop your own plan for learning what you need, here are some suggested starting points.

Fortunately for us, Chromium has some top quality design docs http://www.chromium.org/developers/design-documents.  While these can go a bit stale (for instance, when following along, you may find references to files that have been moved or renamed or refactored out of existence), it is awesome to be able to comprehend the way that the code fits together overall.

  1. Read the most important dev docs
    1. http://www.chromium.org/developers/design-documents/multi-process-architecture
    2. http://www.chromium.org/developers/design-documents/displaying-a-web-page-in-chrome
    3. http://www.chromium.org/developers/design-documents/inter-process-communication
    4. http://www.chromium.org/developers/design-documents/threading
    5. http://www.chromium.org/developers/how-tos/getting-around-the-chrome-source-code
  2. See if your group has any startup docs - there may be some docs that people working on the same code will care about while others don’t need to know as much detail.
  3. Learn some of the code idioms:
    1. http://www.chromium.org/developers/coding-style/important-abstractions-and-data-structures
    2. http://www.chromium.org/developers/smart-pointer-guidelines
    3. http://www.chromium.org/developers/chromium-string-usage
  4. Later, as time permits, skim all the design docs, reading where it seems relevant.
  5. Get good at using code search (or your code browsing tool of choice)
  6. Learn who to ask how the code works (how to find somebody who knows how the code works)
  7. Debug into the code you need to learn, with a debugger if you can, log statements and grepping if you cannot.
  8. Look at the differences in what you need to understand and you currently understand.  For instance, if your group does a lot of GUI programming, then maybe you can invest time in learning GTK+, Win32, or Cocoa programming.

Blink:
Sometimes to make a fix or add a feature to chromium, the right place to put it is in blink (formerly webkit).

There is a “How Webkit works” slide deck here: https://docs.google.com/presentation/pub?id=1ZRIQbUKw9Tf077odCh66OrrwRIVNLvI_nhLm2Gi__F0. While Blink has forked, some of this may still be relevant.
There is also a slide that explains a basic workflow for webkit development for people who are already familiar with chromium development here: http://dev.chromium.org/developers/webkit-development-workflow
Comments