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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 472403002: Prevent invalidating refresh token on transient errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix integration tests Created 6 years, 4 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 | « no previous file | chrome/browser/sync/test/integration/sync_auth_test.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 754
755 void ProfileSyncService::OnGetTokenFailure( 755 void ProfileSyncService::OnGetTokenFailure(
756 const OAuth2TokenService::Request* request, 756 const OAuth2TokenService::Request* request,
757 const GoogleServiceAuthError& error) { 757 const GoogleServiceAuthError& error) {
758 DCHECK_EQ(access_token_request_, request); 758 DCHECK_EQ(access_token_request_, request);
759 DCHECK_NE(error.state(), GoogleServiceAuthError::NONE); 759 DCHECK_NE(error.state(), GoogleServiceAuthError::NONE);
760 access_token_request_.reset(); 760 access_token_request_.reset();
761 last_get_token_error_ = error; 761 last_get_token_error_ = error;
762 switch (error.state()) { 762 switch (error.state()) {
763 case GoogleServiceAuthError::CONNECTION_FAILED: 763 case GoogleServiceAuthError::CONNECTION_FAILED:
764 case GoogleServiceAuthError::REQUEST_CANCELED:
765 case GoogleServiceAuthError::SERVICE_ERROR:
764 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: { 766 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: {
765 // Transient error. Retry after some time. 767 // Transient error. Retry after some time.
766 request_access_token_backoff_.InformOfRequest(false); 768 request_access_token_backoff_.InformOfRequest(false);
767 next_token_request_time_ = base::Time::Now() + 769 next_token_request_time_ = base::Time::Now() +
768 request_access_token_backoff_.GetTimeUntilRelease(); 770 request_access_token_backoff_.GetTimeUntilRelease();
769 request_access_token_retry_timer_.Start( 771 request_access_token_retry_timer_.Start(
770 FROM_HERE, 772 FROM_HERE,
771 request_access_token_backoff_.GetTimeUntilRelease(), 773 request_access_token_backoff_.GetTimeUntilRelease(),
772 base::Bind(&ProfileSyncService::RequestAccessToken, 774 base::Bind(&ProfileSyncService::RequestAccessToken,
773 weak_factory_.GetWeakPtr())); 775 weak_factory_.GetWeakPtr()));
774 NotifyObservers(); 776 NotifyObservers();
775 break; 777 break;
776 } 778 }
777 case GoogleServiceAuthError::SERVICE_ERROR:
778 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: { 779 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: {
779 if (!sync_prefs_.SyncHasAuthError()) { 780 if (!sync_prefs_.SyncHasAuthError()) {
780 sync_prefs_.SetSyncAuthError(true); 781 sync_prefs_.SetSyncAuthError(true);
781 UMA_HISTOGRAM_ENUMERATION("Sync.SyncAuthError", 782 UMA_HISTOGRAM_ENUMERATION("Sync.SyncAuthError",
782 AUTH_ERROR_ENCOUNTERED, 783 AUTH_ERROR_ENCOUNTERED,
783 AUTH_ERROR_LIMIT); 784 AUTH_ERROR_LIMIT);
784 } 785 }
785 // Fallthrough. 786 // Fallthrough.
786 } 787 }
787 default: { 788 default: {
789 if (error.state() != GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) {
790 LOG(ERROR) << "Unexpected persistent error: " << error.ToString();
791 }
788 // Show error to user. 792 // Show error to user.
789 UpdateAuthErrorState(error); 793 UpdateAuthErrorState(error);
790 } 794 }
791 } 795 }
792 } 796 }
793 797
794 void ProfileSyncService::OnRefreshTokenAvailable( 798 void ProfileSyncService::OnRefreshTokenAvailable(
795 const std::string& account_id) { 799 const std::string& account_id) {
796 if (account_id == signin_->GetAccountIdToUse()) 800 if (account_id == signin_->GetAccountIdToUse())
797 OnRefreshTokensLoaded(); 801 OnRefreshTokensLoaded();
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 true)); 2766 true));
2763 } 2767 }
2764 2768
2765 bool ProfileSyncService::NeedBackup() const { 2769 bool ProfileSyncService::NeedBackup() const {
2766 return need_backup_; 2770 return need_backup_;
2767 } 2771 }
2768 2772
2769 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { 2773 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const {
2770 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); 2774 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime();
2771 } 2775 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/test/integration/sync_auth_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698