2 function timer_callback(callback) {
3 this.callback = callback;
5 timer_callback.prototype = {
6 QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback]),
8 notify : function(timer) {
9 this.callback.call(null, timer);
12 function call_after_timeout(callback, timeout) {
13 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
14 timer.initWithCallback(new timer_callback(callback), timeout, Ci.nsITimer.TYPE_ONE_SHOT);
18 function call_at_interval(callback, interval) {
19 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
20 timer.initWithCallback(new timer_callback(callback), timeout, Ci.nsITimer.TYPE_REPEATING_SLACK);
24 function call_at_precise_interval(callback, interval) {
25 var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
26 timer.initWithCallback(new timer_callback(callback), timeout, Ci.nsITimer.TYPE_REPEATING_PRECISE);