| OLD | NEW |
| 1 # Design of V8 bindings | 1 # Design of V8 bindings |
| 2 | 2 |
| 3 This document explains key concepts in the V8 binding architecture | 3 This document explains key concepts in the V8 binding architecture |
| 4 except the lifetime management of DOM wrappers. | 4 except the lifetime management of DOM wrappers. |
| 5 See [V8GCController.md](V8GCController.md) to learn the lifetime management. | 5 See [V8GCController.md](V8GCController.md) to learn the lifetime management. |
| 6 | 6 |
| 7 [TOC] | 7 [TOC] |
| 8 | 8 |
| 9 ## Isolate | 9 ## Isolate |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 If a debugger is active, the debugger context may be inserted to | 130 If a debugger is active, the debugger context may be inserted to |
| 131 the context stack. | 131 the context stack. |
| 132 | 132 |
| 133 ## World | 133 ## World |
| 134 | 134 |
| 135 A world is a concept to sandbox DOM wrappers among content scripts of | 135 A world is a concept to sandbox DOM wrappers among content scripts of |
| 136 Chrome extensions. There are three kinds of worlds: a main world, | 136 Chrome extensions. There are three kinds of worlds: a main world, |
| 137 an isolated world and a worker world. | 137 an isolated world and a worker world. |
| 138 A main world is a world where a normal JavaScript downloaded from the web | 138 A main world is a world where a normal JavaScript downloaded from the web |
| 139 is executed. | 139 is executed. |
| 140 An isolated world is a world where a content script of a Chrome extension. | 140 An isolated world is a world where a content script of a Chrome extension is |
| 141 executed. |
| 141 An isolate of the main thread has 1 main world and N isolated worlds. | 142 An isolate of the main thread has 1 main world and N isolated worlds. |
| 142 An isolate of a worker thread has 1 worker world and 0 isolated world. | 143 An isolate of a worker thread has 1 worker world and 0 isolated world. |
| 143 [This diagram](https://drive.google.com/file/d/0B1obCOyvTnPKQmJEWkVtOEN2TmM/view
?usp=sharing) | 144 [This diagram](https://drive.google.com/file/d/0B1obCOyvTnPKQmJEWkVtOEN2TmM/view
?usp=sharing) |
| 144 will be helpful to understand the relationship. | 145 will be helpful to understand the relationship. |
| 145 | 146 |
| 146 All worlds in one isolate share underlying C++ DOM objects, | 147 All worlds in one isolate share underlying C++ DOM objects, |
| 147 but each world has its own DOM wrappers. That way the worlds in one isolate | 148 but each world has its own DOM wrappers. That way the worlds in one isolate |
| 148 can operate on the same C++ DOM object without sharing any DOM wrapper | 149 can operate on the same C++ DOM object without sharing any DOM wrapper |
| 149 among the worlds. | 150 among the worlds. |
| 150 | 151 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // iframe.html | 256 // iframe.html |
| 256 <script> | 257 <script> |
| 257 </script> | 258 </script> |
| 258 ``` | 259 ``` |
| 259 | 260 |
| 260 To make sure that a DOM wrapper is created in a correct context, you need to | 261 To make sure that a DOM wrapper is created in a correct context, you need to |
| 261 make sure that the current context must be set to the correct context | 262 make sure that the current context must be set to the correct context |
| 262 whenever you call toV8(). If you're not sure what context to use, | 263 whenever you call toV8(). If you're not sure what context to use, |
| 263 ask haraken@chromium.org. | 264 ask haraken@chromium.org. |
| 264 | 265 |
| OLD | NEW |