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

Side by Side Diff: chrome/browser/resources/google_now/utility.js

Issue 158003003: Convert Google Now's State Change Gathering Mechanism to use Promises (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change from .apply to .call Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/google_now/common_test_util.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @fileoverview Utility objects and functions for Google Now extension. 8 * @fileoverview Utility objects and functions for Google Now extension.
9 * Most important entities here: 9 * Most important entities here:
10 * (1) 'wrapper' is a module used to add error handling and other services to 10 * (1) 'wrapper' is a module used to add error handling and other services to
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 })(); 430 })();
431 431
432 wrapper.instrumentChromeApiFunction('alarms.get', 1); 432 wrapper.instrumentChromeApiFunction('alarms.get', 1);
433 wrapper.instrumentChromeApiFunction('alarms.onAlarm.addListener', 0); 433 wrapper.instrumentChromeApiFunction('alarms.onAlarm.addListener', 0);
434 wrapper.instrumentChromeApiFunction('identity.getAuthToken', 1); 434 wrapper.instrumentChromeApiFunction('identity.getAuthToken', 1);
435 wrapper.instrumentChromeApiFunction('identity.onSignInChanged.addListener', 0); 435 wrapper.instrumentChromeApiFunction('identity.onSignInChanged.addListener', 0);
436 wrapper.instrumentChromeApiFunction('identity.removeCachedAuthToken', 1); 436 wrapper.instrumentChromeApiFunction('identity.removeCachedAuthToken', 1);
437 wrapper.instrumentChromeApiFunction('webstorePrivate.getBrowserLogin', 0); 437 wrapper.instrumentChromeApiFunction('webstorePrivate.getBrowserLogin', 0);
438 438
439 /** 439 /**
440 * Add task tracking support to Promises.
441 * @override
442 */
443 Promise.prototype.then = function() {
444 var originalThen = Promise.prototype.then;
445 return function(callback) {
446 originalThen.call(this, wrapper.wrapCallback(callback, false));
447 }
448 }();
449
450 /**
440 * Builds the object to manage tasks (mutually exclusive chains of events). 451 * Builds the object to manage tasks (mutually exclusive chains of events).
441 * @param {function(string, string): boolean} areConflicting Function that 452 * @param {function(string, string): boolean} areConflicting Function that
442 * checks if a new task can't be added to a task queue that contains an 453 * checks if a new task can't be added to a task queue that contains an
443 * existing task. 454 * existing task.
444 * @return {Object} Task manager interface. 455 * @return {Object} Task manager interface.
445 */ 456 */
446 function buildTaskManager(areConflicting) { 457 function buildTaskManager(areConflicting) {
447 /** 458 /**
448 * Queue of scheduled tasks. The first element, if present, corresponds to the 459 * Queue of scheduled tasks. The first element, if present, corresponds to the
449 * currently running task. 460 * currently running task.
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 // One hour is just an arbitrary amount of time chosen. 802 // One hour is just an arbitrary amount of time chosen.
792 chrome.alarms.create(alarmName, {periodInMinutes: 60}); 803 chrome.alarms.create(alarmName, {periodInMinutes: 60});
793 804
794 return { 805 return {
795 addListener: addListener, 806 addListener: addListener,
796 getAuthToken: getAuthToken, 807 getAuthToken: getAuthToken,
797 isSignedIn: isSignedIn, 808 isSignedIn: isSignedIn,
798 removeToken: removeToken 809 removeToken: removeToken
799 }; 810 };
800 } 811 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/google_now/common_test_util.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698