michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: * This service allows access to the current thread's Chromium MessageLoop michael@0: * instance, with some extra sugar added. If you're calling from C++, it may michael@0: * or may not make sense for you to use this interface. If you're calling from michael@0: * JS, you don't have a choice! michael@0: * michael@0: * Right now, you can only call PostIdleTask(), but nothing is stopping you michael@0: * from adding other methods. michael@0: * michael@0: * nsIMessageLoop's contractid is "@mozilla.org/message-loop;1". michael@0: */ michael@0: [scriptable, uuid(3E8C58E8-E52C-43E0-8E66-669CA788FF5F)] michael@0: interface nsIMessageLoop : nsISupports michael@0: { michael@0: /** michael@0: * Posts a task to be run when this thread's message loop is idle, or after michael@0: * ensureRunsAfterMS milliseconds have elapsed. (That is, the task is michael@0: * guaranteed to run /eventually/.) michael@0: * michael@0: * Note that if the event loop is busy, we will hold a reference to the task michael@0: * until ensureRunsAfterMS milliseconds have elapsed. Be careful when michael@0: * specifying long timeouts and tasks which hold references to windows or michael@0: * other large objects, because you can leak memory in a difficult-to-detect michael@0: * way! michael@0: */ michael@0: void postIdleTask(in nsIRunnable task, in uint32_t ensureRunsAfterMS); michael@0: };