Commit f76169e4 authored by Kush Sinha's avatar Kush Sinha Committed by Commit Bot

Improve AccountReconcilor API usage in AccountManagerMigrator

AccountManagerMigrator used |AccountReconcilor::Initialize| as a way of
starting account reconciliation because |AccountReconcilor::Start| is a
private method.

Make |AccountReconcilor::EnableReconcile| call
|AccountReconcilor::StartReconcile| in its implementation and call
|EnableReconcile| from AccountManagerMigrator.

Bug: 904128
Test: components_unittests --gtest_filter="*AccountReconcilorTest*"
Change-Id: I7899fb261080c10bb62ebdefe31c45d3a9a4754c
Reviewed-on: https://chromium-review.googlesource.com/c/1424299
Commit-Queue: Kush Sinha <sinhak@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629934}
parent 02803244
...@@ -575,8 +575,9 @@ void AccountManagerMigrator::RunCleanupTasks() { ...@@ -575,8 +575,9 @@ void AccountManagerMigrator::RunCleanupTasks() {
// Secondary Accounts but if we do not enable reconciliation, users will not // Secondary Accounts but if we do not enable reconciliation, users will not
// be able to add any account to Chrome content area which is a much worse // be able to add any account to Chrome content area which is a much worse
// experience than losing Chrome content area Secondary Accounts. // experience than losing Chrome content area Secondary Accounts.
AccountReconcilorFactory::GetForProfile(profile_)->Initialize( AccountReconcilor* account_reconcilor =
true /* start_reconcile_if_tokens_available */); AccountReconcilorFactory::GetForProfile(profile_);
account_reconcilor->EnableReconcile();
} }
// static // static
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <set>
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
...@@ -218,10 +219,20 @@ AccountReconcilor::~AccountReconcilor() { ...@@ -218,10 +219,20 @@ AccountReconcilor::~AccountReconcilor() {
DCHECK(!registered_with_identity_manager_); DCHECK(!registered_with_identity_manager_);
} }
void AccountReconcilor::RegisterWithAllDependencies() {
RegisterWithContentSettings();
RegisterWithIdentityManager();
}
void AccountReconcilor::UnregisterWithAllDependencies() {
UnregisterWithIdentityManager();
UnregisterWithContentSettings();
}
void AccountReconcilor::Initialize(bool start_reconcile_if_tokens_available) { void AccountReconcilor::Initialize(bool start_reconcile_if_tokens_available) {
VLOG(1) << "AccountReconcilor::Initialize"; VLOG(1) << "AccountReconcilor::Initialize";
if (delegate_->IsReconcileEnabled()) { if (delegate_->IsReconcileEnabled()) {
EnableReconcile(); RegisterWithAllDependencies();
// Start a reconcile if the tokens are already loaded. // Start a reconcile if the tokens are already loaded.
if (start_reconcile_if_tokens_available && IsIdentityManagerReady()) if (start_reconcile_if_tokens_available && IsIdentityManagerReady())
...@@ -237,14 +248,17 @@ void AccountReconcilor::SetIsWKHTTPSystemCookieStoreEnabled(bool is_enabled) { ...@@ -237,14 +248,17 @@ void AccountReconcilor::SetIsWKHTTPSystemCookieStoreEnabled(bool is_enabled) {
void AccountReconcilor::EnableReconcile() { void AccountReconcilor::EnableReconcile() {
DCHECK(delegate_->IsReconcileEnabled()); DCHECK(delegate_->IsReconcileEnabled());
RegisterWithContentSettings(); RegisterWithAllDependencies();
RegisterWithIdentityManager(); #if !defined(OS_IOS)
// TODO(droger): Investigate why this breaks tests on iOS.
if (IsIdentityManagerReady())
StartReconcile();
#endif // !defined(OS_IOS)
} }
void AccountReconcilor::DisableReconcile(bool logout_all_accounts) { void AccountReconcilor::DisableReconcile(bool logout_all_accounts) {
AbortReconcile(); AbortReconcile();
UnregisterWithIdentityManager(); UnregisterWithAllDependencies();
UnregisterWithContentSettings();
if (logout_all_accounts) if (logout_all_accounts)
PerformLogoutAllAccountsAction(); PerformLogoutAllAccountsAction();
......
...@@ -233,6 +233,8 @@ class AccountReconcilor : public KeyedService, ...@@ -233,6 +233,8 @@ class AccountReconcilor : public KeyedService,
} }
// Register and unregister with dependent services. // Register and unregister with dependent services.
void RegisterWithAllDependencies();
void UnregisterWithAllDependencies();
void RegisterWithIdentityManager(); void RegisterWithIdentityManager();
void UnregisterWithIdentityManager(); void UnregisterWithIdentityManager();
void RegisterWithCookieManagerService(); void RegisterWithCookieManagerService();
......
...@@ -63,6 +63,13 @@ MirrorAccountReconcilorDelegate::GetChromeAccountsForReconcile( ...@@ -63,6 +63,13 @@ MirrorAccountReconcilorDelegate::GetChromeAccountsForReconcile(
void MirrorAccountReconcilorDelegate::OnPrimaryAccountSet( void MirrorAccountReconcilorDelegate::OnPrimaryAccountSet(
const AccountInfo& primary_account_info) { const AccountInfo& primary_account_info) {
if (!IsReconcileEnabled()) {
// AccountReconcilor::EnableReconcile DCHECKs for
// |AccountReconcilorDelegate::IsReconcileEnabled|. Subclasses may have
// overridden |AccountReconcilorDelegate::IsReconcileEnabled|. Check that to
// be sure.
return;
}
reconcilor()->EnableReconcile(); reconcilor()->EnableReconcile();
} }
......
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