michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIRunnable; michael@0: michael@0: /** michael@0: * Interface for the native event system layer. This interface is designed michael@0: * to be used on the main application thread only. michael@0: */ michael@0: [uuid(2d10ca53-f143-439a-bb2e-c1fbc71f6a05)] michael@0: interface nsIAppShell : nsISupports michael@0: { michael@0: /** michael@0: * Enter an event loop. Don't leave until exit() is called. michael@0: */ michael@0: void run(); michael@0: michael@0: /** michael@0: * Exit the handle event loop michael@0: */ michael@0: void exit(); michael@0: michael@0: /** michael@0: * Give hint to native event queue notification mechanism. If the native michael@0: * platform needs to tradeoff performance vs. native event starvation this michael@0: * hint tells the native dispatch code which to favor. The default is to michael@0: * prevent native event starvation. michael@0: * michael@0: * Calls to this function may be nested. When the number of calls that pass michael@0: * PR_TRUE is subtracted from the number of calls that pass PR_FALSE is michael@0: * greater than 0, performance is given precedence over preventing event michael@0: * starvation. michael@0: * michael@0: * The starvationDelay arg is only used when favorPerfOverStarvation is michael@0: * PR_FALSE. It is the amount of time in milliseconds to wait before the michael@0: * PR_FALSE actually takes effect. michael@0: */ michael@0: void favorPerformanceHint(in boolean favorPerfOverStarvation, michael@0: in unsigned long starvationDelay); michael@0: michael@0: /** michael@0: * Suspends the use of additional platform-specific methods (besides the michael@0: * nsIAppShell->run() event loop) to run Gecko events on the main michael@0: * application thread. Under some circumstances these "additional methods" michael@0: * can cause Gecko event handlers to be re-entered, sometimes leading to michael@0: * hangs and crashes. Calls to suspendNative() and resumeNative() may be michael@0: * nested. On some platforms (those that don't use any "additional michael@0: * methods") this will be a no-op. Does not (in itself) stop Gecko events michael@0: * from being processed on the main application thread. But if the michael@0: * nsIAppShell->run() event loop is blocked when this call is made, Gecko michael@0: * events will stop being processed until resumeNative() is called (even michael@0: * if a plugin or library is temporarily processing events on a nested michael@0: * event loop). michael@0: */ michael@0: void suspendNative(); michael@0: michael@0: /** michael@0: * Resumes the use of additional platform-specific methods to run Gecko michael@0: * events on the main application thread. Calls to suspendNative() and michael@0: * resumeNative() may be nested. On some platforms this will be a no-op. michael@0: */ michael@0: void resumeNative(); michael@0: michael@0: /** michael@0: * The current event loop nesting level. michael@0: */ michael@0: readonly attribute unsigned long eventloopNestingLevel; michael@0: michael@0: /** michael@0: * Allows running of a "synchronous section", in the form of an nsIRunnable michael@0: * once the event loop has reached a "stable state". We've reached a stable michael@0: * state when the currently executing task/event has finished, see: michael@0: * http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#synchronous-section michael@0: * In practice this runs aRunnable once the currently executing event michael@0: * finishes. If called multiple times per task/event, all the runnables will michael@0: * be executed, in the order in which runInStableState() was called. michael@0: */ michael@0: void runInStableState(in nsIRunnable runnable); michael@0: michael@0: /** michael@0: * Run the given runnable before the next iteration of the event loop (this michael@0: * includes native events too). If a nested loop is spawned within the current michael@0: * event then the runnable will not be run until that loop has terminated. michael@0: */ michael@0: void runBeforeNextEvent(in nsIRunnable runnable); michael@0: };