|
1 /* -*- Mode: IDL; 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 nsITimerCallback; |
|
9 |
|
10 /** |
|
11 * An interface describing a global application service that allows long |
|
12 * duration (e.g. 1-7 or more days, weeks or months) timers to be registered |
|
13 * and then fired. |
|
14 */ |
|
15 [scriptable, uuid(0765c92c-6145-4253-9db4-594d8023087e)] |
|
16 interface nsIUpdateTimerManager : nsISupports |
|
17 { |
|
18 /** |
|
19 * Register an interval with the timer manager. The timer manager |
|
20 * periodically checks to see if the interval has expired and if it has |
|
21 * calls the specified callback. This is persistent across application |
|
22 * restarts and can handle intervals of long durations. |
|
23 * @param id |
|
24 * An id that identifies the interval, used for persistence |
|
25 * @param callback |
|
26 * A nsITimerCallback object that is notified when the interval |
|
27 * expires |
|
28 * @param interval |
|
29 * The length of time, in seconds, of the interval |
|
30 * |
|
31 * Note: to avoid having to instantiate a component to call registerTimer |
|
32 * the component can intead register an update-timer category with comma |
|
33 * separated values as a single string representing the timer as follows. |
|
34 * |
|
35 * _xpcom_categories: [{ category: "update-timer", |
|
36 * value: "contractID," + |
|
37 * "method," + |
|
38 * "id," + |
|
39 * "preference," + |
|
40 * "interval" }], |
|
41 * the values are as follows |
|
42 * contractID : the contract ID for the component. |
|
43 * method : the method used to instantiate the interface. This should be |
|
44 * either getService or createInstance depending on your |
|
45 * component. |
|
46 * id : the id that identifies the interval, used for persistence. |
|
47 * preference : the preference to for timer interval. This value can be |
|
48 * optional by specifying an empty string for the value. |
|
49 * interval : the default interval in seconds for the timer. |
|
50 */ |
|
51 void registerTimer(in AString id, |
|
52 in nsITimerCallback callback, |
|
53 in unsigned long interval); |
|
54 }; |