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

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

Issue 848993002: Improve apps v2 upgrade UX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address outstanding feedbacks Created 5 years, 11 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/html/main.css ('k') | remoting/webapp/crd/html/ui_me2me.html » ('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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 function() { 263 function() {
264 return Promise.reject(); 264 return Promise.reject();
265 }, 265 },
266 /** @return {Promise} */ 266 /** @return {Promise} */
267 function() { 267 function() {
268 return Promise.resolve(); 268 return Promise.resolve();
269 }); 269 });
270 }; 270 };
271 271
272 /** 272 /**
273 * Converts a |method| with callbacks into a Promise.
274 *
275 * @param {Function} method
276 * @param {Array} params
277 * @param {*=} opt_context
278 * @param {boolean=} opt_hasErrorHandler whether the method has an error handler
279 * @return {Promise}
280 */
281 base.Promise.as = function(method, params, opt_context, opt_hasErrorHandler) {
282 return new Promise(function(resolve, reject) {
283 params.push(resolve);
284 if (opt_hasErrorHandler) {
285 params.push(reject);
286 }
287 try {
288 method.apply(opt_context, params);
289 } catch (/** @type {*} */ e) {
290 reject(e);
291 }
292 });
293 };
294
295 /**
273 * A mixin for classes with events. 296 * A mixin for classes with events.
274 * 297 *
275 * For example, to create an alarm event for SmokeDetector: 298 * For example, to create an alarm event for SmokeDetector:
276 * functionSmokeDetector() { 299 * functionSmokeDetector() {
277 * this.defineEvents(['alarm']); 300 * this.defineEvents(['alarm']);
278 * }; 301 * };
279 * base.extend(SmokeDetector, base.EventSource); 302 * base.extend(SmokeDetector, base.EventSource);
280 * 303 *
281 * To fire an event: 304 * To fire an event:
282 * SmokeDetector.prototype.onCarbonMonoxideDetected = function() { 305 * SmokeDetector.prototype.onCarbonMonoxideDetected = function() {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 * @return {Object|undefined} The decoded object, or undefined if the string 461 * @return {Object|undefined} The decoded object, or undefined if the string
439 * cannot be parsed. 462 * cannot be parsed.
440 */ 463 */
441 base.jsonParseSafe = function(jsonString) { 464 base.jsonParseSafe = function(jsonString) {
442 try { 465 try {
443 return /** @type {Object} */ (JSON.parse(jsonString)); 466 return /** @type {Object} */ (JSON.parse(jsonString));
444 } catch (err) { 467 } catch (err) {
445 return undefined; 468 return undefined;
446 } 469 }
447 } 470 }
OLDNEW
« no previous file with comments | « remoting/webapp/base/html/main.css ('k') | remoting/webapp/crd/html/ui_me2me.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698