| OLD | NEW |
| 1 # Mojo in Chromium | 1 # Mojo in Chromium |
| 2 | 2 |
| 3 This document is intended to serve as a Mojo primer for Chromium developers. No | 3 This document is intended to serve as a Mojo primer for Chromium developers. No |
| 4 prior knowledge of Mojo is assumed. | 4 prior knowledge of Mojo is assumed. |
| 5 | 5 |
| 6 [TOC] | 6 [TOC] |
| 7 | 7 |
| 8 ## Should I Bother Reading This? | 8 ## Should I Bother Reading This? |
| 9 | 9 |
| 10 If you're planning to build a Chromium feature that needs IPC and you aren't | 10 If you're planning to build a Chromium feature that needs IPC and you aren't |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 // Tada! | 175 // Tada! |
| 176 frobinator->Frobinate(); | 176 frobinator->Frobinate(); |
| 177 ``` | 177 ``` |
| 178 | 178 |
| 179 Behind the scenes this serializes a message corresponding to the `Frobinate` | 179 Behind the scenes this serializes a message corresponding to the `Frobinate` |
| 180 request and writes it to one end of the pipe. Eventually (and incidentally, | 180 request and writes it to one end of the pipe. Eventually (and incidentally, |
| 181 very soon after), `impl`'s internal `mojo::Binding` will decode this message and | 181 very soon after), `impl`'s internal `mojo::Binding` will decode this message and |
| 182 dispatch a call to `impl.Frobinate()`. | 182 dispatch a call to `impl.Frobinate()`. |
| 183 | 183 |
| 184 **NOTE:** In this example the service and client are in the same process, and |
| 185 this works just fine. If they were in different processes (see the example below |
| 186 in [Exposing Services in Chromium](#Exposing-Services-in-Chromium)), the call |
| 187 to `Frobinate()` would look exactly the same! |
| 188 |
| 184 ### Responding to Requests | 189 ### Responding to Requests |
| 185 | 190 |
| 186 A common idiom in Chromium IPC is to keep track of IPC requests with some kind | 191 A common idiom in Chromium IPC is to keep track of IPC requests with some kind |
| 187 of opaque identifier (i.e. an integer *request ID*) so that you can later | 192 of opaque identifier (i.e. an integer *request ID*) so that you can later |
| 188 respond to a specific request using some nominally related message in the other | 193 respond to a specific request using some nominally related message in the other |
| 189 direction. | 194 direction. |
| 190 | 195 |
| 191 This is baked into mojom interface definitions. We can extend our `Frobinator` | 196 This is baked into mojom interface definitions. We can extend our `Frobinator` |
| 192 service like so: | 197 service like so: |
| 193 | 198 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 334 |
| 330 This is a work in progress. TL;DR: We'll also soon begin using Mojo services | 335 This is a work in progress. TL;DR: We'll also soon begin using Mojo services |
| 331 from Blink so that the platform layer can consume browser services | 336 from Blink so that the platform layer can consume browser services |
| 332 directly via Mojo. The long-term goal there is to eliminate `content/renderer`. | 337 directly via Mojo. The long-term goal there is to eliminate `content/renderer`. |
| 333 | 338 |
| 334 ## Questions, Discussion, etc. | 339 ## Questions, Discussion, etc. |
| 335 | 340 |
| 336 A good place to find highly concentrated doses of people who know and care | 341 A good place to find highly concentrated doses of people who know and care |
| 337 about Mojo in Chromium would be the [chromium-mojo](https://goo.gl/A4ebWB) | 342 about Mojo in Chromium would be the [chromium-mojo](https://goo.gl/A4ebWB) |
| 338 mailing list[.](https://goo.gl/L70ihQ) | 343 mailing list[.](https://goo.gl/L70ihQ) |
| OLD | NEW |