|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 interface nsIRunnable; |
|
9 |
|
10 /** |
|
11 * This service allows access to the current thread's Chromium MessageLoop |
|
12 * instance, with some extra sugar added. If you're calling from C++, it may |
|
13 * or may not make sense for you to use this interface. If you're calling from |
|
14 * JS, you don't have a choice! |
|
15 * |
|
16 * Right now, you can only call PostIdleTask(), but nothing is stopping you |
|
17 * from adding other methods. |
|
18 * |
|
19 * nsIMessageLoop's contractid is "@mozilla.org/message-loop;1". |
|
20 */ |
|
21 [scriptable, uuid(3E8C58E8-E52C-43E0-8E66-669CA788FF5F)] |
|
22 interface nsIMessageLoop : nsISupports |
|
23 { |
|
24 /** |
|
25 * Posts a task to be run when this thread's message loop is idle, or after |
|
26 * ensureRunsAfterMS milliseconds have elapsed. (That is, the task is |
|
27 * guaranteed to run /eventually/.) |
|
28 * |
|
29 * Note that if the event loop is busy, we will hold a reference to the task |
|
30 * until ensureRunsAfterMS milliseconds have elapsed. Be careful when |
|
31 * specifying long timeouts and tasks which hold references to windows or |
|
32 * other large objects, because you can leak memory in a difficult-to-detect |
|
33 * way! |
|
34 */ |
|
35 void postIdleTask(in nsIRunnable task, in uint32_t ensureRunsAfterMS); |
|
36 }; |