Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: remoting/webapp/base/js/base.js

Issue 944183002: HostTableEntry refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Jamie's feedback Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/base/html/main.css ('k') | remoting/webapp/browser_test/browser_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/base.js
diff --git a/remoting/webapp/base/js/base.js b/remoting/webapp/base/js/base.js
index bbf29107929d9b84ee44317782f146d5f664d76b..6f4ae0528190051856439efe1b60cbbf1a9dfcd8 100644
--- a/remoting/webapp/base/js/base.js
+++ b/remoting/webapp/base/js/base.js
@@ -74,6 +74,35 @@ base.Disposables = function(var_args) {
this.disposables_ = Array.prototype.slice.call(arguments, 0);
};
+/**
+ * @param {...base.Disposable} var_args
+ */
+base.Disposables.prototype.add = function(var_args) {
+ var disposables = Array.prototype.slice.call(arguments, 0);
+ for (var i = 0; i < disposables.length; i++) {
+ var current = /** @type {base.Disposable} */ (disposables[i]);
+ if (this.disposables_.indexOf(current) === -1) {
+ this.disposables_.push(current);
+ }
+ }
+};
+
+/**
+ * @param {...base.Disposable} var_args Dispose |var_args| and remove
+ * them from the current object.
+ */
+base.Disposables.prototype.remove = function(var_args) {
+ var disposables = Array.prototype.slice.call(arguments, 0);
+ for (var i = 0; i < disposables.length; i++) {
+ var disposable = /** @type {base.Disposable} */ (disposables[i]);
+ var index = this.disposables_.indexOf(disposable);
+ if(index !== -1) {
+ this.disposables_.splice(index, 1);
+ disposable.dispose();
+ }
+ }
+};
+
base.Disposables.prototype.dispose = function() {
for (var i = 0; i < this.disposables_.length; i++) {
this.disposables_[i].dispose();
« no previous file with comments | « remoting/webapp/base/html/main.css ('k') | remoting/webapp/browser_test/browser_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698