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

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

Issue 10440007: Merge 138735 - No longer trigger SyncCredentialsLost flow on cros. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1132/src/
Patch Set: Created 8 years, 7 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/profile_sync_service_startup_unittest.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 <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 200
201 void ProfileSyncService::TryStart() { 201 void ProfileSyncService::TryStart() {
202 if (!IsSyncEnabledAndLoggedIn()) 202 if (!IsSyncEnabledAndLoggedIn())
203 return; 203 return;
204 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); 204 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
205 if (!token_service) 205 if (!token_service)
206 return; 206 return;
207 // Don't start the backend if the token service hasn't finished loading tokens 207 // Don't start the backend if the token service hasn't finished loading tokens
208 // yet (if the backend is started before the sync token has been loaded, 208 // yet (if the backend is started before the sync token has been loaded,
209 // GetCredentials() will return bogus credentials). 209 // GetCredentials() will return bogus credentials). On auto_start platforms
210 if (IsSyncTokenAvailable() || token_service->TokensLoadedFromDB()) { 210 // (like ChromeOS) we don't start sync until tokens are loaded, because the
211 // user can be "signed in" on those platforms long before the tokens get
212 // loaded, and we don't want to generate spurious auth errors.
213 if (IsSyncTokenAvailable() ||
214 (!auto_start_enabled_ && token_service->TokensLoadedFromDB())) {
211 if (HasSyncSetupCompleted() || auto_start_enabled_) { 215 if (HasSyncSetupCompleted() || auto_start_enabled_) {
212 // If sync setup has completed we always start the backend. 216 // If sync setup has completed we always start the backend.
213 // If autostart is enabled, but we haven't completed sync setup, we try to 217 // If autostart is enabled, but we haven't completed sync setup, we try to
214 // start sync anyway, since it's possible we crashed/shutdown after 218 // start sync anyway, since it's possible we crashed/shutdown after
215 // logging in but before the backend finished initializing the last time. 219 // logging in but before the backend finished initializing the last time.
216 // Note that if we haven't finished setting up sync, backend bring up will 220 // Note that if we haven't finished setting up sync, backend bring up will
217 // be done by the wizard. 221 // be done by the wizard.
218 StartUp(); 222 StartUp();
219 } 223 }
220 } 224 }
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 backend_->UpdateCredentials(GetCredentials()); 1542 backend_->UpdateCredentials(GetCredentials());
1539 else 1543 else
1540 StartUp(); 1544 StartUp();
1541 } 1545 }
1542 break; 1546 break;
1543 } 1547 }
1544 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { 1548 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: {
1545 // This notification gets fired when TokenService loads the tokens 1549 // This notification gets fired when TokenService loads the tokens
1546 // from storage. 1550 // from storage.
1547 if (IsSyncEnabledAndLoggedIn()) { 1551 if (IsSyncEnabledAndLoggedIn()) {
1552 // Don't start up sync and generate an auth error on auto_start
1553 // platforms as they have their own way to resolve TokenService errors.
1554 // (crbug.com/128592).
1555 if (auto_start_enabled_ && !IsSyncTokenAvailable())
1556 break;
1557
1548 // Initialize the backend if sync is enabled. If the sync token was 1558 // Initialize the backend if sync is enabled. If the sync token was
1549 // not loaded, GetCredentials() will generate invalid credentials to 1559 // not loaded, GetCredentials() will generate invalid credentials to
1550 // cause the backend to generate an auth error (crbug.com/121755). 1560 // cause the backend to generate an auth error (crbug.com/121755).
1551 if (backend_initialized_) 1561 if (backend_initialized_)
1552 backend_->UpdateCredentials(GetCredentials()); 1562 backend_->UpdateCredentials(GetCredentials());
1553 else 1563 else
1554 StartUp(); 1564 StartUp();
1555 } 1565 }
1556 break; 1566 break;
1557 } 1567 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1671 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1662 ProfileSyncService* old_this = this; 1672 ProfileSyncService* old_this = this;
1663 this->~ProfileSyncService(); 1673 this->~ProfileSyncService();
1664 new(old_this) ProfileSyncService( 1674 new(old_this) ProfileSyncService(
1665 new ProfileSyncComponentsFactoryImpl(profile, 1675 new ProfileSyncComponentsFactoryImpl(profile,
1666 CommandLine::ForCurrentProcess()), 1676 CommandLine::ForCurrentProcess()),
1667 profile, 1677 profile,
1668 signin, 1678 signin,
1669 behavior); 1679 behavior);
1670 } 1680 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service_startup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698