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() {
// 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
// experience than losing Chrome content area Secondary Accounts.
AccountReconcilorFactory::GetForProfile(profile_)->Initialize(
true /* start_reconcile_if_tokens_available */);
AccountReconcilor* account_reconcilor =
AccountReconcilorFactory::GetForProfile(profile_);
account_reconcilor->EnableReconcile();
}
// static
......
......@@ -8,6 +8,7 @@
#include <algorithm>
#include <iterator>
#include <set>
#include <utility>
#include "base/bind.h"
......@@ -218,10 +219,20 @@ AccountReconcilor::~AccountReconcilor() {
DCHECK(!registered_with_identity_manager_);
}
void AccountReconcilor::RegisterWithAllDependencies() {
RegisterWithContentSettings();
RegisterWithIdentityManager();
}
void AccountReconcilor::UnregisterWithAllDependencies() {
UnregisterWithIdentityManager();
UnregisterWithContentSettings();
}
void AccountReconcilor::Initialize(bool start_reconcile_if_tokens_available) {
VLOG(1) << "AccountReconcilor::Initialize";
if (delegate_->IsReconcileEnabled()) {
EnableReconcile();
RegisterWithAllDependencies();
// Start a reconcile if the tokens are already loaded.
if (start_reconcile_if_tokens_available && IsIdentityManagerReady())
......@@ -237,14 +248,17 @@ void AccountReconcilor::SetIsWKHTTPSystemCookieStoreEnabled(bool is_enabled) {
void AccountReconcilor::EnableReconcile() {
DCHECK(delegate_->IsReconcileEnabled());
RegisterWithContentSettings();
RegisterWithIdentityManager();
RegisterWithAllDependencies();
#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) {
AbortReconcile();
UnregisterWithIdentityManager();
UnregisterWithContentSettings();
UnregisterWithAllDependencies();
if (logout_all_accounts)
PerformLogoutAllAccountsAction();
......
......@@ -233,6 +233,8 @@ class AccountReconcilor : public KeyedService,
}
// Register and unregister with dependent services.
void RegisterWithAllDependencies();
void UnregisterWithAllDependencies();
void RegisterWithIdentityManager();
void UnregisterWithIdentityManager();
void RegisterWithCookieManagerService();
......
......@@ -63,6 +63,13 @@ MirrorAccountReconcilorDelegate::GetChromeAccountsForReconcile(
void MirrorAccountReconcilorDelegate::OnPrimaryAccountSet(
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();
}
......
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