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

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

Issue 11428125: [Sync] Fix auth error handling while the backend is initializing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // the process of setting up now, we should start the backend to download 271 // the process of setting up now, we should start the backend to download
272 // account control state / encryption information). If autostart is enabled, 272 // account control state / encryption information). If autostart is enabled,
273 // but we haven't completed sync setup, we try to start sync anyway, since 273 // but we haven't completed sync setup, we try to start sync anyway, since
274 // it's possible we crashed/shutdown after logging in but before the backend 274 // it's possible we crashed/shutdown after logging in but before the backend
275 // finished initializing the last time. 275 // finished initializing the last time.
276 if (!HasSyncSetupCompleted() && !setup_in_progress_ && !auto_start_enabled_) 276 if (!HasSyncSetupCompleted() && !setup_in_progress_ && !auto_start_enabled_)
277 return; 277 return;
278 278
279 // All systems Go for launch. 279 // All systems Go for launch.
280 StartUp(); 280 StartUp();
281
282 } 281 }
283 282
284 void ProfileSyncService::StartSyncingWithServer() { 283 void ProfileSyncService::StartSyncingWithServer() {
285 if (backend_.get()) 284 if (backend_.get())
286 backend_->StartSyncingWithServer(); 285 backend_->StartSyncingWithServer();
287 } 286 }
288 287
289 void ProfileSyncService::RegisterAuthNotifications() { 288 void ProfileSyncService::RegisterAuthNotifications() {
290 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); 289 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
291 registrar_.Add(this, 290 registrar_.Add(this,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 414
416 void ProfileSyncService::OnSyncConfigureDone( 415 void ProfileSyncService::OnSyncConfigureDone(
417 DataTypeManager::ConfigureResult result) { 416 DataTypeManager::ConfigureResult result) {
418 if (failed_datatypes_handler_.UpdateFailedDatatypes(result.failed_data_types, 417 if (failed_datatypes_handler_.UpdateFailedDatatypes(result.failed_data_types,
419 FailedDatatypesHandler::STARTUP)) { 418 FailedDatatypesHandler::STARTUP)) {
420 ReconfigureDatatypeManager(); 419 ReconfigureDatatypeManager();
421 } 420 }
422 } 421 }
423 422
424 void ProfileSyncService::OnSyncConfigureRetry() { 423 void ProfileSyncService::OnSyncConfigureRetry() {
425 // In platforms with auto start we would just wait for the 424 // Note: in order to handle auth failures that arise before the backend is
426 // configure to finish. In other platforms we would throw 425 // initialized (e.g. from invalidation notifier, or downloading new control
427 // an unrecoverable error. The reason we do this is so that 426 // types), we have to gracefully handle configuration retries at all times.
428 // the login dialog would show an error and the user would have 427 // At this point an auth error badge should be shown, which once resolved
429 // to relogin. 428 // will trigger a new sync cycle.
430 // Also if backend has been initialized(the user is authenticated
431 // and nigori is downloaded) we would simply wait rather than going into
432 // unrecoverable error, even if the platform has auto start disabled.
433 // Note: In those scenarios the UI does not wait for the configuration
434 // to finish.
435 if (!auto_start_enabled_ && !backend_initialized_) {
436 OnInternalUnrecoverableError(FROM_HERE,
437 "Configure failed to download.",
438 true,
439 ERROR_REASON_CONFIGURATION_RETRY);
440 }
441
442 NotifyObservers(); 429 NotifyObservers();
443 } 430 }
444 431
445 432
446 void ProfileSyncService::StartUp() { 433 void ProfileSyncService::StartUp() {
447 // Don't start up multiple times. 434 // Don't start up multiple times.
448 if (backend_.get()) { 435 if (backend_.get()) {
449 DVLOG(1) << "Skipping bringing up backend host."; 436 DVLOG(1) << "Skipping bringing up backend host.";
450 return; 437 return;
451 } 438 }
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 details).ptr()); 1756 details).ptr());
1770 if (!IsTokenServiceRelevant(token_details.service())) 1757 if (!IsTokenServiceRelevant(token_details.service()))
1771 break; 1758 break;
1772 } // Fall through. 1759 } // Fall through.
1773 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { 1760 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: {
1774 // This notification gets fired when TokenService loads the tokens 1761 // This notification gets fired when TokenService loads the tokens
1775 // from storage. 1762 // from storage.
1776 // Initialize the backend if sync is enabled. If the sync token was 1763 // Initialize the backend if sync is enabled. If the sync token was
1777 // not loaded, GetCredentials() will generate invalid credentials to 1764 // not loaded, GetCredentials() will generate invalid credentials to
1778 // cause the backend to generate an auth error (crbug.com/121755). 1765 // cause the backend to generate an auth error (crbug.com/121755).
1779 if (backend_initialized_) 1766 if (backend_.get())
1780 backend_->UpdateCredentials(GetCredentials()); 1767 backend_->UpdateCredentials(GetCredentials());
1781 else 1768 else
1782 TryStart(); 1769 TryStart();
1783 break; 1770 break;
1784 } 1771 }
1785 default: { 1772 default: {
1786 NOTREACHED(); 1773 NOTREACHED();
1787 } 1774 }
1788 } 1775 }
1789 } 1776 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1893 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1907 ProfileSyncService* old_this = this; 1894 ProfileSyncService* old_this = this;
1908 this->~ProfileSyncService(); 1895 this->~ProfileSyncService();
1909 new(old_this) ProfileSyncService( 1896 new(old_this) ProfileSyncService(
1910 new ProfileSyncComponentsFactoryImpl(profile, 1897 new ProfileSyncComponentsFactoryImpl(profile,
1911 CommandLine::ForCurrentProcess()), 1898 CommandLine::ForCurrentProcess()),
1912 profile, 1899 profile,
1913 signin, 1900 signin,
1914 behavior); 1901 behavior);
1915 } 1902 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | chrome/browser/sync/profile_sync_service_startup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698