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

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

Issue 937593002: Changed identity API to use promises instead of callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed bad merge 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
« no previous file with comments | « remoting/webapp/base/js/auth_init.js ('k') | remoting/webapp/crd/js/apps_v2_migration.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 * Sample Usage: 230 * Sample Usage:
231 * function myAsyncAPI() { 231 * function myAsyncAPI() {
232 * var deferred = new base.Deferred(); 232 * var deferred = new base.Deferred();
233 * window.setTimeout(function() { 233 * window.setTimeout(function() {
234 * deferred.resolve(); 234 * deferred.resolve();
235 * }, 100); 235 * }, 100);
236 * return deferred.promise(); 236 * return deferred.promise();
237 * }; 237 * };
238 * 238 *
239 * @constructor 239 * @constructor
240 * @template T
240 */ 241 */
241 base.Deferred = function() { 242 base.Deferred = function() {
242 /** 243 /**
243 * @type {?function(?):void} 244 * @private {?function(?):void}
244 * @private
245 */ 245 */
246 this.resolve_ = null; 246 this.resolve_ = null;
247 247
248 /** 248 /**
249 * @type {?function(?):void} 249 * @private {?function(?):void}
250 * @private
251 */ 250 */
252 this.reject_ = null; 251 this.reject_ = null;
253 252
254 /** 253 /**
255 * @this {base.Deferred} 254 * @this {base.Deferred}
256 * @param {function(?):void} resolve 255 * @param {function(?):void} resolve
257 * @param {function(*):void} reject 256 * @param {function(*):void} reject
258 */ 257 */
259 var initPromise = function(resolve, reject) { 258 var initPromise = function(resolve, reject) {
260 this.resolve_ = resolve; 259 this.resolve_ = resolve;
261 this.reject_ = reject; 260 this.reject_ = reject;
262 }; 261 };
263 262
264 /** 263 /**
265 * @type {Promise} 264 * @private {!Promise<T>}
266 * @private
267 */ 265 */
268 this.promise_ = new Promise(initPromise.bind(this)); 266 this.promise_ = new Promise(initPromise.bind(this));
269 }; 267 };
270 268
271 /** @param {*} reason */ 269 /** @param {*} reason */
272 base.Deferred.prototype.reject = function(reason) { 270 base.Deferred.prototype.reject = function(reason) {
273 this.reject_(reason); 271 this.reject_(reason);
274 }; 272 };
275 273
276 /** @param {*=} opt_value */ 274 /** @param {*=} opt_value */
277 base.Deferred.prototype.resolve = function(opt_value) { 275 base.Deferred.prototype.resolve = function(opt_value) {
278 this.resolve_(opt_value); 276 this.resolve_(opt_value);
279 }; 277 };
280 278
281 /** @return {Promise} */ 279 /** @return {!Promise<T>} */
282 base.Deferred.prototype.promise = function() { 280 base.Deferred.prototype.promise = function() {
283 return this.promise_; 281 return this.promise_;
284 }; 282 };
285 283
286 base.Promise = function() {}; 284 base.Promise = function() {};
287 285
288 /** 286 /**
289 * @param {number} delay 287 * @param {number} delay
290 * @return {Promise} a Promise that will be fulfilled after |delay| ms. 288 * @return {Promise} a Promise that will be fulfilled after |delay| ms.
291 */ 289 */
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 */ 619 */
622 base.resizeWindowToContent = function() { 620 base.resizeWindowToContent = function() {
623 var appWindow = chrome.app.window.current(); 621 var appWindow = chrome.app.window.current();
624 var outerBounds = appWindow.outerBounds; 622 var outerBounds = appWindow.outerBounds;
625 var borderY = outerBounds.height - appWindow.innerBounds.height; 623 var borderY = outerBounds.height - appWindow.innerBounds.height;
626 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); 624 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY);
627 // Sometimes, resizing the window causes its position to be reset to (0, 0), 625 // Sometimes, resizing the window causes its position to be reset to (0, 0),
628 // so restore it explicitly. 626 // so restore it explicitly.
629 appWindow.moveTo(outerBounds.left, outerBounds.top); 627 appWindow.moveTo(outerBounds.left, outerBounds.top);
630 }; 628 };
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/auth_init.js ('k') | remoting/webapp/crd/js/apps_v2_migration.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698