/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is worker threads. * * The Initial Developer of the Original Code is * Mozilla Corporation. * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Vladimir Vukicevic (Original Author) * Ben Turner * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsISupports.idl" interface nsIScriptError; [scriptable, function, uuid(e50ca05d-1381-4abb-a021-02eb720cfc38)] interface nsIDOMWorkerMessageListener : nsISupports { /** * 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 nsISupports) * The worker that sent the message. Useful for a quick response. */ void onMessage(in DOMString aMessage, in nsISupports 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 nsISupports) * The worker that sent the message. Depending on the specific error in * question it may not be possible to use this object (in the case of a * parse error, for instance, aSource will be unusable). */ void onError(in nsIScriptError aError, in nsISupports aSource); }; [scriptable, uuid(6f19f3ff-2aaa-4504-9b71-dca3c191efed)] interface nsIDOMWorkerThread : nsISupports { /** * Sends a message to the worker. * * @param aMessage (in DOMString) * The message to send. */ void postMessage(in DOMString aMessage); }; [scriptable, uuid(45312e93-8a3e-4493-9bd9-272a6c23a16c)] interface nsIDOMWorkerPool : nsISupports { /** * Sends a message to the pool. * * @param aMessage (in DOMString) * The message to send.. */ void postMessage(in DOMString aMessage); /** * The nsIDOMWorkerMessageListener which handles messages for this worker. * * Developers should set this attribute to a proper object before another * worker begins sending messages to ensure that all messages are received. */ attribute nsIDOMWorkerMessageListener messageListener; /** * 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. */ attribute nsIDOMWorkerErrorListener errorListener; /** * Create a new worker object by evaluating the given script. * * @param aSourceScript (in DOMString) * The script to compile. See below for details on the scope in which * the script will run. */ nsIDOMWorkerThread createWorker(in DOMString aSourceScript); /** * Create a new worker object by evaluating the given script. * * @param aSourceURL (in AString) * The script url to load and compile. See below for details on the * scope in which the script will run. */ nsIDOMWorkerThread createWorkerFromURL(in AString aSourceURL); }; [scriptable, uuid(0f2a52ea-afc9-49e6-86dd-2d0cb65b5dd5)] interface nsIDOMThreadService : nsISupports { /** * Creates a new DOM worker pool. */ nsIDOMWorkerPool createPool(); }; [scriptable, uuid(fcf387be-a7e3-4283-8bc5-06bfe13c5e8c)] interface nsIDOMWorkerThreadContext : nsISupports { readonly attribute nsIDOMWorkerThread thisThread; };