Changes

Jump to: navigation, search

DOMWorkerThreads

4,009 bytes removed, 02:55, 13 August 2008
no edit summary
interface nsIScriptError;
[scriptable, function, uuid(e50ca05d-1381-4abb-a021-02eb720cfc38)]interface nsIDOMWorkerMessageListener : nsISupportsWorker
{
/** * An nsIDOMWorkerThread receives the onMessage callback when another * worker posts a message to it. * * @param aMessage (in DOMString) * The message sent from another worker. * @param aSource (in nsIDOMWorkerThread) * The worker that sent the message. Useful for a quick response. */ void onMessagepostMessage(in DOMString aMessage, in nsIDOMWorkerThread aSource);};
[scriptable, function, uuid(9df8422e-25dd-43f4-b9b9-709f9e074647)]interface nsIDOMWorkerErrorListener : nsISupports{ /** * An nsIDOMWorkerPool receives the onError callback when one of its child * workers has a parse error or an unhandled exception. * * @param aMessage (in nsIScriptError) * Details about the error that occurred. See nsIScriptError. * @param aSource (in nsIDOMWorkerThread)/ event handler attributes * The worker that sent the message. Depending on the specific error in attribute EventListener onmessage; * question it may not be possible to use this object (in the case of a attribute EventListener onerror; * parse error, for instance, aSource will be unusable). */ void onError(in nsIScriptError aError, attribute EventListener onload; in nsIDOMWorkerThread aSource) attribute EventListener onunload;
};
[scriptable, uuid(6f19f3ff-2aaa-4504-9b71-dca3c191efed)]
interface nsIDOMWorkerThread : nsISupports
{
/**
* Sends a message to the worker.
*
* @param aMessage (in DOMString)
* The message to send. This may be a string or an object that can be
* serialized via JSON (see http://developer.mozilla.org/en/docs/JSON).
*/
void postMessage(in DOMString aMessage);
};
[scriptable, uuid(45312e93-8a3e-4493-9bd9-272a6c23a16c)NoInterfaceObject]interface nsIDOMWorkerPool : nsIDOMWorkerThreadWorkerGlobalScope
{
/**readonly attribute WorkerGlobalScope self; * The nsIDOMWorkerMessageListener which handles messages for this pool. readonly attribute WorkerLocation location; * * Developers should set this readonly attribute to a proper object before another * worker begins sending messages to ensure that all messages are received. */boolean closing; attribute nsIDOMWorkerMessageListener messageListenervoid close();
/** * The nsIDOMWorkerErrorListener which handles errors in child threads. * * Developers should set this attribute to a proper object before calling * createWorker in order to catch parse errors as well as runtime exceptions. */event handler attributes attribute nsIDOMWorkerErrorListener errorListenerEventListener onunload;
/**/ WorkerUtils * Create a new worker object by evaluating the given script. void importScripts([Variadic] in DOMString urls); * readonly attribute Storage localStorage; * @param aSourceScript Database openDatabase(in DOMStringname, in DOMString version, in DOMString displayName, in unsigned long estimatedSize); * The script to compile. See below for details on the scope void showNotification(in DOMString title, in DOMString subtitle, in which * the script will run. */DOMString description); nsIDOMWorkerThread createWorkervoid showNotification(in DOMString aScriptTexttitle, in DOMString subtitle, in DOMString description, in VoidCallback onclick);};
[NoInterfaceObject] interface WorkerFactory { /** * Create a new worker object by evaluating the given script file. * * @param aSourceScript Worker createWorker(in nsIURIDOMString scriptURL) * The script file to compile. See below for details on the scope in * which the script will run. See nsIURI. */; nsIDOMWorkerThread createWorkerFromURIWorker createSharedWorker(in DOMString aScriptURIname, in DOMString scriptURL);
};
[NoInterfaceObject] interface nsIDOMWorkerGlobalScopeWorkerLocation { /** * The worker object that created this scope. */ readonly attribute nsIDOMWorkerThread thisThreadDOMString href/** * Sends a message to the pool that created the worker. * * @param aMessage (in readonly attribute DOMString) * The message to send. This may be a string or an object that can be * serialized via JSON (see http://developer.mozilla.org/en/docs/JSON). */protocol; void postMessageToPool(in readonly attribute DOMString aMessage)host/** * The nsIDOMWorkerMessageListener which handles messages for this worker. * * Developers should set this readonly attribute to a proper object before another * worker begins sending messages to ensure that all messages are received. */DOMString hostname; readonly attribute nsIDOMWorkerMessageListener messageListenerDOMString port/** * Loads the scripts indicated from the given URI or array. * * This function will block until the script files have been loaded and * executed. Load order is not guaranteed, but execution order will be * determined by the order in the given array. * * @param aURIString * The URI to load or an array of URIs to load. * XXX We could also make this function take a variable number of * arguments and forget the array... * * @throws Will throw an nsIException if the URI cannot be loaded or * executed. */ void loadScripts(/* in JSObject aURIStringOrArray */)readonly attribute DOMString pathname/** * Creates a new XMLHttpRequest object. * * Use: 'var req = new XMLHttpRequest()readonly attribute DOMString search;' */ /* nsIJSXMLHttpRequest XMLHttpRequest(); */  /** * See nsIDOMJSWindow.idl */ void dump(in readonly attribute DOMString str);  /** * See nsIDOMJSWindow.idl */ long setTimeout(/* in JSObject aFunctionOrString, */ /* in JSObject aMilisecondDelay, */ /* [optional] in aArgsToFunctionOrString */);  /** * See nsIDOMJSWindow.idl */ long setInterval(/* in JSObject aFunctionOrString, */ /* in JSObject aMilisecondDelay, */ /* [optional] in aArgsToFunctionOrString */);  /** * See nsIDOMJSWindow.idl */ void clearTimeout(/* in JSObject aTimeoutId */);  /** * See nsIDOMJSWindow.idl */ void clearInterval(/* in JSObject aIntervalId */)hash;
};
</code>
</blockquote>
 
=== The worker pool's scope ===
 
The scope for the worker pool is the standard DOM scope. All DOM objects such as <code>window</code> and <code>document</code> are available, as well as functions such as <code>alert()</code> and <code>dump()</code>.
=== The worker's scope ===
The worker's scope is far more limited. See <code>nsIDOMWorkerGlobalScopeWorkerGlobalScope</code> above for details.
=== Sample usage ===
Confirm
716
edits

Navigation menu