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

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

Issue 62423002: Fix one case that can make sync backend stuck in auth error state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
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 <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 // be there. 636 // be there.
637 InitializeBackend(!HasSyncSetupCompleted()); 637 InitializeBackend(!HasSyncSetupCompleted());
638 } 638 }
639 639
640 void ProfileSyncService::OnGetTokenSuccess( 640 void ProfileSyncService::OnGetTokenSuccess(
641 const OAuth2TokenService::Request* request, 641 const OAuth2TokenService::Request* request,
642 const std::string& access_token, 642 const std::string& access_token,
643 const base::Time& expiration_time) { 643 const base::Time& expiration_time) {
644 DCHECK_EQ(access_token_request_, request); 644 DCHECK_EQ(access_token_request_, request);
645 access_token_request_.reset(); 645 access_token_request_.reset();
646 // Reset backoff time after successful response.
647 request_access_token_backoff_.Reset();
648 access_token_ = access_token; 646 access_token_ = access_token;
649 if (backend_) 647 if (backend_)
650 backend_->UpdateCredentials(GetCredentials()); 648 backend_->UpdateCredentials(GetCredentials());
651 else 649 else
652 TryStart(); 650 TryStart();
653 } 651 }
654 652
655 void ProfileSyncService::OnGetTokenFailure( 653 void ProfileSyncService::OnGetTokenFailure(
656 const OAuth2TokenService::Request* request, 654 const OAuth2TokenService::Request* request,
657 const GoogleServiceAuthError& error) { 655 const GoogleServiceAuthError& error) {
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 } 1102 }
1105 1103
1106 } // namespace 1104 } // namespace
1107 1105
1108 void ProfileSyncService::OnConnectionStatusChange( 1106 void ProfileSyncService::OnConnectionStatusChange(
1109 syncer::ConnectionStatus status) { 1107 syncer::ConnectionStatus status) {
1110 if (status == syncer::CONNECTION_AUTH_ERROR) { 1108 if (status == syncer::CONNECTION_AUTH_ERROR) {
1111 // Sync server returned error indicating that access token is invalid. It 1109 // Sync server returned error indicating that access token is invalid. It
1112 // could be either expired or access is revoked. Let's request another 1110 // could be either expired or access is revoked. Let's request another
1113 // access token and if access is revoked then request for token will fail 1111 // access token and if access is revoked then request for token will fail
1114 // with corresponding error. 1112 // with corresponding error. If access token is repeatedly reported
1115 RequestAccessToken(); 1113 // invalid, there may be some issues with token server. In that case, we
tim (not reviewing) 2013/11/06 19:35:32 In fact, if the access token is repeatedly reporte
haitaol1 2013/11/06 22:37:30 I think the root cause is still on server. If serv
tim (not reviewing) 2013/11/07 22:07:13 But there could be *no issue* with the *token* ser
haitaol1 2013/11/08 15:23:02 Removed token On 2013/11/07 22:07:13, timsteele w
1114 // backoff token requests exponentially to avoid hammering token server
1115 // too much.
1116 if (request_access_token_backoff_.failure_count() == 0) {
1117 RequestAccessToken();
1118 } else {
1119 request_access_token_backoff_.InformOfRequest(false);
1120 request_access_token_retry_timer_.Start(
1121 FROM_HERE,
1122 request_access_token_backoff_.GetTimeUntilRelease(),
1123 base::Bind(&ProfileSyncService::RequestAccessToken,
1124 weak_factory_.GetWeakPtr()));
1125 }
1116 } else { 1126 } else {
1127 // Reset backoff time after successful connection.
tim (not reviewing) 2013/11/06 19:35:32 This is where it gets dangerous and bug prone in m
haitaol1 2013/11/06 22:37:30 Good point. Changed to only reset if no request is
1128 if (status == syncer::CONNECTION_OK)
1129 request_access_token_backoff_.Reset();
1130
1117 const GoogleServiceAuthError auth_error = 1131 const GoogleServiceAuthError auth_error =
1118 ConnectionStatusToAuthError(status); 1132 ConnectionStatusToAuthError(status);
1119 DVLOG(1) << "Connection status change: " << auth_error.ToString(); 1133 DVLOG(1) << "Connection status change: " << auth_error.ToString();
1120 UpdateAuthErrorState(auth_error); 1134 UpdateAuthErrorState(auth_error);
1121 } 1135 }
1122 } 1136 }
1123 1137
1124 void ProfileSyncService::OnStopSyncingPermanently() { 1138 void ProfileSyncService::OnStopSyncingPermanently() {
1125 sync_prefs_.SetStartSuppressed(true); 1139 sync_prefs_.SetStartSuppressed(true);
1126 DisableForUser(); 1140 DisableForUser();
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 NOTREACHED(); 2148 NOTREACHED();
2135 #endif 2149 #endif
2136 } 2150 }
2137 2151
2138 return signin_->GetAuthenticatedUsername(); 2152 return signin_->GetAuthenticatedUsername();
2139 } 2153 }
2140 2154
2141 WeakHandle<syncer::JsEventHandler> ProfileSyncService::GetJsEventHandler() { 2155 WeakHandle<syncer::JsEventHandler> ProfileSyncService::GetJsEventHandler() {
2142 return MakeWeakHandle(sync_js_controller_.AsWeakPtr()); 2156 return MakeWeakHandle(sync_js_controller_.AsWeakPtr());
2143 } 2157 }
OLDNEW
« no previous file with comments | « no previous file | sync/engine/net/server_connection_manager.cc » ('j') | sync/engine/net/server_connection_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698