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

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

Issue 1267843003: Fix reconcilor loop when the primary account is in an auth error state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 5 years, 4 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_reconcilor.cc
diff --git a/components/signin/core/browser/account_reconcilor.cc b/components/signin/core/browser/account_reconcilor.cc
index 934458da1d24b04edd00f3d552bf55d521d4df7d..f4969bb8dbf355809ab0ac7c48e6dffe2dcb08df 100644
--- a/components/signin/core/browser/account_reconcilor.cc
+++ b/components/signin/core/browser/account_reconcilor.cc
@@ -21,7 +21,6 @@
#include "google_apis/gaia/gaia_oauth_client.h"
#include "google_apis/gaia/gaia_urls.h"
-
namespace {
class AccountEqualToFunc : public std::equal_to<gaia::ListedAccount> {
@@ -258,9 +257,6 @@ void AccountReconcilor::StartReconcile() {
if (is_reconcile_started_)
return;
- is_reconcile_started_ = true;
- error_during_last_reconcile_ = false;
-
// Reset state for validating gaia cookie.
gaia_accounts_.clear();
@@ -270,6 +266,14 @@ void AccountReconcilor::StartReconcile() {
add_to_cookie_.clear();
ValidateAccountsFromTokenService();
+ if (primary_account_.empty()) {
+ VLOG(1) << "AccountReconcilor::StartReconcile: primary has error";
+ return;
+ }
+
+ is_reconcile_started_ = true;
+ error_during_last_reconcile_ = false;
+
// Rely on the GCMS to manage calls to and responses from ListAccounts.
if (cookie_manager_service_->ListAccounts(&gaia_accounts_)) {
OnGaiaAccountsInCookieUpdated(
@@ -305,6 +309,28 @@ void AccountReconcilor::ValidateAccountsFromTokenService() {
chrome_accounts_ = token_service_->GetAccounts();
+ // Remove any accounts that have an error. There is no point in trying to
+ // reconcile them, since it won't work anyway. If the list ends up being
+ // empty, or if the primary account is in error, then don't reconcile any
+ // accounts.
+ for (auto i = chrome_accounts_.begin(); i != chrome_accounts_.end(); ++i) {
+ if (token_service_->GetDelegate()->RefreshTokenHasError(*i)) {
+ if (primary_account_ == *i) {
+ primary_account_.clear();
+ chrome_accounts_.clear();
+ break;
+ } else {
+ VLOG(1) << "AccountReconcilor::ValidateAccountsFromTokenService: "
+ << *i << " has error, won't reconcile";
+ i->clear();
+ }
+ }
+ }
+ chrome_accounts_.erase(std::remove(chrome_accounts_.begin(),
+ chrome_accounts_.end(),
+ std::string()),
+ chrome_accounts_.end());
+
VLOG(1) << "AccountReconcilor::ValidateAccountsFromTokenService: "
<< "Chrome " << chrome_accounts_.size() << " accounts, "
<< "Primary is '" << primary_account_ << "'";

Powered by Google App Engine
This is Rietveld 408576698