Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(833)

Side by Side Diff: blimp/client/README.md

Issue 2376573002: Cleanup blimp/client/core code organization. (Closed)
Patch Set: merged origin/master Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Blimp Client 1 # Blimp Client
2 2
3 This document contains documentation for the blimp client code organization. 3 This document contains documentation for the blimp client code organization.
4 4
5 For a quick guide for how to add Java files to an existing directory, see 5 For a quick guide for how to add Java files to an existing directory, see
6 [Adding Java files](#adding-java-files) below. 6 [Adding Java files](#adding-java-files) below.
7 7
8 [TOC] 8 [TOC]
9 9
10 ## Code Organization 10 ## Code Organization
(...skipping 20 matching lines...) Expand all
31 31
32 There are sub-directories for logically separate parts, such as `contents` for 32 There are sub-directories for logically separate parts, such as `contents` for
33 code that relate to the contents of a web page. All Android code is put into 33 code that relate to the contents of a web page. All Android code is put into
34 their respective directories, so Android and Java-code related to `contents` 34 their respective directories, so Android and Java-code related to `contents`
35 is put in `contents/android`. 35 is put in `contents/android`.
36 36
37 Each of the sub-directories have their own `BUILD.gn` file, which includes 37 Each of the sub-directories have their own `BUILD.gn` file, which includes
38 targets for both C++ and Java. 38 targets for both C++ and Java.
39 39
40 * `//blimp/client/core/` 40 * `//blimp/client/core/`
41 * `android/` All Android-related code, including Java-code, that are for
42 the code living directly in `//blimp/client/core`.
43 * `compositor/` Code related to the Chrome Compositor. 41 * `compositor/` Code related to the Chrome Compositor.
44 * `contents/` Code related to the contents of a web page. 42 * `contents/` Code related to the contents of a web page.
45 * `contents/android/` JNI bridges and Java-code for `contents`. 43 * `contents/android/` JNI bridges and Java-code for `contents`.
44 * **`context/` Code related to the context (`BlimpClientContext`), which
45 is the core functionality used by all embedders.**
46 * `context/android` JNI bridges and Java-code for `context`.
46 * `session/` Code related to the session with the engine. 47 * `session/` Code related to the session with the engine.
47 48
48 Most code in `core` do not need any Java counterparts unless the embedder is 49 Most code in `core` do not need any Java counterparts unless the embedder is
49 written for Android and it is typically only needed for things that relate to 50 written for Android and it is typically only needed for things that relate to
50 the embedder UI. 51 the embedder UI.
51 52
52 #### Actual and dummy implementations of core 53 #### Actual and dummy implementations of core
53 54
54 The `core` directory has two implementations of the public API, a dummy one 55 The `core` directory has two implementations of the public API, a dummy one
55 and a real one. The default is to use the dummy API, but an embedder can choose 56 and a real one. The default is to use the dummy API, but an embedder can choose
56 to enable full blimp support by setting the GN arguments `enable_blimp_client` 57 to enable full blimp support by setting the GN arguments `enable_blimp_client`
57 to `true`. 58 to `true`.
58 59
59 Basically only the implementation of BlimpClientContext has been split out into 60 Basically only the implementation of `BlimpClientContext` has been split out
60 two parts (both in C++ and Java), and the choice of which backing implementation 61 into two parts (both in C++ and Java), and the choice of which backing
61 to be used is selected by the `enable_blimp_client` flag. 62 implementation to be used is selected by the `enable_blimp_client` flag. These
63 two implementations live in `//blimp/client/context`.
62 64
63 ### The public directory 65 ### The public directory
64 66
65 The `public` directory represents the public API of the blimp client, to be 67 The `public` directory represents the public API of the blimp client, to be
66 used by the embedders. 68 used by the embedders.
67 69
68 Embedders should be able to depend on `//blimp/client/public` for C++ code, 70 Embedders should be able to depend on `//blimp/client/public` for C++ code,
69 and for Java they should depend on `//blimp/client/public:public_java`. This 71 and for Java they should depend on `//blimp/client/public:public_java`. This
70 automatically pulls in the dependencies on the code in `core`. 72 automatically pulls in the dependencies on the code in `core`.
71 73
(...skipping 19 matching lines...) Expand all
91 The `feature` directory is from the old directory organization, and all the 93 The `feature` directory is from the old directory organization, and all the
92 content of this will move over to the `core` directory. The feature-specific 94 content of this will move over to the `core` directory. The feature-specific
93 code will move together with the usage of the feature itself, such as 95 code will move together with the usage of the feature itself, such as
94 `core/contents`. 96 `core/contents`.
95 97
96 #### The session directory 98 #### The session directory
97 99
98 The `session` directory is from the old directory organization, and all the 100 The `session` directory is from the old directory organization, and all the
99 content of this will move over to the `core/session` directory. 101 content of this will move over to the `core/session` directory.
100 102
103 #### The support directory
104
105 The `support` directory is a directory providing help to embedders. This
106 typically includes a default implementation of an interface from
107 `//blimp/client/public` or other helpful tools.
108
101 #### The test directory 109 #### The test directory
102 110
103 The `test` directory contains tools helpful for testing client code. 111 The `test` directory contains tools helpful for testing client code.
104 112
105 ### Adding Java files {#adding-java-files} 113 ### Adding Java files {#adding-java-files}
106 114
107 Most of Blimp is written in C++, but some parts have to be written in Java for 115 Most of Blimp is written in C++, but some parts have to be written in Java for
108 the Android platform. For those parts of the code, it is required to add an 116 the Android platform. For those parts of the code, it is required to add an
109 `android` sub-directory, and put JNI-bridges and Java files within there. 117 `android` sub-directory, and put JNI-bridges and Java files within there.
110 118
111 This will mostly happen in a sub-directory of `core`, so the following section 119 This will mostly happen in a sub-directory of `core`, so the following section
112 explains how to add a Java file with JNI hooks for the imaginary sub-directory ` //blimp/client/core/foo`. Conceptually, it's adding a Java-version of the C++ 120 explains how to add a Java file with JNI hooks for the imaginary sub-directory ` //blimp/client/core/foo`. Conceptually, it's adding a Java-version of the C++
113 class `Foo`, that lives in `//blimp/client/core/foo/foo.[cc|h]`. 121 class `Foo`, that lives in `//blimp/client/core/foo/foo.[cc|h]`.
114 122
115 * The file Foo.java should be added at: 123 * The file Foo.java should be added at:
116 `//blimp/client/core/foo/android/java/src/org/chromium/blimp/core/foo/Foo.ja va` 124 `//blimp/client/core/foo/android/java/src/org/chromium/blimp/core/foo/Foo.ja va`
117 125
118 * The JNI-bridge should live in: 126 * The JNI-bridge should live in:
119 `//blimp/client/core/foo/android/foo_android.[cc|h]` 127 `//blimp/client/core/foo/android/foo_android.[cc|h]`
120 128
121 * Add the JNI-bridge JNI registration to: 129 * Add the JNI-bridge JNI registration to:
122 `//blimp/client/core/android/blimp_jni_registrar.cc` 130 `//blimp/client/core/context/android/blimp_jni_registrar.cc`
123 131
124 * Add this to the top of `//blimp/client/core/foo/BUILD.gn`: 132 * Add this to the top of `//blimp/client/core/foo/BUILD.gn`:
125 133
126 ```python 134 ```python
127 if (is_android) { 135 if (is_android) {
128 import("//build/config/android/config.gni") 136 import("//build/config/android/config.gni")
129 import("//build/config/android/rules.gni") 137 import("//build/config/android/rules.gni")
130 } 138 }
131 ``` 139 ```
132 140
(...skipping 12 matching lines...) Expand all
145 ] 153 ]
146 } 154 }
147 155
148 generate_jni("jni_headers") { 156 generate_jni("jni_headers") {
149 visibility = [ ":*" ] 157 visibility = [ ":*" ]
150 158
151 sources = [ 159 sources = [
152 "android/java/src/org/chromium/blimp/core/foo/Foo.java", 160 "android/java/src/org/chromium/blimp/core/foo/Foo.java",
153 ] 161 ]
154 162
155 jni_package = "blimp/client/core/contents" 163 jni_package = "blimp/client/core/foo"
156 } 164 }
157 ``` 165 ```
158 166
159 * Edit the target `//blimp/client/core/foo:foo` to add this Android-part: 167 * Edit the target `//blimp/client/core/foo:foo` to add this Android-part:
160 168
161 ```python 169 ```python
162 source_set("foo") { 170 source_set("foo") {
163 171
164 ... 172 ...
165 173
166 if (is_android) { 174 if (is_android) {
167 sources += [ 175 sources += [
168 "android/foo.cc", 176 "android/foo.cc",
169 "android/foo.h", 177 "android/foo.h",
170 ] 178 ]
171 179
172 deps += [ ":jni_headers" ] 180 deps += [ ":jni_headers" ]
173 } 181 }
174 } 182 }
175 ``` 183 ```
184
185 * Add `//blimp/client/core/foo:foo_java` as a dependency in
186 `//blimp/client/core:core_java`.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698