Bug 573443 - Remove Util.Timeout in Util.js [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2010-06-21 22:04:59 +02:00
parent bd7acd124a
commit 3e3caa9c00

View File

@ -210,70 +210,6 @@ let Util = {
};
/**
* Helper class to nsITimer that adds a little more pizazz. Callback can be an
* object with a notify method or a function.
*/
Util.Timeout = function(aCallback) {
this._callback = aCallback;
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this._active = false;
}
Util.Timeout.prototype = {
/** Timer callback. Don't call this manually. */
notify: function notify() {
this._active = false;
if (this._callback.notify)
this._callback.notify();
else
this._callback.apply(null);
},
/** Do the callback once. Cancels other timeouts on this object. */
once: function once(aDelay, aCallback) {
if (aCallback)
this._callback = aCallback;
this.clear();
this._timer.initWithCallback(this, aDelay, this._timer.TYPE_ONE_SHOT);
this._active = true;
return this;
},
/** Do the callback every aDelay msecs. Cancels other timeouts on this object. */
interval: function interval(aDelay, aCallback) {
if (aCallback)
this._callback = aCallback;
this.clear();
this._timer.initWithCallback(this, aDelay, this._timer.TYPE_REPEATING_SLACK);
this._active = true;
return this;
},
/** Clear any pending timeouts. */
clear: function clear() {
if (this._active) {
this._timer.cancel();
this._active = false;
}
return this;
},
/** If there is a pending timeout, call it and cancel the timeout. */
flush: function flush() {
if (this._active) {
this.clear();
this.notify();
}
return this;
},
/** Return true iff we are waiting for a callback. */
isPending: function isPending() {
return this._active;
}
};
/**
* Cache of commonly used elements.
*/
@ -297,6 +233,7 @@ let Elements = {};
});
});
/**
* Simple Point class.
*