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

Side by Side Diff: chrome/browser/sync/engine/net/server_connection_manager.h

Issue 7563017: Dont retry sync in case of auth errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload before commit. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/sync/engine/net/server_connection_manager.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ 6 #define CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <iosfwd> 9 #include <iosfwd>
10 #include <string> 10 #include <string>
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 // Factory method to create a Post object we can use for communication with 271 // Factory method to create a Post object we can use for communication with
272 // the server. 272 // the server.
273 virtual Post* MakePost(); 273 virtual Post* MakePost();
274 274
275 void set_client_id(const std::string& client_id) { 275 void set_client_id(const std::string& client_id) {
276 DCHECK(client_id_.empty()); 276 DCHECK(client_id_.empty());
277 client_id_.assign(client_id); 277 client_id_.assign(client_id);
278 } 278 }
279 279
280 void set_auth_token(const std::string& auth_token) { 280 // Returns true if the auth token is succesfully set and false otherwise.
281 bool set_auth_token(const std::string& auth_token) {
281 // TODO(chron): Consider adding a message loop check here. 282 // TODO(chron): Consider adding a message loop check here.
282 base::AutoLock lock(auth_token_mutex_); 283 base::AutoLock lock(auth_token_mutex_);
283 auth_token_.assign(auth_token); 284 if (previously_invalidated_token != auth_token) {
285 auth_token_.assign(auth_token);
286 previously_invalidated_token = std::string();
287 return true;
288 }
289 return false;
290 }
291
292 void InvalidateAndClearAuthToken() {
293 // Copy over the token to previous invalid token.
294 base::AutoLock lock(auth_token_mutex_);
295 if (!auth_token_.empty()) {
296 previously_invalidated_token.assign(auth_token_);
297 auth_token_ = std::string();
298 }
284 } 299 }
285 300
286 const std::string auth_token() const { 301 const std::string auth_token() const {
287 base::AutoLock lock(auth_token_mutex_); 302 base::AutoLock lock(auth_token_mutex_);
288 return auth_token_; 303 return auth_token_;
289 } 304 }
290 305
291 protected: 306 protected:
292 inline std::string proto_sync_path() const { 307 inline std::string proto_sync_path() const {
293 base::AutoLock lock(path_mutex_); 308 base::AutoLock lock(path_mutex_);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 346
332 // The paths we post to. 347 // The paths we post to.
333 mutable base::Lock path_mutex_; 348 mutable base::Lock path_mutex_;
334 std::string proto_sync_path_; 349 std::string proto_sync_path_;
335 std::string get_time_path_; 350 std::string get_time_path_;
336 351
337 mutable base::Lock auth_token_mutex_; 352 mutable base::Lock auth_token_mutex_;
338 // The auth token to use in authenticated requests. Set by the AuthWatcher. 353 // The auth token to use in authenticated requests. Set by the AuthWatcher.
339 std::string auth_token_; 354 std::string auth_token_;
340 355
356 // The previous auth token that is invalid now.
357 std::string previously_invalidated_token;
358
341 base::Lock error_count_mutex_; // Protects error_count_ 359 base::Lock error_count_mutex_; // Protects error_count_
342 int error_count_; // Tracks the number of connection errors. 360 int error_count_; // Tracks the number of connection errors.
343 361
344 scoped_refptr<ObserverListThreadSafe<ServerConnectionEventListener> > 362 scoped_refptr<ObserverListThreadSafe<ServerConnectionEventListener> >
345 listeners_; 363 listeners_;
346 364
347 // Volatile so various threads can call server_status() without 365 // Volatile so various threads can call server_status() without
348 // synchronization. 366 // synchronization.
349 volatile HttpResponse::ServerConnectionCode server_status_; 367 volatile HttpResponse::ServerConnectionCode server_status_;
350 bool server_reachable_; 368 bool server_reachable_;
(...skipping 17 matching lines...) Expand all
368 // settings. 386 // settings.
369 bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm, 387 bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm,
370 syncable::DirectoryManager* manager, 388 syncable::DirectoryManager* manager,
371 const std::string& share); 389 const std::string& share);
372 390
373 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); 391 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr);
374 392
375 } // namespace browser_sync 393 } // namespace browser_sync
376 394
377 #endif // CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ 395 #endif // CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/engine/net/server_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698