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

Unified Diff: components/signin/core/browser/account_tracker_service.cc

Issue 1086073006: Fix DCHECK when upgrading from an old profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | components/signin/core/browser/signin_manager_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/signin/core/browser/account_tracker_service.cc
diff --git a/components/signin/core/browser/account_tracker_service.cc b/components/signin/core/browser/account_tracker_service.cc
index 78d942afff1d3f91b45477090ae290e8cc549cce..5f2c1eb60523d6fd5e345f9bc5441ab5e34a94c8 100644
--- a/components/signin/core/browser/account_tracker_service.cc
+++ b/components/signin/core/browser/account_tracker_service.cc
@@ -255,13 +255,15 @@ AccountTrackerService::AccountInfo AccountTrackerService::GetAccountInfo(
AccountTrackerService::AccountInfo
AccountTrackerService::FindAccountInfoByGaiaId(
const std::string& gaia_id) {
- for (std::map<std::string, AccountState>::const_iterator it =
- accounts_.begin();
- it != accounts_.end();
- ++it) {
- const AccountState& state = it->second;
- if (state.info.gaia == gaia_id)
- return state.info;
+ if (!gaia_id.empty()) {
+ for (std::map<std::string, AccountState>::const_iterator it =
+ accounts_.begin();
+ it != accounts_.end();
+ ++it) {
+ const AccountState& state = it->second;
+ if (state.info.gaia == gaia_id)
+ return state.info;
+ }
}
return AccountInfo();
@@ -270,13 +272,15 @@ AccountTrackerService::FindAccountInfoByGaiaId(
AccountTrackerService::AccountInfo
AccountTrackerService::FindAccountInfoByEmail(
const std::string& email) {
- for (std::map<std::string, AccountState>::const_iterator it =
- accounts_.begin();
- it != accounts_.end();
- ++it) {
- const AccountState& state = it->second;
- if (gaia::AreEmailsSame(state.info.email, email))
- return state.info;
+ if (!email.empty()) {
+ for (std::map<std::string, AccountState>::const_iterator it =
+ accounts_.begin();
+ it != accounts_.end();
+ ++it) {
+ const AccountState& state = it->second;
+ if (gaia::AreEmailsSame(state.info.email, email))
+ return state.info;
+ }
}
return AccountInfo();
@@ -584,7 +588,8 @@ std::string AccountTrackerService::PickAccountIdForAccount(
PrefService* pref_service,
const std::string& gaia,
const std::string& email) {
- DCHECK(!gaia.empty());
+ DCHECK(!gaia.empty() ||
+ GetMigrationState(pref_service) == MIGRATION_NOT_STARTED);
DCHECK(!email.empty());
switch(GetMigrationState(pref_service)) {
case MIGRATION_NOT_STARTED:
@@ -603,13 +608,11 @@ std::string AccountTrackerService::PickAccountIdForAccount(
std::string AccountTrackerService::SeedAccountInfo(const std::string& gaia,
const std::string& email) {
- DCHECK(!gaia.empty());
- DCHECK(!email.empty());
const std::string account_id = PickAccountIdForAccount(gaia, email);
const bool already_exists = ContainsKey(accounts_, account_id);
StartTrackingAccount(account_id);
AccountState& state = accounts_[account_id];
- DCHECK(!already_exists || state.info.gaia == gaia);
+ DCHECK(!already_exists || state.info.gaia.empty() || state.info.gaia == gaia);
state.info.gaia = gaia;
state.info.email = email;
SaveToPrefs(state);
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | components/signin/core/browser/signin_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698