blob: b3bb2ffb652aa57e367a9fe7b3282ff46e2c821d [file] [log] [blame]
jam77c81222016-07-22 05:50:221This directory is for features that are intended for reuse. Example use cases:
2-code that is shared by Chrome on iOS and other Chrome platforms (since the iOS
3 port doesn't use src/chrome)
4-code that is shared between multiple embedders of content (e.g., Android
5 WebView and Chrome)
6-code that is shared between Blink and the browser process (since code in the
7 browser doesn't use Blink, while Blink doesn't include content or chrome to
8 avoid circular dependencies)
9
10In general, if some code is used by a directory "foo" and things above "foo" in
11the dependency tree, the code should probably live in "foo".
[email protected]f5321782014-03-11 11:47:1712
[email protected]fe0035162014-05-06 14:34:5513By default, components can depend only on the lower layers of the Chromium
jam77c81222016-07-22 05:50:2214codebase (e.g. base/, net/, etc.). Individual components may additionally allow
[email protected]fe0035162014-05-06 14:34:5515dependencies on the content API and IPC; however, if such a component is used
16by Chrome for iOS (which does not use the content API or IPC), the component
17will have to be in the form of a layered component
[email protected]f5321782014-03-11 11:47:1718(http://www.chromium.org/developers/design-documents/layered-components-design).
[email protected]5ec3ed82012-12-27 11:44:0019
20Components that have bits of code that need to live in different
21processes (e.g. some code in the browser process, some in the renderer
22process, etc.) should separate the code into different subdirectories.
23Hence for a component named 'foo' you might end up with a structure
[email protected]fe0035162014-05-06 14:34:5524like the following (assuming that foo is not used by iOS and thus does not
25need to be a layered component):
[email protected]5ec3ed82012-12-27 11:44:0026
27components/foo - DEPS, OWNERS, foo.gypi
28components/foo/browser - code that needs the browser process
29components/foo/common - for e.g. IPC constants and such
30components/foo/renderer - code that needs renderer process
31
32These subdirectories should have DEPS files with the relevant
33restrictions in place, i.e. only components/*/browser should
34be allowed to #include from content/public/browser.
35
36Note that there may also be an 'android' subdir, with a Java source
37code structure underneath it where the package name is
38org.chromium.components.foo, and with subdirs after 'foo'
39to illustrate process, e.g. 'browser' or 'renderer':
40
41components/foo/android/OWNERS, DEPS
42components/foo/android/java/src/org/chromium/components/foo/browser/
43components/foo/android/javatests/src/org/chromium/components/foo/browser/
44
[email protected]a70edd22013-04-09 09:23:0445Code in a component should be placed in a namespace corresponding to
46the name of the component; e.g. for a component living in
47//components/foo, code in that component should be in the foo::
[email protected]fe0035162014-05-06 14:34:5548namespace.