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

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

Issue 10434009: No longer trigger SyncCredentialsLost flow on cros. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update per review feedback 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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 backend_->UpdateCredentials(GetCredentials()); 1545 backend_->UpdateCredentials(GetCredentials());
1542 else 1546 else
1543 StartUp(); 1547 StartUp();
1544 } 1548 }
1545 break; 1549 break;
1546 } 1550 }
1547 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { 1551 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: {
1548 // This notification gets fired when TokenService loads the tokens 1552 // This notification gets fired when TokenService loads the tokens
1549 // from storage. 1553 // from storage.
1550 if (IsSyncEnabledAndLoggedIn()) { 1554 if (IsSyncEnabledAndLoggedIn()) {
1555 // Don't start up sync and generate an auth error on auto_start
1556 // platforms as they have their own way to resolve TokenService errors.
1557 // (crbug.com/128592).
1558 if (auto_start_enabled_ && !IsSyncTokenAvailable())
1559 break;
1560
1551 // Initialize the backend if sync is enabled. If the sync token was 1561 // Initialize the backend if sync is enabled. If the sync token was
1552 // not loaded, GetCredentials() will generate invalid credentials to 1562 // not loaded, GetCredentials() will generate invalid credentials to
1553 // cause the backend to generate an auth error (crbug.com/121755). 1563 // cause the backend to generate an auth error (crbug.com/121755).
1554 if (backend_initialized_) 1564 if (backend_initialized_)
1555 backend_->UpdateCredentials(GetCredentials()); 1565 backend_->UpdateCredentials(GetCredentials());
1556 else 1566 else
1557 StartUp(); 1567 StartUp();
1558 } 1568 }
1559 break; 1569 break;
1560 } 1570 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1674 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1665 ProfileSyncService* old_this = this; 1675 ProfileSyncService* old_this = this;
1666 this->~ProfileSyncService(); 1676 this->~ProfileSyncService();
1667 new(old_this) ProfileSyncService( 1677 new(old_this) ProfileSyncService(
1668 new ProfileSyncComponentsFactoryImpl(profile, 1678 new ProfileSyncComponentsFactoryImpl(profile,
1669 CommandLine::ForCurrentProcess()), 1679 CommandLine::ForCurrentProcess()),
1670 profile, 1680 profile,
1671 signin, 1681 signin,
1672 behavior); 1682 behavior);
1673 } 1683 }
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