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

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

Issue 1380103004: Delay fetching account info until OnRefreshTokensLoaded(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 2 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
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 b57c58500e897372df481d6608843af8b5d09cb5..5c4d9e5b4266da73ebc5949387c34637f1e07c38 100644
--- a/components/signin/core/browser/account_tracker_service.cc
+++ b/components/signin/core/browser/account_tracker_service.cc
@@ -141,6 +141,26 @@ AccountInfo AccountTrackerService::FindAccountInfoByEmail(
return AccountInfo();
}
+bool AccountTrackerService::IsTrackingAccount(
+ const std::string& account_id) const {
+ return ContainsKey(accounts_, account_id);
+}
+
+bool AccountTrackerService::HasIdNameMappingForAccount(
+ const std::string& account_id) const {
+ AccountInfo account = GetAccountInfo(account_id);
+ return !account.email.empty() && !account.gaia.empty();
gogerald1 2015/10/13 16:34:53 This is always true, if IsMigratable() is true and
nyquist 2015/10/15 19:33:45 I thought GetAccountInfo(...) returns an empty str
+}
+
+bool AccountTrackerService::HasIdNameMappingForAllAccounts() const {
+ for (const auto& account : accounts_) {
+ const AccountInfo& account_info = account.second.info;
+ if (account_info.email.empty() || account_info.gaia.empty())
gogerald1 2015/10/13 16:34:53 Same as above comments
+ return false;
+ }
+ return true;
+}
+
AccountTrackerService::AccountIdMigrationState
AccountTrackerService::GetMigrationState() const {
return GetMigrationState(signin_client_->GetPrefs());
@@ -182,7 +202,7 @@ void AccountTrackerService::NotifyAccountRemoved(const AccountState& state) {
void AccountTrackerService::StartTrackingAccount(
const std::string& account_id) {
- if (!ContainsKey(accounts_, account_id)) {
+ if (!IsTrackingAccount(account_id)) {
DVLOG(1) << "StartTracking " << account_id;
AccountState state;
state.info.account_id = account_id;
@@ -193,7 +213,7 @@ void AccountTrackerService::StartTrackingAccount(
void AccountTrackerService::StopTrackingAccount(const std::string& account_id) {
DVLOG(1) << "StopTracking " << account_id;
- if (ContainsKey(accounts_, account_id)) {
+ if (IsTrackingAccount(account_id)) {
AccountState& state = accounts_[account_id];
RemoveFromPrefs(state);
if (!state.info.gaia.empty())
@@ -206,7 +226,7 @@ void AccountTrackerService::StopTrackingAccount(const std::string& account_id) {
void AccountTrackerService::SetAccountStateFromUserInfo(
const std::string& account_id,
const base::DictionaryValue* user_info) {
- DCHECK(ContainsKey(accounts_, account_id));
+ DCHECK(IsTrackingAccount(account_id));
AccountState& state = accounts_[account_id];
std::string gaia_id;
@@ -241,7 +261,7 @@ void AccountTrackerService::SetAccountStateFromUserInfo(
void AccountTrackerService::SetIsChildAccount(const std::string& account_id,
const bool& is_child_account) {
- DCHECK(ContainsKey(accounts_, account_id));
+ DCHECK(IsTrackingAccount(account_id));
AccountState& state = accounts_[account_id];
if (state.info.is_child_account == is_child_account)
return;
@@ -253,14 +273,7 @@ void AccountTrackerService::SetIsChildAccount(const std::string& account_id,
bool AccountTrackerService::IsMigratable() const {
#if !defined(OS_CHROMEOS)
- for (std::map<std::string, AccountState>::const_iterator it =
- accounts_.begin();
- it != accounts_.end(); ++it) {
- const AccountState& state = it->second;
- if ((it->first).empty() || state.info.gaia.empty())
- return false;
- }
- return true;
+ return HasIdNameMappingForAllAccounts();
#else
return false;
#endif
@@ -276,7 +289,7 @@ void AccountTrackerService::MigrateToGaiaId() {
std::string account_id = it->first;
if (account_id != state.info.gaia) {
std::string new_account_id = state.info.gaia;
- if (!ContainsKey(accounts_, new_account_id)) {
+ if (!IsTrackingAccount(new_account_id)) {
AccountState new_state = state;
new_state.info.account_id = new_account_id;
migrated_accounts.insert(make_pair(new_account_id, new_state));
@@ -288,7 +301,7 @@ void AccountTrackerService::MigrateToGaiaId() {
// Remove any obsolete account.
for (auto account_id : to_remove) {
- if (ContainsKey(accounts_, account_id)) {
+ if (IsTrackingAccount(account_id)) {
AccountState& state = accounts_[account_id];
RemoveFromPrefs(state);
accounts_.erase(account_id);
@@ -466,7 +479,7 @@ std::string AccountTrackerService::PickAccountIdForAccount(
std::string AccountTrackerService::SeedAccountInfo(const std::string& gaia,
const std::string& email) {
const std::string account_id = PickAccountIdForAccount(gaia, email);
- const bool already_exists = ContainsKey(accounts_, account_id);
+ const bool already_exists = IsTrackingAccount(account_id);
StartTrackingAccount(account_id);
AccountState& state = accounts_[account_id];
DCHECK(!already_exists || state.info.gaia.empty() || state.info.gaia == gaia);
@@ -489,7 +502,7 @@ void AccountTrackerService::SeedAccountInfo(AccountInfo info) {
}
if(info.IsValid()) {
- if(!ContainsKey(accounts_, info.account_id)) {
+ if (!IsTrackingAccount(info.account_id)) {
SeedAccountInfo(info.gaia, info.email);
}

Powered by Google App Engine
This is Rietveld 408576698