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

Side by Side Diff: sync/engine/net/server_connection_manager.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 "sync/engine/net/server_connection_manager.h" 5 #include "sync/engine/net/server_connection_manager.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include <ostream> 9 #include <ostream>
10 #include <string> 10 #include <string>
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 active_connection_ = NULL; 226 active_connection_ = NULL;
227 } 227 }
228 228
229 bool ServerConnectionManager::SetAuthToken(const std::string& auth_token) { 229 bool ServerConnectionManager::SetAuthToken(const std::string& auth_token) {
230 DCHECK(thread_checker_.CalledOnValidThread()); 230 DCHECK(thread_checker_.CalledOnValidThread());
231 if (previously_invalidated_token != auth_token) { 231 if (previously_invalidated_token != auth_token) {
232 auth_token_.assign(auth_token); 232 auth_token_.assign(auth_token);
233 previously_invalidated_token = std::string(); 233 previously_invalidated_token = std::string();
234 return true; 234 return true;
235 } 235 }
236
237 // This could happen in case like server outage/bug. Need to notify sync
tim (not reviewing) 2013/11/06 19:35:32 What is server outage/bug? Either explain the out
haitaol1 2013/11/06 22:37:30 Done.
238 // frontend again to request new token, otherwise backend will stay in
239 // SYNC_AUTH_ERROR state while fronend thinks everything is fine and takes
240 // no actions.
241 SetServerStatus(HttpResponse::SYNC_AUTH_ERROR);
tim (not reviewing) 2013/11/06 19:35:32 I guess the only case that is implicitly in the "e
haitaol1 2013/11/06 22:37:30 Empty token shouldn't be possible because ProfileS
236 return false; 242 return false;
237 } 243 }
238 244
239 void ServerConnectionManager::OnInvalidationCredentialsRejected() { 245 void ServerConnectionManager::OnInvalidationCredentialsRejected() {
240 InvalidateAndClearAuthToken(); 246 InvalidateAndClearAuthToken();
241 SetServerStatus(HttpResponse::SYNC_AUTH_ERROR); 247 SetServerStatus(HttpResponse::SYNC_AUTH_ERROR);
242 } 248 }
243 249
244 void ServerConnectionManager::InvalidateAndClearAuthToken() { 250 void ServerConnectionManager::InvalidateAndClearAuthToken() {
245 DCHECK(thread_checker_.CalledOnValidThread()); 251 DCHECK(thread_checker_.CalledOnValidThread());
246 // Copy over the token to previous invalid token. 252 // Copy over the token to previous invalid token.
247 if (!auth_token_.empty()) { 253 if (!auth_token_.empty()) {
248 previously_invalidated_token.assign(auth_token_); 254 previously_invalidated_token.assign(auth_token_);
249 auth_token_ = std::string(); 255 auth_token_ = std::string();
250 } 256 }
251 } 257 }
252 258
253 void ServerConnectionManager::SetServerStatus( 259 void ServerConnectionManager::SetServerStatus(
254 HttpResponse::ServerConnectionCode server_status) { 260 HttpResponse::ServerConnectionCode server_status) {
255 if (server_status_ == server_status) 261 // SYNC_AUTH_ERROR is permanent error. Need to notify observer to take
262 // action externally to resolve.
263 if (server_status != HttpResponse::SYNC_AUTH_ERROR &&
264 server_status_ == server_status) {
tim (not reviewing) 2013/11/06 19:35:32 Pavel and Richard should review this part carefull
haitaol1 2013/11/06 22:37:30 acked
haitaol1 2013/11/07 15:23:52 Another option is to leverage CONNECTION_NOT_ATTEM
256 return; 265 return;
266 }
257 server_status_ = server_status; 267 server_status_ = server_status;
258 NotifyStatusChanged(); 268 NotifyStatusChanged();
259 } 269 }
260 270
261 void ServerConnectionManager::NotifyStatusChanged() { 271 void ServerConnectionManager::NotifyStatusChanged() {
262 DCHECK(thread_checker_.CalledOnValidThread()); 272 DCHECK(thread_checker_.CalledOnValidThread());
263 FOR_EACH_OBSERVER(ServerConnectionEventListener, listeners_, 273 FOR_EACH_OBSERVER(ServerConnectionEventListener, listeners_,
264 OnServerConnectionEvent( 274 OnServerConnectionEvent(
265 ServerConnectionEvent(server_status_))); 275 ServerConnectionEvent(server_status_)));
266 } 276 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 383
374 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { 384 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) {
375 s << " Response Code (bogus on error): " << hr.response_code; 385 s << " Response Code (bogus on error): " << hr.response_code;
376 s << " Content-Length (bogus on error): " << hr.content_length; 386 s << " Content-Length (bogus on error): " << hr.content_length;
377 s << " Server Status: " 387 s << " Server Status: "
378 << HttpResponse::GetServerConnectionCodeString(hr.server_status); 388 << HttpResponse::GetServerConnectionCodeString(hr.server_status);
379 return s; 389 return s;
380 } 390 }
381 391
382 } // namespace syncer 392 } // namespace syncer
OLDNEW
« chrome/browser/sync/profile_sync_service.cc ('K') | « chrome/browser/sync/profile_sync_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698