Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | interface nsIRunnable; |
michael@0 | 10 | |
michael@0 | 11 | [scriptable, uuid(4e8febe4-6631-49dc-8ac9-308c1cb9b09c)] |
michael@0 | 12 | interface nsIEventTarget : nsISupports |
michael@0 | 13 | { |
michael@0 | 14 | /** |
michael@0 | 15 | * Dispatch an event to this event target. This function may be called from |
michael@0 | 16 | * any thread, and it may be called re-entrantly. |
michael@0 | 17 | * |
michael@0 | 18 | * @param event |
michael@0 | 19 | * The event to dispatch. |
michael@0 | 20 | * @param flags |
michael@0 | 21 | * The flags modifying event dispatch. The flags are described in detail |
michael@0 | 22 | * below. |
michael@0 | 23 | * |
michael@0 | 24 | * @throws NS_ERROR_INVALID_ARG |
michael@0 | 25 | * Indicates that event is null. |
michael@0 | 26 | * @throws NS_ERROR_UNEXPECTED |
michael@0 | 27 | * Indicates that the thread is shutting down and has finished processing |
michael@0 | 28 | * events, so this event would never run and has not been dispatched. |
michael@0 | 29 | */ |
michael@0 | 30 | void dispatch(in nsIRunnable event, in unsigned long flags); |
michael@0 | 31 | |
michael@0 | 32 | /** |
michael@0 | 33 | * This flag specifies the default mode of event dispatch, whereby the event |
michael@0 | 34 | * is simply queued for later processing. When this flag is specified, |
michael@0 | 35 | * dispatch returns immediately after the event is queued. |
michael@0 | 36 | */ |
michael@0 | 37 | const unsigned long DISPATCH_NORMAL = 0; |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * This flag specifies the synchronous mode of event dispatch, in which the |
michael@0 | 41 | * dispatch method does not return until the event has been processed. |
michael@0 | 42 | * |
michael@0 | 43 | * NOTE: passing this flag to dispatch may have the side-effect of causing |
michael@0 | 44 | * other events on the current thread to be processed while waiting for the |
michael@0 | 45 | * given event to be processed. |
michael@0 | 46 | */ |
michael@0 | 47 | const unsigned long DISPATCH_SYNC = 1; |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * Check to see if this event target is associated with the current thread. |
michael@0 | 51 | * |
michael@0 | 52 | * @returns |
michael@0 | 53 | * A boolean value that if "true" indicates that events dispatched to this |
michael@0 | 54 | * event target will run on the current thread (i.e., the thread calling |
michael@0 | 55 | * this method). |
michael@0 | 56 | */ |
michael@0 | 57 | boolean isOnCurrentThread(); |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | %{C++ |
michael@0 | 61 | // convenient aliases: |
michael@0 | 62 | #define NS_DISPATCH_NORMAL nsIEventTarget::DISPATCH_NORMAL |
michael@0 | 63 | #define NS_DISPATCH_SYNC nsIEventTarget::DISPATCH_SYNC |
michael@0 | 64 | %} |