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

Unified Diff: chrome/browser/invalidation/ticl_invalidation_service.cc

Issue 21140004: Refresh access tokens for TiclInvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Fred's comments Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/invalidation/ticl_invalidation_service.cc
diff --git a/chrome/browser/invalidation/ticl_invalidation_service.cc b/chrome/browser/invalidation/ticl_invalidation_service.cc
index ee2da37e8c620d76aadbbbd59df21dad82b69026..cc465e69a4e24c36d4c207cb42235b696404b427 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service.cc
+++ b/chrome/browser/invalidation/ticl_invalidation_service.cc
@@ -258,7 +258,23 @@ void TiclInvalidationService::OnGetTokenFailure(
void TiclInvalidationService::OnInvalidatorStateChange(
syncer::InvalidatorState state) {
- invalidator_registrar_->UpdateInvalidatorState(state);
+ if (state == syncer::INVALIDATION_CREDENTIALS_REJECTED) {
+ // This may be due to normal OAuth access token expiration. If so, we must
+ // fetch a new one using our refresh token. Resetting the invalidator's
+ // access token will not reset the invalidator's exponential backoff, so
+ // it's safe to try to update the token every time we receive this signal.
+ //
+ // We won't be receiving any invalidations while the refresh is in progress,
+ // we set our state to TRANSIENT_INVALIDATION_ERROR. If the credentials
+ // really are invalid, the refresh request should fail and
+ // OnGetTokenFailure() will put us into a INVALIDATION_CREDENTIALS_REJECTED
+ // state.
+ invalidator_registrar_->UpdateInvalidatorState(
+ syncer::TRANSIENT_INVALIDATION_ERROR);
+ RequestAccessToken();
+ } else {
+ invalidator_registrar_->UpdateInvalidatorState(state);
+ }
}
void TiclInvalidationService::OnIncomingInvalidation(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698