Commit d594dc5f authored by rogerm's avatar rogerm Committed by Commit bot

Run autofill-profile de-dupe after sync starts if sync is enabled.

This CL updates the PersonalDataManager to run autofill profile
de-duplication (if enabled) at the appropriate time, depending on
whether autofill profile sync is enabled.

If sync is not enabled, profile de-duplication is run after the
data is initially loaded.

If sync is enabled, profild de-duplication is run after the sync
first becomes active.

In all cases, de-duplication is only run once for a given version
of chromium.

BUG=627519
R=sebsg@chromium.org, mathp@chromium.org

Review-Url: https://codereview.chromium.org/2142123002
Cr-Commit-Position: refs/heads/master@{#406026}
parent 010756d2
......@@ -214,6 +214,8 @@ AutofillManager::AutofillManager(
download_manager_.reset(new AutofillDownloadManager(driver, this));
}
CountryNames::SetLocaleString(app_locale_);
if (personal_data_ && client_)
personal_data_->OnSyncServiceInitialized(client_->GetSyncService());
}
AutofillManager::~AutofillManager() {}
......
......@@ -446,6 +446,8 @@ bool AutofillProfile::MergeDataFrom(const AutofillProfile& profile,
PhoneNumber phone_number(this);
Address address;
DVLOG(1) << "Merging profiles:\nSource = " << profile << "\nDest = " << *this;
// The comparator's merge operations are biased to prefer the data in the
// first profile parameter when the data is the same modulo case. We pass the
// incoming profile in this position to prefer accepting updates instead of
......
......@@ -135,10 +135,35 @@ bool AutofillProfileComparator::AreMergeable(const AutofillProfile& p1,
const AutofillProfile& p2) const {
// Sorted in order to relative expense of the tests to fail early and cheaply
// if possible.
return HaveMergeableEmailAddresses(p1, p2) &&
HaveMergeableCompanyNames(p1, p2) &&
HaveMergeablePhoneNumbers(p1, p2) && HaveMergeableNames(p1, p2) &&
HaveMergeableAddresses(p1, p2);
DVLOG(1) << "Comparing profiles:\np1 = " << p1 << "\np2 = " << p2;
if (!HaveMergeableEmailAddresses(p1, p2)) {
DVLOG(1) << "Different email addresses.";
return false;
}
if (!HaveMergeableCompanyNames(p1, p2)) {
DVLOG(1) << "Different email company names.";
return false;
}
if (!HaveMergeablePhoneNumbers(p1, p2)) {
DVLOG(1) << "Different phone numbers.";
return false;
}
if (!HaveMergeableNames(p1, p2)) {
DVLOG(1) << "Different names.";
return false;
}
if (!HaveMergeableAddresses(p1, p2)) {
DVLOG(1) << "Different addresses.";
return false;
}
DVLOG(1) << "Profiles are mergeable.";
return true;
}
bool AutofillProfileComparator::MergeNames(const AutofillProfile& p1,
......@@ -299,10 +324,10 @@ bool AutofillProfileComparator::MergePhoneNumbers(
std::string new_number;
phone_util->Format(merged_number, format, &new_number);
VLOG(1) << "n1 = {" << n1 << "}";
VLOG(1) << "n2 = {" << n2 << "}";
VLOG(1) << "merged_number = {" << merged_number << "}";
VLOG(1) << "new_number = \"" << new_number << "\"";
DVLOG(2) << "n1 = {" << n1 << "}";
DVLOG(2) << "n2 = {" << n2 << "}";
DVLOG(2) << "merged_number = {" << merged_number << "}";
DVLOG(2) << "new_number = \"" << new_number << "\"";
// Check if it's a North American number that's missing the area code.
// Libphonenumber doesn't know how to format short numbers; it will still
......
......@@ -39,6 +39,7 @@
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/common/signin_pref_names.h"
#include "components/sync_driver/sync_service.h"
#include "components/variations/variations_associated_data.h"
#include "components/version_info/version_info.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h"
......@@ -287,6 +288,7 @@ void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database,
LoadCreditCards();
database_->AddObserver(this);
is_autofill_profile_dedupe_pending_ = IsAutofillProfileCleanupEnabled();
}
PersonalDataManager::~PersonalDataManager() {
......@@ -299,6 +301,27 @@ PersonalDataManager::~PersonalDataManager() {
database_->RemoveObserver(this);
}
void PersonalDataManager::OnSyncServiceInitialized(
sync_driver::SyncService* sync_service) {
// We want to know when, if at all, we need to run autofill profile de-
// duplication: now or after waiting until sync has started.
if (!is_autofill_profile_dedupe_pending_) {
// De-duplication isn't enabled.
return;
}
// If the sync service is configured to start and to sync autofill profiles,
// then we can just let the notification that sync has started trigger the
// de-duplication.
if (sync_service && sync_service->CanSyncStart() &&
sync_service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE)) {
return;
}
// Otherwise, run the de-duplication now.
ApplyDedupingRoutine();
}
void PersonalDataManager::OnWebDataServiceRequestDone(
WebDataServiceBase::Handle h,
const WDTypedResult* result) {
......@@ -326,10 +349,7 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
ReceiveLoadedDbValues(h, result, &pending_profiles_query_,
&web_profiles_);
LogProfileCount(); // This only logs local profiles.
// Since these two routines both re-launch the database queries, don't
// run them on the same query response.
if (!ApplyDedupingRoutine())
ApplyProfileUseDatesFix();
ApplyProfileUseDatesFix();
} else {
ReceiveLoadedDbValues(h, result, &pending_server_profiles_query_,
&server_profiles_);
......@@ -383,6 +403,13 @@ void PersonalDataManager::AutofillMultipleChanged() {
Refresh();
}
void PersonalDataManager::SyncStarted(syncer::ModelType model_type) {
if (model_type == syncer::AUTOFILL_PROFILE &&
is_autofill_profile_dedupe_pending_) {
ApplyDedupingRoutine();
}
}
void PersonalDataManager::AddObserver(PersonalDataManagerObserver* observer) {
observers_.AddObserver(observer);
}
......@@ -1606,16 +1633,22 @@ void PersonalDataManager::ApplyProfileUseDatesFix() {
}
bool PersonalDataManager::ApplyDedupingRoutine() {
if (!IsAutofillProfileCleanupEnabled())
if (!is_autofill_profile_dedupe_pending_)
return false;
int current_major_version = atoi(version_info::GetVersionNumber().c_str());
DCHECK(IsAutofillProfileCleanupEnabled());
is_autofill_profile_dedupe_pending_ = false;
// Check if the deduping routine has already been run on this major version.
int current_major_version = atoi(version_info::GetVersionNumber().c_str());
if (pref_service_->GetInteger(prefs::kAutofillLastVersionDeduped) >=
current_major_version)
current_major_version) {
DVLOG(1)
<< "Autofill profile de-duplication already performed for this version";
return false;
}
DVLOG(1) << "Starting autofill profile de-duplication.";
std::vector<AutofillProfile*> existing_profiles = web_profiles_.get();
std::unordered_set<AutofillProfile*> profiles_to_delete;
profiles_to_delete.reserve(existing_profiles.size());
......
......@@ -36,6 +36,10 @@ class SigninManagerBase;
class PersonalDataManagerFactory;
#endif
namespace sync_driver {
class SyncService;
}
namespace autofill {
class AutofillInteractiveTest;
class AutofillTest;
......@@ -75,12 +79,17 @@ class PersonalDataManager : public KeyedService,
SigninManagerBase* signin_manager,
bool is_off_the_record);
// Called once the sync service is known to be instantiated. Note that it may
// not be started, but it's preferences can be queried.
void OnSyncServiceInitialized(sync_driver::SyncService* sync_service);
// WebDataServiceConsumer:
void OnWebDataServiceRequestDone(WebDataServiceBase::Handle h,
const WDTypedResult* result) override;
// AutofillWebDataServiceObserverOnUIThread:
void AutofillMultipleChanged() override;
void SyncStarted(syncer::ModelType model_type) override;
// Adds a listener to be notified of PersonalDataManager events.
virtual void AddObserver(PersonalDataManagerObserver* observer);
......@@ -484,6 +493,10 @@ class PersonalDataManager : public KeyedService,
// An observer to listen for changes to prefs::kAutofillWalletImportEnabled.
std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_;
// Set to true if autofill profile deduplication is enabled and needs to be
// performed on the next data refresh.
bool is_autofill_profile_dedupe_pending_ = false;
DISALLOW_COPY_AND_ASSIGN(PersonalDataManager);
};
......
......@@ -176,6 +176,7 @@ class PersonalDataManagerTest : public testing::Test {
signin_manager_.get(),
is_incognito);
personal_data_->AddObserver(&personal_data_observer_);
personal_data_->OnSyncServiceInitialized(nullptr);
// Verify that the web database has been updated and the notification sent.
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
......@@ -201,6 +202,7 @@ class PersonalDataManagerTest : public testing::Test {
feature_list->InitializeFromCommandLine(kAutofillProfileCleanup.name,
std::string());
base::FeatureList::SetInstance(std::move(feature_list));
personal_data_->is_autofill_profile_dedupe_pending_ = true;
}
void SetupReferenceProfile() {
......@@ -4601,7 +4603,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MergedProfileValues) {
base::HistogramTester histogram_tester;
personal_data_->ApplyDedupingRoutine();
EXPECT_TRUE(personal_data_->ApplyDedupingRoutine());
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::RunLoop().Run();
......@@ -4694,7 +4696,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_VerifiedProfileFirst) {
base::HistogramTester histogram_tester;
personal_data_->ApplyDedupingRoutine();
EXPECT_TRUE(personal_data_->ApplyDedupingRoutine());
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::RunLoop().Run();
......@@ -4766,7 +4768,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_VerifiedProfileLast) {
base::HistogramTester histogram_tester;
personal_data_->ApplyDedupingRoutine();
EXPECT_TRUE(personal_data_->ApplyDedupingRoutine());
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::RunLoop().Run();
......@@ -4837,7 +4839,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MultipleVerifiedProfiles) {
base::HistogramTester histogram_tester;
personal_data_->ApplyDedupingRoutine();
EXPECT_TRUE(personal_data_->ApplyDedupingRoutine());
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::RunLoop().Run();
......@@ -5067,7 +5069,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MultipleDedupes) {
// |Homer1| should get merged into |Homer2| which should then be merged into
// |Homer3|. |Marge2| should be discarded in favor of |Marge1| which is
// verified. |Homer4| and |Barney| should not be deduped at all.
personal_data_->ApplyDedupingRoutine();
EXPECT_TRUE(personal_data_->ApplyDedupingRoutine());
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::RunLoop().Run();
......
......@@ -158,6 +158,8 @@ syncer::SyncMergeResult AutocompleteSyncableService::MergeDataAndStartSyncing(
// Sync error when that item's deletion is propagated to Sync.
web_data_backend_->RemoveExpiredFormElements();
web_data_backend_->NotifyThatSyncHasStarted(type);
return merge_result;
}
......
......@@ -44,6 +44,7 @@ class NoOpAutofillBackend : public AutofillWebDataBackend {
autofill::AutofillWebDataServiceObserverOnDBThread* observer) override {}
void RemoveExpiredFormElements() override {}
void NotifyOfMultipleAutofillChanges() override {}
void NotifyThatSyncHasStarted(syncer::ModelType /* model_type */) override {}
};
// Fake WebDataService implementation that stubs out the database loading.
......
......@@ -194,8 +194,10 @@ AutofillProfileSyncableService::MergeDataAndStartSyncing(
sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
}
if (webdata_backend_)
if (webdata_backend_) {
webdata_backend_->NotifyOfMultipleAutofillChanges();
webdata_backend_->NotifyThatSyncHasStarted(type);
}
return merge_result;
}
......@@ -550,6 +552,7 @@ AutofillProfileSyncableService::CreateOrUpdateProfile(
// we will merge them.
bundle->candidates_to_merge.insert(
std::make_pair(local_profile->guid(), new_profile));
break;
}
}
profiles_.push_back(new_profile);
......
......@@ -225,7 +225,10 @@ AutofillWalletMetadataSyncableService::MergeDataAndStartSyncing(
cache_ = initial_sync_data;
return MergeData(initial_sync_data);
syncer::SyncMergeResult result = MergeData(initial_sync_data);
if (web_data_backend_)
web_data_backend_->NotifyThatSyncHasStarted(type);
return result;
}
void AutofillWalletMetadataSyncableService::StopSyncing(
......
......@@ -155,6 +155,7 @@ class NoOpWebData : public AutofillWebDataBackend {
AutofillWebDataServiceObserverOnDBThread* observer) override {}
void RemoveExpiredFormElements() override {}
void NotifyOfMultipleAutofillChanges() override {}
void NotifyThatSyncHasStarted(syncer::ModelType /* model_type */) override {}
DISALLOW_COPY_AND_ASSIGN(NoOpWebData);
};
......
......@@ -216,7 +216,10 @@ syncer::SyncMergeResult AutofillWalletSyncableService::MergeDataAndStartSyncing(
std::unique_ptr<syncer::SyncErrorFactory> sync_error_factory) {
DCHECK(thread_checker_.CalledOnValidThread());
sync_processor_ = std::move(sync_processor);
return SetSyncData(initial_sync_data);
syncer::SyncMergeResult result = SetSyncData(initial_sync_data);
if (webdata_backend_)
webdata_backend_->NotifyThatSyncHasStarted(type);
return result;
}
void AutofillWalletSyncableService::StopSyncing(syncer::ModelType type) {
......
......@@ -5,6 +5,8 @@
#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
#include "sync/internal_api/public/base/model_type.h"
class WebDatabase;
namespace autofill {
......@@ -36,6 +38,11 @@ class AutofillWebDataBackend {
// NOTE: This method is intended to be called from the DB thread. The UI
// thread notifications are asynchronous.
virtual void NotifyOfMultipleAutofillChanges() = 0;
// Notifies listeners on the UI thread that sync has started for |model_type|.
// NOTE: This method is intended to be called from the DB thread. The UI
// thread notifications are asynchronous.
virtual void NotifyThatSyncHasStarted(syncer::ModelType model_type) = 0;
};
} // namespace autofill
......
......@@ -29,13 +29,15 @@ AutofillWebDataBackendImpl::AutofillWebDataBackendImpl(
scoped_refptr<WebDatabaseBackend> web_database_backend,
scoped_refptr<base::SingleThreadTaskRunner> ui_thread,
scoped_refptr<base::SingleThreadTaskRunner> db_thread,
const base::Closure& on_changed_callback)
const base::Closure& on_changed_callback,
const base::Callback<void(syncer::ModelType)>& on_sync_started_callback)
: base::RefCountedDeleteOnMessageLoop<AutofillWebDataBackendImpl>(
db_thread),
ui_thread_(ui_thread),
db_thread_(db_thread),
web_database_backend_(web_database_backend),
on_changed_callback_(on_changed_callback) {
on_changed_callback_(on_changed_callback),
on_sync_started_callback_(on_sync_started_callback) {
}
void AutofillWebDataBackendImpl::AddObserver(
......@@ -76,6 +78,18 @@ void AutofillWebDataBackendImpl::NotifyOfMultipleAutofillChanges() {
ui_thread_->PostTask(FROM_HERE, on_changed_callback_);
}
void AutofillWebDataBackendImpl::NotifyThatSyncHasStarted(
syncer::ModelType model_type) {
DCHECK(db_thread_->BelongsToCurrentThread());
if (on_sync_started_callback_.is_null())
return;
// UI thread notification.
ui_thread_->PostTask(FROM_HERE,
base::Bind(on_sync_started_callback_, model_type));
}
base::SupportsUserData* AutofillWebDataBackendImpl::GetDBUserData() {
DCHECK(db_thread_->BelongsToCurrentThread());
if (!user_data_)
......
......@@ -52,7 +52,8 @@ class AutofillWebDataBackendImpl
scoped_refptr<WebDatabaseBackend> web_database_backend,
scoped_refptr<base::SingleThreadTaskRunner> ui_thread,
scoped_refptr<base::SingleThreadTaskRunner> db_thread,
const base::Closure& on_changed_callback);
const base::Closure& on_changed_callback,
const base::Callback<void(syncer::ModelType)>& on_sync_started_callback);
// AutofillWebDataBackend implementation.
void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer) override;
......@@ -61,6 +62,7 @@ class AutofillWebDataBackendImpl
WebDatabase* GetDatabase() override;
void RemoveExpiredFormElements() override;
void NotifyOfMultipleAutofillChanges() override;
void NotifyThatSyncHasStarted(syncer::ModelType model_type) override;
// Returns a SupportsUserData objects that may be used to store data
// owned by the DB thread on this object. Should be called only from
......@@ -224,6 +226,7 @@ class AutofillWebDataBackendImpl
scoped_refptr<WebDatabaseBackend> web_database_backend_;
base::Closure on_changed_callback_;
base::Callback<void(syncer::ModelType)> on_sync_started_callback_;
DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackendImpl);
};
......
......@@ -34,30 +34,34 @@ AutofillWebDataService::AutofillWebDataService(
: WebDataServiceBase(wdbs, callback, ui_thread),
ui_thread_(ui_thread),
db_thread_(db_thread),
autofill_backend_(NULL),
autofill_backend_(nullptr),
weak_ptr_factory_(this) {
base::Closure on_changed_callback = Bind(
&AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread,
weak_ptr_factory_.GetWeakPtr());
base::Callback<void(syncer::ModelType)> on_sync_started_callback = Bind(
&AutofillWebDataService::NotifySyncStartedOnUIThread,
weak_ptr_factory_.GetWeakPtr());
autofill_backend_ = new AutofillWebDataBackendImpl(
wdbs_->GetBackend(), ui_thread_, db_thread_, on_changed_callback);
wdbs_->GetBackend(), ui_thread_, db_thread_, on_changed_callback,
on_sync_started_callback);
}
AutofillWebDataService::AutofillWebDataService(
scoped_refptr<base::SingleThreadTaskRunner> ui_thread,
scoped_refptr<base::SingleThreadTaskRunner> db_thread)
: WebDataServiceBase(NULL,
: WebDataServiceBase(nullptr,
WebDataServiceBase::ProfileErrorCallback(),
ui_thread),
ui_thread_(ui_thread),
db_thread_(db_thread),
autofill_backend_(new AutofillWebDataBackendImpl(NULL,
ui_thread_,
db_thread_,
base::Closure())),
weak_ptr_factory_(this) {
}
autofill_backend_(new AutofillWebDataBackendImpl(
nullptr,
ui_thread_,
db_thread_,
base::Closure(),
base::Callback<void(syncer::ModelType)>())),
weak_ptr_factory_(this) {}
void AutofillWebDataService::ShutdownOnUIThread() {
weak_ptr_factory_.InvalidateWeakPtrs();
......@@ -296,4 +300,12 @@ void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() {
AutofillMultipleChanged());
}
void AutofillWebDataService::NotifySyncStartedOnUIThread(
syncer::ModelType model_type) {
DCHECK(ui_thread_->BelongsToCurrentThread());
FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread,
ui_observer_list_,
SyncStarted(model_type));
}
} // namespace autofill
......@@ -18,6 +18,7 @@
#include "components/webdata/common/web_data_service_base.h"
#include "components/webdata/common/web_data_service_consumer.h"
#include "components/webdata/common/web_database.h"
#include "sync/internal_api/public/base/model_type.h"
class WebDatabaseService;
......@@ -129,6 +130,8 @@ class AutofillWebDataService : public AutofillWebData,
virtual void NotifyAutofillMultipleChangedOnUIThread();
virtual void NotifySyncStartedOnUIThread(syncer::ModelType model_type);
base::WeakPtr<AutofillWebDataService> AsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
......
......@@ -6,6 +6,7 @@
#define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_OBSERVER_H_
#include "components/autofill/core/browser/webdata/autofill_change.h"
#include "sync/internal_api/public/base/model_type.h"
namespace autofill {
......@@ -36,6 +37,9 @@ class AutofillWebDataServiceObserverOnUIThread {
// Sync.
virtual void AutofillMultipleChanged() {}
// Called on UI thread when sync has started for |model_type|.
virtual void SyncStarted(syncer::ModelType /* model_type */) {}
protected:
virtual ~AutofillWebDataServiceObserverOnUIThread() {}
};
......
......@@ -45,6 +45,7 @@
#include "components/sync_driver/data_type_manager_impl.h"
#include "components/sync_driver/sync_api_component_factory_mock.h"
#include "components/syncable_prefs/pref_service_syncable.h"
#include "components/version_info/version_info.h"
#include "components/webdata/common/web_database.h"
#include "components/webdata_services/web_data_service_test_util.h"
#include "sync/internal_api/public/base/model_type.h"
......@@ -100,6 +101,8 @@ void RegisterAutofillPrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, true);
registry->RegisterBooleanPref(autofill::prefs::kAutofillWalletImportEnabled,
true);
registry->RegisterIntegerPref(autofill::prefs::kAutofillLastVersionDeduped,
atoi(version_info::GetVersionNumber().c_str()));
}
void RunAndSignal(const base::Closure& cb, WaitableEvent* event) {
......@@ -169,11 +172,14 @@ class WebDatabaseFake : public WebDatabase {
class MockAutofillBackend : public autofill::AutofillWebDataBackend {
public:
MockAutofillBackend(WebDatabase* web_database,
const base::Closure& on_changed,
const scoped_refptr<base::SequencedTaskRunner>& ui_thread)
MockAutofillBackend(
WebDatabase* web_database,
const base::Closure& on_changed,
const base::Callback<void(syncer::ModelType)>& on_sync_started,
const scoped_refptr<base::SequencedTaskRunner>& ui_thread)
: web_database_(web_database),
on_changed_(on_changed),
on_sync_started_(on_sync_started),
ui_thread_(ui_thread) {}
~MockAutofillBackend() override {}
......@@ -187,10 +193,15 @@ class MockAutofillBackend : public autofill::AutofillWebDataBackend {
DCHECK(!ui_thread_->RunsTasksOnCurrentThread());
ui_thread_->PostTask(FROM_HERE, on_changed_);
}
void NotifyThatSyncHasStarted(syncer::ModelType model_type) override {
DCHECK(!ui_thread_->RunsTasksOnCurrentThread());
ui_thread_->PostTask(FROM_HERE, base::Bind(on_sync_started_, model_type));
}
private:
WebDatabase* web_database_;
base::Closure on_changed_;
base::Callback<void(syncer::ModelType)> on_sync_started_;
const scoped_refptr<base::SequencedTaskRunner> ui_thread_;
};
......@@ -263,10 +274,14 @@ class WebDataServiceFake : public AutofillWebDataService {
const base::Closure& on_changed_callback = base::Bind(
&WebDataServiceFake::NotifyAutofillMultipleChangedOnUIThread,
AsWeakPtr());
const base::Callback<void(syncer::ModelType)> on_sync_started_callback =
base::Bind(&WebDataServiceFake::NotifySyncStartedOnUIThread,
AsWeakPtr());
db_thread_->PostTask(
FROM_HERE, base::Bind(&WebDataServiceFake::CreateSyncableService,
base::Unretained(this), on_changed_callback));
db_thread_->PostTask(FROM_HERE,
base::Bind(&WebDataServiceFake::CreateSyncableService,
base::Unretained(this), on_changed_callback,
on_sync_started_callback));
syncable_service_created_or_destroyed_.Wait();
}
......@@ -312,11 +327,13 @@ class WebDataServiceFake : public AutofillWebDataService {
private:
~WebDataServiceFake() override {}
void CreateSyncableService(const base::Closure& on_changed_callback) {
void CreateSyncableService(
const base::Closure& on_changed_callback,
const base::Callback<void(syncer::ModelType)>& on_sync_started) {
ASSERT_TRUE(db_thread_->RunsTasksOnCurrentThread());
// These services are deleted in DestroySyncableService().
backend_.reset(new MockAutofillBackend(GetDatabase(), on_changed_callback,
ui_thread_.get()));
on_sync_started, ui_thread_.get()));
AutocompleteSyncableService::CreateForWebDataServiceAndBackend(
this, backend_.get());
AutofillProfileSyncableService::CreateForWebDataServiceAndBackend(
......
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