Confirmed users
716
edits
No edit summary |
No edit summary |
||
| Line 6: | Line 6: | ||
<code> | <code> | ||
<pre> | <pre> | ||
[NoInterfaceObject] interface WorkerFactory { | |||
Worker createWorker(in DOMString scriptURL); | |||
}; | |||
interface Worker | interface Worker | ||
{ | { | ||
| Line 15: | Line 20: | ||
attribute EventListener onload; | attribute EventListener onload; | ||
attribute EventListener onunload; | attribute EventListener onunload; | ||
}; | |||
[NoInterfaceObject] interface WorkerParent | |||
{ | |||
void postMessage(in DOMString aMessage); | |||
// event handler attributes | |||
attribute EventListener onmessage; | |||
}; | }; | ||
| Line 21: | Line 34: | ||
readonly attribute WorkerGlobalScope self; | readonly attribute WorkerGlobalScope self; | ||
readonly attribute WorkerLocation location; | readonly attribute WorkerLocation location; | ||
readonly attribute WorkerParent parent; | |||
readonly attribute boolean closing; | readonly attribute boolean closing; | ||
void close(); | void close(); | ||
// event handler attributes | // event handler attributes | ||
attribute EventListener onunload; | attribute EventListener onunload; | ||
| Line 36: | Line 47: | ||
void showNotification(in DOMString title, in DOMString subtitle, in DOMString description); | void showNotification(in DOMString title, in DOMString subtitle, in DOMString description); | ||
void showNotification(in DOMString title, in DOMString subtitle, in DOMString description, in VoidCallback onclick); | void showNotification(in DOMString title, in DOMString subtitle, in DOMString description, in VoidCallback onclick); | ||
}; | }; | ||
| Line 76: | Line 83: | ||
<code> | <code> | ||
<pre> | <pre> | ||
onmessage = function(e) { | parent.onmessage = function(e) { | ||
if (e.data <= 1) | if (e.data <= 1) | ||
postMessage(e.data); | postMessage(e.data); | ||
| Line 105: | Line 112: | ||
The only thing I've seen so far is the [http://code.google.com/apis/gears/api_workerpool.html Google Gears WorkerPool API]. We would certainly like to provide a API that would make migrating Gears code trivial. | The only thing I've seen so far is the [http://code.google.com/apis/gears/api_workerpool.html Google Gears WorkerPool API]. We would certainly like to provide a API that would make migrating Gears code trivial. | ||
== API Proposal For Shared Workers == | |||
If we want to support shared workers in the initial release of this spec, here are two proposals that will work with the above initial API. | |||
=== Proposal 2 === | |||
<blockquote> | |||
<code> | |||
<pre> | |||
[NoInterfaceObject] interface WorkerFactory { | |||
... | |||
Worker createSharedWorker(in DOMString name, in DOMString scriptURL); | |||
}; | |||
</pre> | |||
</code> | |||
</blockquote> | |||
<code>createSharedWorker</code> creates a new <code>Worker</code> object that interacts with the same <code>WorkerGlobalScope</code> as any previously existing <code>Worker</code>s. When <code>postMessage</code> is called from within a shared <code>WorkerGlobalScope</code> all connected <code>Worker</code> objects will received that message through their <code>onmessage</code> property. | |||
The | |||