2 * (C) Copyright 2008 Jeremy Maitin-Shepard
4 * Use, modification, and distribution are subject to the terms specified in the
8 function timer_callback (callback) {
9 this.callback = callback;
11 timer_callback.prototype = {
12 constructor: timer_callback,
13 QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback]),
15 notify: function (timer) {
16 this.callback.call(null, timer);
20 function call_after_timeout (callback, timeout) {
21 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
22 timer.initWithCallback(new timer_callback(callback), timeout, Ci.nsITimer.TYPE_ONE_SHOT);
26 function call_at_interval (callback, interval) {
27 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
28 timer.initWithCallback(new timer_callback(callback), interval, Ci.nsITimer.TYPE_REPEATING_SLACK);
32 function call_at_precise_interval (callback, interval) {
33 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
34 timer.initWithCallback(new timer_callback(callback), interval, Ci.nsITimer.TYPE_REPEATING_PRECISE);
38 function timer_cancel (timer) {