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

Side by Side Diff: remoting/webapp/base/js/base.js

Issue 944183002: HostTableEntry refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedbacks with unit tests 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * A module that contains basic utility components and methods for the 7 * A module that contains basic utility components and methods for the
8 * chromoting project 8 * chromoting project
9 * 9 *
10 */ 10 */
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 * @implements {base.Disposable} 67 * @implements {base.Disposable}
68 */ 68 */
69 base.Disposables = function(var_args) { 69 base.Disposables = function(var_args) {
70 /** 70 /**
71 * @type {Array<base.Disposable>} 71 * @type {Array<base.Disposable>}
72 * @private 72 * @private
73 */ 73 */
74 this.disposables_ = Array.prototype.slice.call(arguments, 0); 74 this.disposables_ = Array.prototype.slice.call(arguments, 0);
75 }; 75 };
76 76
77 /**
78 * @param {...base.Disposable} var_args
79 */
80 base.Disposables.prototype.add = function(var_args) {
81 var disposables = Array.prototype.slice.call(arguments, 0);
82 for (var i = 0; i < disposables.length; i++) {
83 var current = /** @type {base.Disposable} */ (disposables[i]);
84 if (this.disposables_.indexOf(current) === -1) {
85 this.disposables_.push(current);
86 }
87 }
88 };
89
90 /**
91 * @param {...base.Disposable} var_args Dispose |var_args| and remove
92 * them from the current object.
93 */
94 base.Disposables.prototype.remove = function(var_args) {
95 var disposables = Array.prototype.slice.call(arguments, 0);
96 for (var i = 0; i < disposables.length; i++) {
97 var disposable = /** @type {base.Disposable} */ (disposables[i]);
98 var index = this.disposables_.indexOf(disposable);
99 if(index !== -1) {
100 this.disposables_.splice(index, 1);
101 disposable.dispose();
102 }
103 }
104 };
105
77 base.Disposables.prototype.dispose = function() { 106 base.Disposables.prototype.dispose = function() {
78 for (var i = 0; i < this.disposables_.length; i++) { 107 for (var i = 0; i < this.disposables_.length; i++) {
79 this.disposables_[i].dispose(); 108 this.disposables_[i].dispose();
80 } 109 }
81 this.disposables_ = null; 110 this.disposables_ = null;
82 }; 111 };
83 112
84 /** 113 /**
85 * A utility function to invoke |obj|.dispose without a null check on |obj|. 114 * A utility function to invoke |obj|.dispose without a null check on |obj|.
86 * @param {base.Disposable} obj 115 * @param {base.Disposable} obj
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 */ 650 */
622 base.resizeWindowToContent = function() { 651 base.resizeWindowToContent = function() {
623 var appWindow = chrome.app.window.current(); 652 var appWindow = chrome.app.window.current();
624 var outerBounds = appWindow.outerBounds; 653 var outerBounds = appWindow.outerBounds;
625 var borderY = outerBounds.height - appWindow.innerBounds.height; 654 var borderY = outerBounds.height - appWindow.innerBounds.height;
626 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); 655 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY);
627 // Sometimes, resizing the window causes its position to be reset to (0, 0), 656 // Sometimes, resizing the window causes its position to be reset to (0, 0),
628 // so restore it explicitly. 657 // so restore it explicitly.
629 appWindow.moveTo(outerBounds.left, outerBounds.top); 658 appWindow.moveTo(outerBounds.left, outerBounds.top);
630 }; 659 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698