874
edits
(removed old content, marked-up code to improve readability) |
|||
| Line 10: | Line 10: | ||
Predefined globals: | Predefined globals: | ||
* require() | |||
* <code>require()</code> | |||
=== implementation-jetpack context === | === implementation-jetpack context === | ||
| Line 17: | Line 18: | ||
Predefined globals: | Predefined globals: | ||
* jetpack / | * <code>jetpack</code> - the jetpack context global, used to create <code>jetpack.require</code> | ||
* sendMessage("messageName" [, data]); / | * <code>sendMessage("messageName" [, data]);</code> - sends asynchronously, no return value | ||
* callMessage("messageName" [, data]); / | * <code>callMessage("messageName" [, data]);</code> - sends synchronously, has return value | ||
* createHandle(object[, parentHandle]); / | * <code>createHandle(object[, parentHandle]);</code> - returns handle object | ||
* other special globals as necessary, e.g. ctypes would be exposed entirely within the jetpack process and wouldn't need to communicate with chrome | * other special globals as necessary, e.g. ctypes would be exposed entirely within the jetpack process and wouldn't need to communicate with chrome | ||
* registerReceiver(messageName, func) / | * <code>registerReceiver(messageName, func)</code> - incoming messages of the specified name | ||
* wrap(object) / | * <code>wrap(object)</code> - create a COW | ||
=== implementation-chrome context === | === implementation-chrome context === | ||
| Line 29: | Line 30: | ||
The rest of the jetpack implementation would live in the chrome process, primarily in a JS module. A method would exist (via XPCOM?) to bootstrap a jetpack: | The rest of the jetpack implementation would live in the chrome process, primarily in a JS module. A method would exist (via XPCOM?) to bootstrap a jetpack: | ||
var ajetpack = createJetpackProcess(); | <code>var ajetpack = createJetpackProcess();</code> | ||
* ajetpack.sendMessage("messageName" [, data]); / | * <code>ajetpack.sendMessage("messageName" [, data]);</code> - only async messages are allowed | ||
* ajetpack.createHandle(object [, parentHandle]); | * <code>ajetpack.createHandle(object [, parentHandle]);</code> | ||
* ajetpack.loadImplementation(uri); / | * <code>ajetpack.loadImplementation(uri);</code> - load a script into the jetpack implementation context | ||
* ajetpack.loadUserScript(uri); / | * <code>ajetpack.loadUserScript(uri);</code> - load a script into the jetpack context | ||
* ajetpack.registerReceiver(messageName, func) | * <code>ajetpack.registerReceiver(messageName, func)</code> | ||
=== Messages and Handles === | === Messages and Handles === | ||
| Line 41: | Line 42: | ||
Messages that communicate between the browser and jetpack process may contain only serializable (JSON) data and "handles". A handle can be used to provide context for messages. Either the browser or the jetpack implementation may create a handle. A handle keeps its associated JS object alive, and has the following properties: | Messages that communicate between the browser and jetpack process may contain only serializable (JSON) data and "handles". A handle can be used to provide context for messages. Either the browser or the jetpack implementation may create a handle. A handle keeps its associated JS object alive, and has the following properties: | ||
* handle.object / | * <code>handle.object</code> - the JS object associated with the handle | ||
* handle.parent / | * <code>handle.parent</code> - the parent handle of the object, if any | ||
* handle.destroy() / | * <code>handle.destroy()</code> - destroy the handle so that is is no longer valid | ||
* handle.isValid / | * <code>handle.isValid</code> - boolean, is this handle still valid? | ||
A handle that is created without a parent stays alive until it is explicitly destroyed. | A handle that is created without a parent stays alive until it is explicitly destroyed. | ||
| Line 57: | Line 58: | ||
Jetpack: | Jetpack: | ||
<pre>const Request = require("request").Request; | <pre>const Request = require("request").Request; | ||
new Request({ | new Request({ | ||
| Line 64: | Line 66: | ||
implementation-jetpack: | implementation-jetpack: | ||
<pre>function jp_request(r) | <pre>function jp_request(r) | ||
{ | { | ||
| Line 97: | Line 100: | ||
implementation-chrome: | implementation-chrome: | ||
<pre>var ajetpack = createJetpackProcess(); | <pre>var ajetpack = createJetpackProcess(); | ||
| Line 116: | Line 120: | ||
=== Unresolved Issues === | === Unresolved Issues === | ||
This proposal doesn't really deal with jetpack- | This proposal doesn't really deal with jetpack-to-content communication at all, for pagemods, etc. That's an easier question, in some ways: we can use CPOWs, and that already basically works. What we don't know is how to bootstrap it: given a jetpack and a content winow in chrome, how do we set up the machinery for jetpack/content communication? | ||
cjones needs this for cross-process layers as well. The basic idea will be that, in the chrome process, some code will do | cjones needs this for cross-process layers as well. The basic idea will be that, in the chrome process, some code will do | ||
<code>contentProcessParent.Bridge(jetpackParent, PJetpackContent)</code> | |||
which will asynchronously open a new channel between the content and jetpack processes. The new channel will talk PJetpackContent (or whatever that's called). Haven't worked out the notification bits or how the new PJetpackContent top-level actors will be created, but probably the content and jetpack top-levels will get an OnBridge() notification and perhaps that will be where the actors will be required to be created. | which will asynchronously open a new channel between the content and jetpack processes. The new channel will talk <code>PJetpackContent</code> (or whatever that's called). Haven't worked out the notification bits or how the new <code>PJetpackContent</code> top-level actors will be created, but probably the content and jetpack top-levels will get an <code>OnBridge()</code> notification and perhaps that will be where the actors will be required to be created. | ||
== External Resources == | == External Resources == | ||
* [https://developer.mozilla.org/en/Multi-Process_Architecture/Jetpack Multi-process Jetpack] on MDC | * [https://developer.mozilla.org/en/Multi-Process_Architecture/Jetpack Multi-process Jetpack] on MDC | ||
edits