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 | * |
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 | /** |
michael@0 | 12 | * Interface for the native event system layer. This interface is designed |
michael@0 | 13 | * to be used on the main application thread only. |
michael@0 | 14 | */ |
michael@0 | 15 | [uuid(2d10ca53-f143-439a-bb2e-c1fbc71f6a05)] |
michael@0 | 16 | interface nsIAppShell : nsISupports |
michael@0 | 17 | { |
michael@0 | 18 | /** |
michael@0 | 19 | * Enter an event loop. Don't leave until exit() is called. |
michael@0 | 20 | */ |
michael@0 | 21 | void run(); |
michael@0 | 22 | |
michael@0 | 23 | /** |
michael@0 | 24 | * Exit the handle event loop |
michael@0 | 25 | */ |
michael@0 | 26 | void exit(); |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * Give hint to native event queue notification mechanism. If the native |
michael@0 | 30 | * platform needs to tradeoff performance vs. native event starvation this |
michael@0 | 31 | * hint tells the native dispatch code which to favor. The default is to |
michael@0 | 32 | * prevent native event starvation. |
michael@0 | 33 | * |
michael@0 | 34 | * Calls to this function may be nested. When the number of calls that pass |
michael@0 | 35 | * PR_TRUE is subtracted from the number of calls that pass PR_FALSE is |
michael@0 | 36 | * greater than 0, performance is given precedence over preventing event |
michael@0 | 37 | * starvation. |
michael@0 | 38 | * |
michael@0 | 39 | * The starvationDelay arg is only used when favorPerfOverStarvation is |
michael@0 | 40 | * PR_FALSE. It is the amount of time in milliseconds to wait before the |
michael@0 | 41 | * PR_FALSE actually takes effect. |
michael@0 | 42 | */ |
michael@0 | 43 | void favorPerformanceHint(in boolean favorPerfOverStarvation, |
michael@0 | 44 | in unsigned long starvationDelay); |
michael@0 | 45 | |
michael@0 | 46 | /** |
michael@0 | 47 | * Suspends the use of additional platform-specific methods (besides the |
michael@0 | 48 | * nsIAppShell->run() event loop) to run Gecko events on the main |
michael@0 | 49 | * application thread. Under some circumstances these "additional methods" |
michael@0 | 50 | * can cause Gecko event handlers to be re-entered, sometimes leading to |
michael@0 | 51 | * hangs and crashes. Calls to suspendNative() and resumeNative() may be |
michael@0 | 52 | * nested. On some platforms (those that don't use any "additional |
michael@0 | 53 | * methods") this will be a no-op. Does not (in itself) stop Gecko events |
michael@0 | 54 | * from being processed on the main application thread. But if the |
michael@0 | 55 | * nsIAppShell->run() event loop is blocked when this call is made, Gecko |
michael@0 | 56 | * events will stop being processed until resumeNative() is called (even |
michael@0 | 57 | * if a plugin or library is temporarily processing events on a nested |
michael@0 | 58 | * event loop). |
michael@0 | 59 | */ |
michael@0 | 60 | void suspendNative(); |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Resumes the use of additional platform-specific methods to run Gecko |
michael@0 | 64 | * events on the main application thread. Calls to suspendNative() and |
michael@0 | 65 | * resumeNative() may be nested. On some platforms this will be a no-op. |
michael@0 | 66 | */ |
michael@0 | 67 | void resumeNative(); |
michael@0 | 68 | |
michael@0 | 69 | /** |
michael@0 | 70 | * The current event loop nesting level. |
michael@0 | 71 | */ |
michael@0 | 72 | readonly attribute unsigned long eventloopNestingLevel; |
michael@0 | 73 | |
michael@0 | 74 | /** |
michael@0 | 75 | * Allows running of a "synchronous section", in the form of an nsIRunnable |
michael@0 | 76 | * once the event loop has reached a "stable state". We've reached a stable |
michael@0 | 77 | * state when the currently executing task/event has finished, see: |
michael@0 | 78 | * http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#synchronous-section |
michael@0 | 79 | * In practice this runs aRunnable once the currently executing event |
michael@0 | 80 | * finishes. If called multiple times per task/event, all the runnables will |
michael@0 | 81 | * be executed, in the order in which runInStableState() was called. |
michael@0 | 82 | */ |
michael@0 | 83 | void runInStableState(in nsIRunnable runnable); |
michael@0 | 84 | |
michael@0 | 85 | /** |
michael@0 | 86 | * Run the given runnable before the next iteration of the event loop (this |
michael@0 | 87 | * includes native events too). If a nested loop is spawned within the current |
michael@0 | 88 | * event then the runnable will not be run until that loop has terminated. |
michael@0 | 89 | */ |
michael@0 | 90 | void runBeforeNextEvent(in nsIRunnable runnable); |
michael@0 | 91 | }; |