VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/threads/nsITimer.idl@ 6542

Last change on this file since 6542 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 KB
Line 
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
3 *
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 *
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/
11 *
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.
16 *
17 * The Original Code is mozilla.org code.
18 *
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.
23 *
24 * Contributor(s):
25 *
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.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40#include "nsISupports.idl"
41
42interface nsIObserver;
43
44%{C++
45/**
46 * The signature of the timer callback function passed to initWithCallback. This
47 * is the function that will get called when the timer expires if the timer is
48 * initialized via initWithCallback.
49 *
50 * @param aTimer the timer which has expired
51 * @param aClosure opaque parameter passed to initWithCallback
52 *
53 * Implementers should return the following:
54 *
55 * @return NS_OK
56 *
57 */
58class nsITimer;
59typedef void (*nsTimerCallbackFunc) (nsITimer *aTimer, void *aClosure);
60%}
61
62native nsTimerCallbackFunc(nsTimerCallbackFunc);
63
64/**
65 * The callback interface for timers.
66 */
67interface nsITimer;
68
69[scriptable, uuid(a796816d-7d47-4348-9ab8-c7aeb3216a7d)]
70interface nsITimerCallback : nsISupports
71{
72 /**
73 * @param aTimer the timer which has expired
74 */
75 void notify(in nsITimer timer);
76};
77
78
79/**
80 * nsITimer instances must be initialized by calling one of the "init" methods
81 * documented below. You may also re-initialize an existing instance with new
82 * delay to avoid the overhead of destroying and creating a timer. It is not
83 * necessary to cancel the timer in that case.
84 */
85[scriptable, uuid(29ee628e-a3ea-471f-965d-dc9f11d1c183)]
86interface nsITimer : nsISupports
87{
88 /* Timer types */
89
90 /**
91 * Type of a timer that fires once only.
92 */
93 const short TYPE_ONE_SHOT = 0;
94
95 /**
96 * After firing, a TYPE_REPEATING_SLACK timer is stopped and not restarted
97 * until its callback completes. Specified timer period will be at least
98 * the time between when processing for last firing the callback completes
99 * and when the next firing occurs.
100 *
101 * This is the preferable repeating type for most situations.
102 */
103 const short TYPE_REPEATING_SLACK = 1;
104
105 /**
106 * An TYPE_REPEATING_PRECISE repeating timer aims to have constant period
107 * between firings. The processing time for each timer callback should not
108 * influence the timer period. However, if the processing for the last
109 * timer firing could not be completed until just before the next firing
110 * occurs, then you could have two timer notification routines being
111 * executed in quick succession.
112 */
113 const short TYPE_REPEATING_PRECISE = 2;
114
115 /**
116 * Initialize a timer that will fire after the said delay.
117 * A user must keep a reference to this timer till it is
118 * is no longer needed or has been cancelled.
119 *
120 * @param aObserver the callback object that observes the
121 * ``timer-callback'' topic with the subject being
122 * the timer itself when the timer fires:
123 *
124 * observe(nsISupports aSubject, => nsITimer
125 * string aTopic, => ``timer-callback''
126 * wstring data => null
127 *
128 * @param aDelay delay in milliseconds for timer to fire
129 * @param aType timer type per TYPE* consts defined above
130 */
131 void init(in nsIObserver aObserver, in unsigned long aDelay,
132 in unsigned long aType);
133
134
135 /**
136 * Initialize a timer to fire after the given millisecond interval.
137 * This version takes a function to call and a closure to pass to
138 * that function.
139 *
140 * @param aFunc The function to invoke
141 * @param aClosure An opaque pointer to pass to that function
142 * @param aDelay The millisecond interval
143 * @param aType Timer type per TYPE* consts defined above
144 */
145 [noscript] void initWithFuncCallback(in nsTimerCallbackFunc aCallback,
146 in voidPtr aClosure,
147 in unsigned long aDelay,
148 in unsigned long aType);
149
150 /**
151 * Initialize a timer to fire after the given millisecond interval.
152 * This version takes a function to call and a closure to pass to
153 * that function.
154 *
155 * @param aFunc nsITimerCallback interface to call when timer expires
156 * @param aDelay The millisecond interval
157 * @param aType Timer type per TYPE* consts defined above
158 */
159 void initWithCallback(in nsITimerCallback aCallback,
160 in unsigned long aDelay,
161 in unsigned long aType);
162
163 /**
164 * Cancel the timer. This method works on all types, not just on repeating
165 * timers -- you might want to cancel a TYPE_ONE_SHOT timer, and even reuse
166 * it by re-initializing it (to avoid object destruction and creation costs
167 * by conserving one timer instance).
168 */
169 void cancel();
170
171 /**
172 * The millisecond delay of the timeout
173 */
174 attribute unsigned long delay;
175
176 /**
177 * The timer type : one shot or repeating
178 */
179 attribute unsigned long type;
180
181 /**
182 * The opaque pointer pass to initWithCallback.
183 */
184 [noscript] readonly attribute voidPtr closure;
185};
186
187%{C++
188#define NS_TIMER_CONTRACTID "@mozilla.org/timer;1"
189#define NS_TIMER_CALLBACK_TOPIC "timer-callback"
190%}
191
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette