Commit 4555495a authored by msarda's avatar msarda Committed by Commit bot

Avoid double registration with content settings in account reconcilor.

This CL avoids a double registration for content settings in account
rconcilor as this leads to a DCHECK being fired during a reauthentication
operation.

BUG=454507

Review URL: https://codereview.chromium.org/896723006

Cr-Commit-Position: refs/heads/master@{#314409}
parent 12564e89
...@@ -65,6 +65,7 @@ AccountReconcilor::AccountReconcilor(ProfileOAuth2TokenService* token_service, ...@@ -65,6 +65,7 @@ AccountReconcilor::AccountReconcilor(ProfileOAuth2TokenService* token_service,
NULL), NULL),
registered_with_token_service_(false), registered_with_token_service_(false),
registered_with_merge_session_helper_(false), registered_with_merge_session_helper_(false),
registered_with_content_settings_(false),
is_reconcile_started_(false), is_reconcile_started_(false),
first_execution_(true), first_execution_(true),
are_gaia_accounts_set_(false), are_gaia_accounts_set_(false),
...@@ -144,11 +145,24 @@ void AccountReconcilor::UnregisterWithSigninManager() { ...@@ -144,11 +145,24 @@ void AccountReconcilor::UnregisterWithSigninManager() {
} }
void AccountReconcilor::RegisterWithContentSettings() { void AccountReconcilor::RegisterWithContentSettings() {
VLOG(1) << "AccountReconcilor::RegisterWithContentSettings";
// During re-auth, the reconcilor will get a callback about successful signin
// even when the profile is already connected. Avoid re-registering
// with the token service since this will DCHECK.
if (registered_with_content_settings_)
return;
client_->AddContentSettingsObserver(this); client_->AddContentSettingsObserver(this);
registered_with_content_settings_ = true;
} }
void AccountReconcilor::UnregisterWithContentSettings() { void AccountReconcilor::UnregisterWithContentSettings() {
VLOG(1) << "AccountReconcilor::UnregisterWithContentSettings";
if (!registered_with_content_settings_)
return;
client_->RemoveContentSettingsObserver(this); client_->RemoveContentSettingsObserver(this);
registered_with_content_settings_ = false;
} }
void AccountReconcilor::RegisterWithTokenService() { void AccountReconcilor::RegisterWithTokenService() {
......
...@@ -193,6 +193,7 @@ class AccountReconcilor : public KeyedService, ...@@ -193,6 +193,7 @@ class AccountReconcilor : public KeyedService,
scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; scoped_ptr<GaiaAuthFetcher> gaia_fetcher_;
bool registered_with_token_service_; bool registered_with_token_service_;
bool registered_with_merge_session_helper_; bool registered_with_merge_session_helper_;
bool registered_with_content_settings_;
// True while the reconcilor is busy checking or managing the accounts in // True while the reconcilor is busy checking or managing the accounts in
// this profile. // this profile.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment