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);
18 function call_after_timeout(callback, timeout) {
19 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
20 timer.initWithCallback(new timer_callback(callback), timeout, Ci.nsITimer.TYPE_ONE_SHOT);
24 function call_at_interval(callback, interval) {
25 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
26 timer.initWithCallback(new timer_callback(callback), interval, Ci.nsITimer.TYPE_REPEATING_SLACK);
30 function call_at_precise_interval(callback, interval) {
31 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
32 timer.initWithCallback(new timer_callback(callback), interval, Ci.nsITimer.TYPE_REPEATING_PRECISE);