Fixed attemptTreeCall not checking deep-abort status correctly (bug 520492, r=gal).
[mozilla-central.git] / xpcom / threads / nsITimer.idl
blobbcea228515592c555dd4b37919b2207439e1012e
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
15 * License.
17 * The Original Code is mozilla.org code.
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 2002
22 * the Initial Developer. All Rights Reserved.
24 * Contributor(s):
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #include "nsISupports.idl"
42 interface nsIObserver;
43 interface nsIEventTarget;
45 %{C++
46 /**
47 * The signature of the timer callback function passed to initWithFuncCallback.
48 * This is the function that will get called when the timer expires if the
49 * timer is initialized via initWithFuncCallback.
51 * @param aTimer the timer which has expired
52 * @param aClosure opaque parameter passed to initWithFuncCallback
54 * Implementers should return the following:
56 * @return NS_OK
59 class nsITimer;
60 typedef void (*nsTimerCallbackFunc) (nsITimer *aTimer, void *aClosure);
63 native nsTimerCallbackFunc(nsTimerCallbackFunc);
65 /**
66 * The callback interface for timers.
68 interface nsITimer;
70 [function, scriptable, uuid(a796816d-7d47-4348-9ab8-c7aeb3216a7d)]
71 interface nsITimerCallback : nsISupports
73 /**
74 * @param aTimer the timer which has expired
76 void notify(in nsITimer timer);
80 /**
81 * nsITimer instances must be initialized by calling one of the "init" methods
82 * documented below. You may also re-initialize (using one of the init()
83 * methods) an existing instance to avoid the overhead of destroying and
84 * creating a timer. It is not necessary to cancel the timer in that case.
86 [scriptable, uuid(193fc37a-8aa4-4d29-aa57-1acd87c26b66)]
87 interface nsITimer : nsISupports
89 /* Timer types */
91 /**
92 * Type of a timer that fires once only.
94 const short TYPE_ONE_SHOT = 0;
96 /**
97 * After firing, a TYPE_REPEATING_SLACK timer is stopped and not restarted
98 * until its callback completes. Specified timer period will be at least
99 * the time between when processing for last firing the callback completes
100 * and when the next firing occurs.
102 * This is the preferable repeating type for most situations.
104 const short TYPE_REPEATING_SLACK = 1;
107 * An TYPE_REPEATING_PRECISE repeating timer aims to have constant period
108 * between firings. The processing time for each timer callback should not
109 * influence the timer period. However, if the processing for the last
110 * timer firing could not be completed until just before the next firing
111 * occurs, then you could have two timer notification routines being
112 * executed in quick succession.
114 const short TYPE_REPEATING_PRECISE = 2;
117 * Initialize a timer that will fire after the said delay.
118 * A user must keep a reference to this timer till it is
119 * is no longer needed or has been cancelled.
121 * @param aObserver the callback object that observes the
122 * ``timer-callback'' topic with the subject being
123 * the timer itself when the timer fires:
125 * observe(nsISupports aSubject, => nsITimer
126 * string aTopic, => ``timer-callback''
127 * wstring data => null
129 * @param aDelay delay in milliseconds for timer to fire
130 * @param aType timer type per TYPE* consts defined above
132 void init(in nsIObserver aObserver, in unsigned long aDelay,
133 in unsigned long aType);
137 * Initialize a timer to fire after the given millisecond interval.
138 * This version takes a function to call and a closure to pass to
139 * that function.
141 * @param aFunc The function to invoke
142 * @param aClosure An opaque pointer to pass to that function
143 * @param aDelay The millisecond interval
144 * @param aType Timer type per TYPE* consts defined above
146 [noscript] void initWithFuncCallback(in nsTimerCallbackFunc aCallback,
147 in voidPtr aClosure,
148 in unsigned long aDelay,
149 in unsigned long aType);
152 * Initialize a timer to fire after the given millisecond interval.
153 * This version takes a function to call and a closure to pass to
154 * that function.
156 * @param aFunc nsITimerCallback interface to call when timer expires
157 * @param aDelay The millisecond interval
158 * @param aType Timer type per TYPE* consts defined above
160 void initWithCallback(in nsITimerCallback aCallback,
161 in unsigned long aDelay,
162 in unsigned long aType);
165 * Cancel the timer. This method works on all types, not just on repeating
166 * timers -- you might want to cancel a TYPE_ONE_SHOT timer, and even reuse
167 * it by re-initializing it (to avoid object destruction and creation costs
168 * by conserving one timer instance).
170 void cancel();
173 * The millisecond delay of the timeout.
175 * NOTE: Re-setting the delay on a one-shot timer that has already fired
176 * doesn't restart the timer. Call one of the init() methods to restart
177 * a one-shot timer.
179 attribute unsigned long delay;
182 * The timer type - one of the above TYPE_* constants.
184 attribute unsigned long type;
187 * The opaque pointer pass to initWithFuncCallback.
189 [noscript] readonly attribute voidPtr closure;
192 * The nsITimerCallback object passed to initWithCallback.
194 readonly attribute nsITimerCallback callback;
197 * The nsIEventTarget where the callback will be dispatched. Note that this
198 * target may only be set before the call to one of the init methods above.
200 attribute nsIEventTarget target;
203 %{C++
204 #define NS_TIMER_CONTRACTID "@mozilla.org/timer;1"
205 #define NS_TIMER_CALLBACK_TOPIC "timer-callback"