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

Issue 170283015: Revert of Convert Google Now's Authentication Manager to use Promises (Closed)

Created:
6 years, 10 months ago by robliao
Modified:
6 years, 10 months ago
Reviewers:
vadimt, rgustafson, skare_
CC:
chromium-reviews, arv+watch_chromium.org
Visibility:
Public.

Description

Revert of Convert Google Now's Authentication Manager to use Promises (https://codereview.chromium.org/162273002/) Reason for revert: Promise.catch may not always be called back, breaking an assumption about the task tracking system. Original issue's description: > Convert Google Now's Authentication Manager to use Promises > > BUG=164227 > R=rgustafson@chromium.org, skare@chromium.org, vadimt@chromium.org > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=252109 TBR=skare@chromium.org,rgustafson@chromium.org,vadimt@chromium.org NOTREECHECKS=true NOTRY=true BUG=164227

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -82 lines) Patch
M chrome/browser/resources/google_now/background.js View 5 chunks +20 lines, -5 lines 0 comments Download
M chrome/browser/resources/google_now/background_unittest.gtestjs View 4 chunks +14 lines, -12 lines 0 comments Download
M chrome/browser/resources/google_now/common_test_util.js View 1 chunk +3 lines, -22 lines 0 comments Download
M chrome/browser/resources/google_now/utility.js View 3 chunks +22 lines, -43 lines 0 comments Download

Messages

Total messages: 10 (0 generated)
robliao
Created Revert of Convert Google Now's Authentication Manager to use Promises
6 years, 10 months ago (2014-02-19 23:17:56 UTC) #1
robliao
On 2014/02/19 23:17:56, robliao wrote: > Created Revert of Convert Google Now's Authentication Manager to ...
6 years, 10 months ago (2014-02-19 23:21:57 UTC) #2
vadimt
> Promise.catch may not always be called back... Is this a feature or a bug?
6 years, 10 months ago (2014-02-19 23:23:32 UTC) #3
robliao
On 2014/02/19 23:23:32, vadimt wrote: > > Promise.catch may not always be called back... > ...
6 years, 10 months ago (2014-02-19 23:28:23 UTC) #4
robliao
The CQ bit was unchecked by robliao@chromium.org
6 years, 10 months ago (2014-02-19 23:58:52 UTC) #5
robliao
The CQ bit was checked by robliao@chromium.org
6 years, 10 months ago (2014-02-19 23:58:57 UTC) #6
robliao
The CQ bit was unchecked by robliao@chromium.org
6 years, 10 months ago (2014-02-20 00:25:11 UTC) #7
robliao
Superceded by https://codereview.chromium.org/171713007/
6 years, 10 months ago (2014-02-20 00:25:27 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/robliao@chromium.org/170283015/1
6 years, 10 months ago (2014-02-20 01:20:46 UTC) #9
commit-bot: I haz the power
6 years, 10 months ago (2014-02-20 01:20:51 UTC) #10
Message was sent while issue was closed.
Failed to apply patch for chrome/browser/resources/google_now/background.js:
While running patch -p1 --forward --force --no-backup-if-mismatch;
  patching file chrome/browser/resources/google_now/background.js
  Hunk #1 FAILED at 265.
  Hunk #2 FAILED at 273.
  Hunk #3 FAILED at 282.
  Hunk #4 FAILED at 1085.
  Hunk #5 succeeded at 1096 (offset 3 lines).
  4 out of 5 hunks FAILED -- saving rejects to file
chrome/browser/resources/google_now/background.js.rej

Patch:       chrome/browser/resources/google_now/background.js
Index: chrome/browser/resources/google_now/background.js
diff --git a/chrome/browser/resources/google_now/background.js
b/chrome/browser/resources/google_now/background.js
index
9f7d55e1f02e481997ebc46b2b4e5573c5aa5b3d..fc487cf10cf2ff0f18fc88031dc66cefdd52639f
100644
--- a/chrome/browser/resources/google_now/background.js
+++ b/chrome/browser/resources/google_now/background.js
@@ -265,7 +265,12 @@
  *     parameter.
  */
 function setAuthorization(request, callbackBoolean) {
-  authenticationManager.getAuthToken().then(function(token) {
+  authenticationManager.getAuthToken(function(token) {
+    if (!token) {
+      callbackBoolean(false);
+      return;
+    }
+
     request.setRequestHeader('Authorization', 'Bearer ' + token);
 
     // Instrument onloadend to remove stale auth tokens.
@@ -273,7 +278,7 @@
     request.onloadend = wrapper.wrapCallback(function(event) {
       if (request.status == HTTP_FORBIDDEN ||
           request.status == HTTP_UNAUTHORIZED) {
-        authenticationManager.removeToken(token).then(function() {
+        authenticationManager.removeToken(token, function() {
           originalOnLoadEnd(event);
         });
       } else {
@@ -282,8 +287,6 @@
     });
 
     callbackBoolean(true);
-  }).catch(function() {
-    callbackBoolean(false);
   });
 }
 
@@ -1085,7 +1088,7 @@
 function onStateChange() {
   tasks.add(STATE_CHANGED_TASK_NAME, function() {
     Promise.all([
-        authenticationManager.isSignedIn(),
+        isSignedIn(),
         isGeolocationEnabled(),
         canEnableBackground(),
         isNotificationsEnabled(),
@@ -1093,6 +1096,18 @@
         .then(function(results) {
           updateRunningState.apply(null, results);
         });
+  });
+}
+
+/**
+ * Determines if the user is signed in.
+ * @return {Promise} A promise to evaluate the signed in state.
+ */
+function isSignedIn() {
+  return new Promise(function(resolve) {
+    authenticationManager.isSignedIn(function(signedIn) {
+      resolve(signedIn);
+    });
   });
 }

Powered by Google App Engine
This is Rietveld 408576698