Commit be7410fa authored by maxbogue's avatar maxbogue Committed by Commit bot

[Sync] Remove the last datatype-specific deps from sync_driver.

The ref-counted dependencies being injected by SyncClient are now
injected directly into the DTC's via the components factory.

BUG=543199
TBR=sdefresne

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

Cr-Commit-Position: refs/heads/master@{#364465}
parent 29cf7820
......@@ -182,6 +182,13 @@ ChromeSyncClient::~ChromeSyncClient() {
void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
web_data_service_ = WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
// TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here?
password_store_ = PasswordStoreFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
// Component factory may already be set in tests.
if (!GetSyncApiComponentFactory()) {
const GURL sync_service_url = GetSyncServiceURL(
......@@ -200,11 +207,10 @@ void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) {
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::DB),
token_service, url_request_context_getter));
token_service, url_request_context_getter, web_data_service_,
password_store_));
}
sync_service_ = sync_service;
web_data_service_ = GetWebDataService();
password_store_ = GetPasswordStore();
}
sync_driver::SyncService* ChromeSyncClient::GetSyncService() {
......@@ -241,13 +247,6 @@ autofill::PersonalDataManager* ChromeSyncClient::GetPersonalDataManager() {
return autofill::PersonalDataManagerFactory::GetForProfile(profile_);
}
scoped_refptr<password_manager::PasswordStore>
ChromeSyncClient::GetPasswordStore() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return PasswordStoreFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
}
sync_driver::ClearBrowsingDataCallback
ChromeSyncClient::GetClearBrowsingDataCallback() {
return base::Bind(&ChromeSyncClient::ClearBrowsingData,
......@@ -271,13 +270,6 @@ ChromeSyncClient::GetRegisterPlatformTypesCallback() {
weak_ptr_factory_.GetWeakPtr());
}
scoped_refptr<autofill::AutofillWebDataService>
ChromeSyncClient::GetWebDataService() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
}
BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() {
return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_);
}
......@@ -454,11 +446,9 @@ ChromeSyncClient::CreateModelWorkerForGroup(
observer);
}
case syncer::GROUP_PASSWORD: {
scoped_refptr<password_manager::PasswordStore> password_store =
GetPasswordStore();
if (!password_store.get())
if (!password_store_.get())
return nullptr;
return new PasswordModelWorker(password_store, observer);
return new PasswordModelWorker(password_store_, observer);
}
default:
return nullptr;
......
......@@ -12,6 +12,14 @@
class Profile;
namespace autofill {
class AutofillWebDataService;
}
namespace password_manager {
class PasswordStore;
}
namespace sync_driver {
class SyncApiComponentFactory;
class SyncService;
......@@ -31,7 +39,6 @@ class ChromeSyncClient : public sync_driver::SyncClient {
bookmarks::BookmarkModel* GetBookmarkModel() override;
favicon::FaviconService* GetFaviconService() override;
history::HistoryService* GetHistoryService() override;
scoped_refptr<password_manager::PasswordStore> GetPasswordStore() override;
sync_driver::ClearBrowsingDataCallback GetClearBrowsingDataCallback()
override;
base::Closure GetPasswordStateChangedCallback() override;
......@@ -39,7 +46,6 @@ class ChromeSyncClient : public sync_driver::SyncClient {
GetRegisterPlatformTypesCallback() override;
autofill::PersonalDataManager* GetPersonalDataManager() override;
invalidation::InvalidationService* GetInvalidationService() override;
scoped_refptr<autofill::AutofillWebDataService> GetWebDataService() override;
BookmarkUndoService* GetBookmarkUndoServiceIfExists() override;
scoped_refptr<syncer::ExtensionsActivity> GetExtensionsActivity() override;
sync_sessions::SyncSessionsClient* GetSyncSessionsClient() override;
......
......@@ -163,9 +163,6 @@ class TestSyncClient : public sync_driver::FakeSyncClient {
DCHECK(sync_service_);
return sync_service_;
}
scoped_refptr<autofill::AutofillWebDataService> GetWebDataService() override {
return web_data_service_;
}
base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
syncer::ModelType type) override {
DCHECK(type == AUTOFILL || type == AUTOFILL_PROFILE);
......@@ -680,12 +677,12 @@ class ProfileSyncServiceAutofillTest
return new AutofillDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
base::Bind(&base::DoNothing), sync_client_.get());
base::Bind(&base::DoNothing), sync_client_.get(), web_data_service_);
} else {
return new AutofillProfileDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
base::Bind(&base::DoNothing), sync_client_.get());
base::Bind(&base::DoNothing), sync_client_.get(), web_data_service_);
}
}
......
......@@ -21,13 +21,15 @@ AutofillWalletDataTypeController::AutofillWalletDataTypeController(
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
const base::Closure& error_callback,
sync_driver::SyncClient* sync_client,
syncer::ModelType model_type)
syncer::ModelType model_type,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service)
: NonUIDataTypeController(ui_thread, error_callback, sync_client),
ui_thread_(ui_thread),
db_thread_(db_thread),
sync_client_(sync_client),
callback_registered_(false),
model_type_(model_type),
web_data_service_(web_data_service),
currently_enabled_(IsEnabled()) {
DCHECK(ui_thread_->BelongsToCurrentThread());
DCHECK(model_type_ == syncer::AUTOFILL_WALLET_DATA ||
......@@ -65,17 +67,14 @@ bool AutofillWalletDataTypeController::StartModels() {
DCHECK(ui_thread_->BelongsToCurrentThread());
DCHECK_EQ(state(), MODEL_STARTING);
scoped_refptr<autofill::AutofillWebDataService> web_data_service =
sync_client_->GetWebDataService();
if (!web_data_service)
if (!web_data_service_)
return false;
if (web_data_service->IsDatabaseLoaded())
if (web_data_service_->IsDatabaseLoaded())
return true;
if (!callback_registered_) {
web_data_service->RegisterDBLoadedCallback(
web_data_service_->RegisterDBLoadedCallback(
base::Bind(&AutofillWalletDataTypeController::OnModelLoaded, this));
callback_registered_ = true;
}
......
......@@ -9,6 +9,10 @@
#include "base/prefs/pref_change_registrar.h"
#include "components/sync_driver/non_ui_data_type_controller.h"
namespace autofill {
class AutofillWebDataService;
}
namespace browser_sync {
// Controls syncing of either AUTOFILL_WALLET or AUTOFILL_WALLET_METADATA.
......@@ -21,7 +25,8 @@ class AutofillWalletDataTypeController
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
const base::Closure& error_callback,
sync_driver::SyncClient* sync_client,
syncer::ModelType model_type);
syncer::ModelType model_type,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service);
// NonUIDataTypeController implementation.
syncer::ModelType type() const override;
......@@ -50,10 +55,18 @@ class AutofillWalletDataTypeController
// A reference to the DB thread's task runner.
const scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
// A pointer to the sync client.
sync_driver::SyncClient* const sync_client_;
// Whether the database loaded callback has been registered.
bool callback_registered_;
// The model type for this DTC; can be AUTOFILL_WALLET_DATA or _METADATA.
syncer::ModelType model_type_;
// A reference to the AutofillWebDataService for this controller.
scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
// Stores whether we're currently syncing wallet data. This is the last
// value computed by IsEnabled.
bool currently_enabled_;
......
......@@ -18,10 +18,12 @@ AutofillDataTypeController::AutofillDataTypeController(
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
const base::Closure& error_callback,
sync_driver::SyncClient* sync_client)
sync_driver::SyncClient* sync_client,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service)
: NonUIDataTypeController(ui_thread, error_callback, sync_client),
sync_client_(sync_client),
db_thread_(db_thread) {}
db_thread_(db_thread),
web_data_service_(web_data_service) {}
syncer::ModelType AutofillDataTypeController::type() const {
return syncer::AUTOFILL;
......@@ -53,16 +55,13 @@ bool AutofillDataTypeController::StartModels() {
DCHECK(ui_thread()->BelongsToCurrentThread());
DCHECK_EQ(MODEL_STARTING, state());
scoped_refptr<autofill::AutofillWebDataService> web_data_service =
sync_client_->GetWebDataService();
if (!web_data_service)
if (!web_data_service_)
return false;
if (web_data_service->IsDatabaseLoaded()) {
if (web_data_service_->IsDatabaseLoaded()) {
return true;
} else {
web_data_service->RegisterDBLoadedCallback(
web_data_service_->RegisterDBLoadedCallback(
base::Bind(&AutofillDataTypeController::WebDatabaseLoaded, this));
return false;
}
......
......@@ -26,7 +26,8 @@ class AutofillDataTypeController : public sync_driver::NonUIDataTypeController {
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
const base::Closure& error_callback,
sync_driver::SyncClient* sync_client);
sync_driver::SyncClient* sync_client,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service);
// NonUIDataTypeController implementation.
syncer::ModelType type() const override;
......@@ -52,11 +53,15 @@ class AutofillDataTypeController : public sync_driver::NonUIDataTypeController {
// Callback once WebDatabase has loaded.
void WebDatabaseLoaded();
// A pointer to the sync client.
sync_driver::SyncClient* const sync_client_;
// A reference to the DB thread's task runner.
const scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
// A reference to the AutofillWebDataService for this controller.
scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
DISALLOW_COPY_AND_ASSIGN(AutofillDataTypeController);
};
......
......@@ -62,8 +62,12 @@ class FakeWebDataService : public AutofillWebDataService {
StartSyncableService();
is_database_loaded_ = true;
if (!db_loaded_callback_.is_null())
if (!db_loaded_callback_.is_null()) {
db_loaded_callback_.Run();
// Clear the callback here or the WDS and DTC will have refs to each other
// and create a memory leak.
db_loaded_callback_ = base::Callback<void(void)>();
}
}
bool IsDatabaseLoaded() override { return is_database_loaded_; }
......@@ -102,8 +106,7 @@ class FakeWebDataService : public AutofillWebDataService {
DISALLOW_COPY_AND_ASSIGN(FakeWebDataService);
};
class SyncAutofillDataTypeControllerTest : public testing::Test,
public sync_driver::FakeSyncClient {
class SyncAutofillDataTypeControllerTest : public testing::Test {
public:
SyncAutofillDataTypeControllerTest()
: db_thread_("DB_Thread"),
......@@ -111,18 +114,13 @@ class SyncAutofillDataTypeControllerTest : public testing::Test,
weak_ptr_factory_(this) {}
~SyncAutofillDataTypeControllerTest() override {}
// FakeSyncClient overrides.
scoped_refptr<autofill::AutofillWebDataService> GetWebDataService() override {
return web_data_service_;
}
void SetUp() override {
db_thread_.Start();
web_data_service_ = new FakeWebDataService(
base::ThreadTaskRunnerHandle::Get(), db_thread_.task_runner());
autofill_dtc_ = new AutofillDataTypeController(
base::ThreadTaskRunnerHandle::Get(), db_thread_.task_runner(),
base::Bind(&base::DoNothing), this);
base::Bind(&base::DoNothing), &sync_client_, web_data_service_);
}
void TearDown() override {
......@@ -159,6 +157,7 @@ class SyncAutofillDataTypeControllerTest : public testing::Test,
protected:
base::MessageLoop message_loop_;
base::Thread db_thread_;
sync_driver::FakeSyncClient sync_client_;
scoped_refptr<AutofillDataTypeController> autofill_dtc_;
scoped_refptr<FakeWebDataService> web_data_service_;
......
......@@ -20,12 +20,13 @@ AutofillProfileDataTypeController::AutofillProfileDataTypeController(
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
const base::Closure& error_callback,
sync_driver::SyncClient* sync_client)
sync_driver::SyncClient* sync_client,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service)
: NonUIDataTypeController(ui_thread, error_callback, sync_client),
ui_thread_(ui_thread),
db_thread_(db_thread),
sync_client_(sync_client),
personal_data_(NULL),
web_data_service_(web_data_service),
callback_registered_(false) {}
syncer::ModelType AutofillProfileDataTypeController::type() const {
......@@ -47,16 +48,14 @@ void AutofillProfileDataTypeController::OnPersonalDataChanged() {
DCHECK_EQ(state(), MODEL_STARTING);
sync_client_->GetPersonalDataManager()->RemoveObserver(this);
scoped_refptr<autofill::AutofillWebDataService> web_data_service =
sync_client_->GetWebDataService();
if (!web_data_service)
if (!web_data_service_)
return;
if (web_data_service->IsDatabaseLoaded()) {
if (web_data_service_->IsDatabaseLoaded()) {
OnModelLoaded();
} else if (!callback_registered_) {
web_data_service->RegisterDBLoadedCallback(base::Bind(
web_data_service_->RegisterDBLoadedCallback(base::Bind(
&AutofillProfileDataTypeController::WebDatabaseLoaded, this));
callback_registered_ = true;
}
......@@ -84,17 +83,14 @@ bool AutofillProfileDataTypeController::StartModels() {
return false;
}
scoped_refptr<autofill::AutofillWebDataService> web_data_service =
sync_client_->GetWebDataService();
if (!web_data_service)
if (!web_data_service_)
return false;
if (web_data_service->IsDatabaseLoaded())
if (web_data_service_->IsDatabaseLoaded())
return true;
if (!callback_registered_) {
web_data_service->RegisterDBLoadedCallback(base::Bind(
web_data_service_->RegisterDBLoadedCallback(base::Bind(
&AutofillProfileDataTypeController::WebDatabaseLoaded, this));
callback_registered_ = true;
}
......
......@@ -12,6 +12,7 @@
#include "components/sync_driver/non_ui_data_type_controller.h"
namespace autofill {
class AutofillWebDataService;
class PersonalDataManager;
} // namespace autofill
......@@ -26,7 +27,8 @@ class AutofillProfileDataTypeController
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
const base::Closure& error_callback,
sync_driver::SyncClient* sync_client);
sync_driver::SyncClient* sync_client,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service);
// NonUIDataTypeController:
syncer::ModelType type() const override;
......@@ -54,8 +56,13 @@ class AutofillProfileDataTypeController
// A reference to the DB thread's task runner.
const scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
// A pointer to the sync client.
sync_driver::SyncClient* const sync_client_;
autofill::PersonalDataManager* personal_data_;
// A reference to the AutofillWebDataService for this controller.
scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
// Whether the database loaded callback has been registered.
bool callback_registered_;
DISALLOW_COPY_AND_ASSIGN(AutofillProfileDataTypeController);
......
......@@ -24,6 +24,7 @@
'invalidation_impl',
'invalidation_public',
'keyed_service_core',
'password_manager_core_browser',
'password_manager_sync_browser',
'pref_registry',
'signin_core_browser',
......
......@@ -25,6 +25,7 @@ source_set("browser") {
"//components/invalidation/impl",
"//components/invalidation/public",
"//components/keyed_service/core",
"//components/password_manager/core/browser",
"//components/password_manager/sync/browser",
"//components/pref_registry",
"//components/signin/core/browser",
......
......@@ -4,6 +4,7 @@ include_rules = [
"+components/history/core/browser",
"+components/invalidation",
"+components/keyed_service/core",
"+components/password_manager/core/browser",
"+components/password_manager/sync/browser",
"+components/pref_registry",
"+components/signin/core/browser",
......
......@@ -11,6 +11,7 @@
#include "components/autofill/core/browser/autofill_wallet_data_type_controller.h"
#include "components/autofill/core/browser/webdata/autofill_data_type_controller.h"
#include "components/autofill/core/browser/webdata/autofill_profile_data_type_controller.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/browser_sync/browser/profile_sync_service.h"
......@@ -20,6 +21,7 @@
#include "components/history/core/browser/typed_url_change_processor.h"
#include "components/history/core/browser/typed_url_data_type_controller.h"
#include "components/history/core/browser/typed_url_model_associator.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/sync/browser/password_data_type_controller.h"
#include "components/sync_bookmarks/bookmark_change_processor.h"
#include "components/sync_bookmarks/bookmark_data_type_controller.h"
......@@ -95,7 +97,9 @@ ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
OAuth2TokenService* token_service,
net::URLRequestContextGetter* url_request_context_getter)
net::URLRequestContextGetter* url_request_context_getter,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service,
const scoped_refptr<password_manager::PasswordStore>& password_store)
: sync_client_(sync_client),
channel_(channel),
version_(version),
......@@ -107,6 +111,8 @@ ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
db_thread_(db_thread),
token_service_(token_service),
url_request_context_getter_(url_request_context_getter),
web_data_service_(web_data_service),
password_store_(password_store),
weak_factory_(this) {
DCHECK(token_service_);
DCHECK(url_request_context_getter_);
......@@ -140,8 +146,9 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
// Autofill sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::AUTOFILL)) {
sync_service->RegisterDataTypeController(new AutofillDataTypeController(
ui_thread_, db_thread_, error_callback, sync_client_));
sync_service->RegisterDataTypeController(
new AutofillDataTypeController(ui_thread_, db_thread_, error_callback,
sync_client_, web_data_service_));
}
// Autofill profile sync is enabled by default. Register unless explicitly
......@@ -149,7 +156,8 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) {
sync_service->RegisterDataTypeController(
new AutofillProfileDataTypeController(ui_thread_, db_thread_,
error_callback, sync_client_));
error_callback, sync_client_,
web_data_service_));
}
// Wallet data sync is enabled by default, but behind a syncer experiment
......@@ -159,7 +167,7 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
sync_service->RegisterDataTypeController(
new browser_sync::AutofillWalletDataTypeController(
ui_thread_, db_thread_, error_callback, sync_client_,
syncer::AUTOFILL_WALLET_DATA));
syncer::AUTOFILL_WALLET_DATA, web_data_service_));
}
// Wallet metadata sync depends on Wallet data sync. Register if Wallet data
......@@ -169,7 +177,7 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
sync_service->RegisterDataTypeController(
new browser_sync::AutofillWalletDataTypeController(
ui_thread_, db_thread_, error_callback, sync_client_,
syncer::AUTOFILL_WALLET_METADATA));
syncer::AUTOFILL_WALLET_METADATA, web_data_service_));
}
// Bookmark sync is enabled by default. Register unless explicitly
......@@ -228,7 +236,7 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
if (!disabled_types.Has(syncer::PASSWORDS)) {
sync_service->RegisterDataTypeController(new PasswordDataTypeController(
ui_thread_, error_callback, sync_client_,
sync_client_->GetPasswordStateChangedCallback()));
sync_client_->GetPasswordStateChangedCallback(), password_store_));
}
if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) {
......
......@@ -19,6 +19,14 @@
class OAuth2TokenService;
class Profile;
namespace autofill {
class AutofillWebDataService;
}
namespace password_manager {
class PasswordStore;
}
namespace net {
class URLRequestContextGetter;
}
......@@ -45,7 +53,9 @@ class ProfileSyncComponentsFactoryImpl
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
OAuth2TokenService* token_service,
net::URLRequestContextGetter* url_request_context_getter);
net::URLRequestContextGetter* url_request_context_getter,
const scoped_refptr<autofill::AutofillWebDataService>& web_data_service,
const scoped_refptr<password_manager::PasswordStore>& password_store);
~ProfileSyncComponentsFactoryImpl() override;
// SyncApiComponentFactory implementation:
......@@ -104,6 +114,8 @@ class ProfileSyncComponentsFactoryImpl
const scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
OAuth2TokenService* const token_service_;
net::URLRequestContextGetter* const url_request_context_getter_;
const scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
const scoped_refptr<password_manager::PasswordStore> password_store_;
base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_;
......
......@@ -16,10 +16,12 @@ PasswordDataTypeController::PasswordDataTypeController(
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const base::Closure& error_callback,
sync_driver::SyncClient* sync_client,
const base::Closure& state_changed_callback)
const base::Closure& state_changed_callback,
const scoped_refptr<password_manager::PasswordStore>& password_store)
: NonUIDataTypeController(ui_thread, error_callback, sync_client),
sync_client_(sync_client),
state_changed_callback_(state_changed_callback) {}
state_changed_callback_(state_changed_callback),
password_store_(password_store) {}
syncer::ModelType PasswordDataTypeController::type() const {
return syncer::PASSWORDS;
......@@ -48,7 +50,6 @@ bool PasswordDataTypeController::StartModels() {
OnStateChanged();
password_store_ = sync_client_->GetPasswordStore();
return !!password_store_.get();
}
......
......@@ -30,7 +30,8 @@ class PasswordDataTypeController : public sync_driver::NonUIDataTypeController,
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
const base::Closure& error_callback,
sync_driver::SyncClient* sync_client,
const base::Closure& state_changed_callback);
const base::Closure& state_changed_callback,
const scoped_refptr<password_manager::PasswordStore>& password_store);
// NonFrontendDataTypeController implementation
syncer::ModelType type() const override;
......@@ -50,8 +51,8 @@ class PasswordDataTypeController : public sync_driver::NonUIDataTypeController,
private:
sync_driver::SyncClient* const sync_client_;
scoped_refptr<password_manager::PasswordStore> password_store_;
const base::Closure state_changed_callback_;
scoped_refptr<password_manager::PasswordStore> password_store_;
DISALLOW_COPY_AND_ASSIGN(PasswordDataTypeController);
};
......
......@@ -194,8 +194,6 @@ source_set("test_support") {
deps = [
"//base",
"//components/autofill/core/browser",
"//components/password_manager/core/browser",
"//components/version_info",
"//google_apis",
"//sync:test_support_sync_internal_api",
......
include_rules = [
"+components/autofill/core/browser",
"+components/data_use_measurement/core",
"+components/invalidation",
"+components/os_crypt",
"+components/password_manager/core/browser",
"+components/policy",
"+components/pref_registry",
"+components/signin/core/browser",
......
......@@ -5,8 +5,6 @@
#include "components/sync_driver/fake_sync_client.h"
#include "base/bind.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/sync_driver/fake_sync_service.h"
#include "sync/util/extensions_activity.h"
......@@ -53,11 +51,6 @@ history::HistoryService* FakeSyncClient::GetHistoryService() {
return nullptr;
}
scoped_refptr<password_manager::PasswordStore>
FakeSyncClient::GetPasswordStore() {
return scoped_refptr<password_manager::PasswordStore>();
}
ClearBrowsingDataCallback FakeSyncClient::GetClearBrowsingDataCallback() {
return base::Bind(&DummyClearBrowsingDataCallback);
}
......@@ -75,11 +68,6 @@ autofill::PersonalDataManager* FakeSyncClient::GetPersonalDataManager() {
return nullptr;
}
scoped_refptr<autofill::AutofillWebDataService>
FakeSyncClient::GetWebDataService() {
return scoped_refptr<autofill::AutofillWebDataService>();
}
BookmarkUndoService* FakeSyncClient::GetBookmarkUndoServiceIfExists() {
return nullptr;
}
......
......@@ -24,13 +24,11 @@ class FakeSyncClient : public SyncClient {
bookmarks::BookmarkModel* GetBookmarkModel() override;
favicon::FaviconService* GetFaviconService() override;
history::HistoryService* GetHistoryService() override;
scoped_refptr<password_manager::PasswordStore> GetPasswordStore() override;
ClearBrowsingDataCallback GetClearBrowsingDataCallback() override;
base::Closure GetPasswordStateChangedCallback() override;
sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod
GetRegisterPlatformTypesCallback() override;
autofill::PersonalDataManager* GetPersonalDataManager() override;
scoped_refptr<autofill::AutofillWebDataService> GetWebDataService() override;
BookmarkUndoService* GetBookmarkUndoServiceIfExists() override;
invalidation::InvalidationService* GetInvalidationService() override;
scoped_refptr<syncer::ExtensionsActivity> GetExtensionsActivity() override;
......
......@@ -19,7 +19,6 @@ class BookmarkUndoService;
class PrefService;
namespace autofill {
class AutofillWebDataService;
class AutocompleteSyncableService;
class PersonalDataManager;
} // namespace autofill
......@@ -40,10 +39,6 @@ namespace invalidation {
class InvalidationService;
} // namespace invalidation
namespace password_manager {
class PasswordStore;
} // namespace password_manager
namespace syncer {
class SyncableService;
} // namespace syncer
......@@ -82,7 +77,6 @@ class SyncClient {
virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0;
virtual favicon::FaviconService* GetFaviconService() = 0;
virtual history::HistoryService* GetHistoryService() = 0;
virtual scoped_refptr<password_manager::PasswordStore> GetPasswordStore() = 0;
// Returns a callback that will be invoked when the sync service wishes to
// have browsing data cleared.
......@@ -98,8 +92,6 @@ class SyncClient {
virtual base::Closure GetPasswordStateChangedCallback() = 0;
virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0;
virtual scoped_refptr<autofill::AutofillWebDataService>
GetWebDataService() = 0;
virtual BookmarkUndoService* GetBookmarkUndoServiceIfExists() = 0;
virtual invalidation::InvalidationService* GetInvalidationService() = 0;
virtual scoped_refptr<syncer::ExtensionsActivity> GetExtensionsActivity() = 0;
......
......@@ -134,6 +134,14 @@ IOSChromeSyncClient::~IOSChromeSyncClient() {}
void IOSChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) {
DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
web_data_service_ =
ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState(
browser_state_, ServiceAccessType::EXPLICIT_ACCESS);
// TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here?
password_store_ = IOSChromePasswordStoreFactory::GetForBrowserState(
browser_state_, ServiceAccessType::EXPLICIT_ACCESS);
// Component factory may already be set in tests.
if (!GetSyncApiComponentFactory()) {
const GURL sync_service_url = GetSyncServiceURL(
......@@ -151,11 +159,10 @@ void IOSChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) {
prefs::kSavingBrowserHistoryDisabled, sync_service_url,
web::WebThread::GetTaskRunnerForThread(web::WebThread::UI),
web::WebThread::GetTaskRunnerForThread(web::WebThread::DB),
token_service, url_request_context_getter));
token_service, url_request_context_getter, web_data_service_,
password_store_));
}
sync_service_ = sync_service;
web_data_service_ = GetWebDataService();
password_store_ = GetPasswordStore();
}
sync_driver::SyncService* IOSChromeSyncClient::GetSyncService() {
......@@ -192,14 +199,6 @@ autofill::PersonalDataManager* IOSChromeSyncClient::GetPersonalDataManager() {
return PersonalDataManagerFactory::GetForBrowserState(browser_state_);
}
scoped_refptr<password_manager::PasswordStore>
IOSChromeSyncClient::GetPasswordStore() {
DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
// TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here?
return IOSChromePasswordStoreFactory::GetForBrowserState(
browser_state_, ServiceAccessType::EXPLICIT_ACCESS);
}
sync_driver::ClearBrowsingDataCallback
IOSChromeSyncClient::GetClearBrowsingDataCallback() {
return base::Bind(&IOSChromeSyncClient::ClearBrowsingData,
......@@ -218,13 +217,6 @@ IOSChromeSyncClient::GetRegisterPlatformTypesCallback() {
return sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod();
}
scoped_refptr<autofill::AutofillWebDataService>
IOSChromeSyncClient::GetWebDataService() {
DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
return ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState(
browser_state_, ServiceAccessType::EXPLICIT_ACCESS);
}
BookmarkUndoService* IOSChromeSyncClient::GetBookmarkUndoServiceIfExists() {
return ios::BookmarkUndoServiceFactory::GetForBrowserStateIfExists(
browser_state_);
......@@ -366,11 +358,9 @@ IOSChromeSyncClient::CreateModelWorkerForGroup(
web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), observer);
}
case syncer::GROUP_PASSWORD: {
scoped_refptr<password_manager::PasswordStore> password_store =
GetPasswordStore();
if (!password_store)
if (!password_store_)
return nullptr;
return new browser_sync::PasswordModelWorker(password_store, observer);
return new browser_sync::PasswordModelWorker(password_store_, observer);
}
default:
return nullptr;
......
......@@ -9,10 +9,18 @@
#include "base/memory/weak_ptr.h"
#include "components/sync_driver/sync_client.h"
namespace autofill {
class AutofillWebDataService;
}
namespace ios {
class ChromeBrowserState;
}
namespace password_manager {
class PasswordStore;
}
namespace sync_driver {
class SyncApiComponentFactory;
class SyncService;
......@@ -30,7 +38,6 @@ class IOSChromeSyncClient : public sync_driver::SyncClient {
bookmarks::BookmarkModel* GetBookmarkModel() override;
favicon::FaviconService* GetFaviconService() override;
history::HistoryService* GetHistoryService() override;
scoped_refptr<password_manager::PasswordStore> GetPasswordStore() override;
sync_driver::ClearBrowsingDataCallback GetClearBrowsingDataCallback()
override;
base::Closure GetPasswordStateChangedCallback() override;
......@@ -38,7 +45,6 @@ class IOSChromeSyncClient : public sync_driver::SyncClient {
GetRegisterPlatformTypesCallback() override;
autofill::PersonalDataManager* GetPersonalDataManager() override;
invalidation::InvalidationService* GetInvalidationService() override;
scoped_refptr<autofill::AutofillWebDataService> GetWebDataService() override;
BookmarkUndoService* GetBookmarkUndoServiceIfExists() override;
scoped_refptr<syncer::ExtensionsActivity> GetExtensionsActivity() override;
sync_sessions::SyncSessionsClient* GetSyncSessionsClient() override;
......
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