Index: remoting/webapp/base/js/base.js |
diff --git a/remoting/webapp/base/js/base.js b/remoting/webapp/base/js/base.js |
index 73a5b3abf20bcfda4466771e2ac7c9cd389bd477..1cf6a4fb46fc340a4de4e510b514841dd524cafe 100644 |
--- a/remoting/webapp/base/js/base.js |
+++ b/remoting/webapp/base/js/base.js |
@@ -682,6 +682,32 @@ base.RepeatingTimer.prototype.dispose = function() { |
}; |
/** |
+ * A disposable one shot timer. |
+ * |
+ * @param {Function} callback |
+ * @param {number} timeout |
+ * |
+ * @constructor |
+ * @implements {base.Disposable} |
+ */ |
+base.OneShotTimer = function(callback, timeout) { |
+ var that = this; |
+ |
+ /** @private */ |
+ this.timerId_ = window.setTimeout(function() { |
+ that.timerId_ = null; |
+ callback(); |
+ }, timeout); |
+}; |
+ |
+base.OneShotTimer.prototype.dispose = function() { |
+ if (this.timerId_ !== null) { |
+ window.clearTimeout(this.timerId_); |
+ this.timerId_ = null; |
+ } |
+}; |
+ |
+/** |
* Converts UTF-8 string to ArrayBuffer. |
* |
* @param {string} string |