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 QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback]),
14 notify: function (timer) {
15 this.callback.call(null, timer);
19 function call_after_timeout (callback, timeout) {
20 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
21 timer.initWithCallback(new timer_callback(callback), timeout, Ci.nsITimer.TYPE_ONE_SHOT);
25 function call_at_interval (callback, interval) {
26 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
27 timer.initWithCallback(new timer_callback(callback), interval, Ci.nsITimer.TYPE_REPEATING_SLACK);
31 function call_at_precise_interval (callback, interval) {
32 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
33 timer.initWithCallback(new timer_callback(callback), interval, Ci.nsITimer.TYPE_REPEATING_PRECISE);
37 function timer_cancel (timer) {