summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 03:59:33 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 03:59:33 +0000
commitba81caa32a9949cfed3be94e303ac632a1c5c20c (patch)
treec85fd38b3c0c4c5a728b7a778d7e2207b809da6b
parent9dcdaae34846e064b2fdf173fb1796468a6db816 (diff)
downloadchromium_src-ba81caa32a9949cfed3be94e303ac632a1c5c20c.zip
chromium_src-ba81caa32a9949cfed3be94e303ac632a1c5c20c.tar.gz
chromium_src-ba81caa32a9949cfed3be94e303ac632a1c5c20c.tar.bz2
Reduce dependencies for the AutofillProfileSyncableService
BUG=none TEST=none Review URL: http://codereview.chromium.org/8221028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104844 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/glue/autofill_change_processor.cc3
-rw-r--r--chrome/browser/sync/glue/autofill_model_associator.cc3
-rw-r--r--chrome/browser/sync/glue/autofill_profile_data_type_controller.cc7
-rw-r--r--chrome/browser/sync/profile_sync_factory.h3
-rw-r--r--chrome/browser/sync/profile_sync_factory_impl.cc5
-rw-r--r--chrome/browser/sync/profile_sync_factory_impl.h2
-rw-r--r--chrome/browser/sync/profile_sync_factory_mock.h2
-rw-r--r--chrome/browser/sync/profile_sync_service_autofill_unittest.cc28
-rw-r--r--chrome/browser/webdata/autofill_profile_syncable_service.cc38
-rw-r--r--chrome/browser/webdata/autofill_profile_syncable_service.h12
-rw-r--r--chrome/browser/webdata/web_data_service.cc8
-rw-r--r--chrome/browser/webdata/web_data_service.h4
12 files changed, 54 insertions, 61 deletions
diff --git a/chrome/browser/sync/glue/autofill_change_processor.cc b/chrome/browser/sync/glue/autofill_change_processor.cc
index 0b70639..4f18dcb 100644
--- a/chrome/browser/sync/glue/autofill_change_processor.cc
+++ b/chrome/browser/sync/glue/autofill_change_processor.cc
@@ -295,7 +295,8 @@ void AutofillChangeProcessor::CommitChangesFromSyncModel() {
return;
}
- WebDataService::NotifyOfMultipleAutofillChanges(profile_);
+ WebDataService::NotifyOfMultipleAutofillChanges(
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS));
StartObserving();
}
diff --git a/chrome/browser/sync/glue/autofill_model_associator.cc b/chrome/browser/sync/glue/autofill_model_associator.cc
index 464d940..106cc3a 100644
--- a/chrome/browser/sync/glue/autofill_model_associator.cc
+++ b/chrome/browser/sync/glue/autofill_model_associator.cc
@@ -198,7 +198,8 @@ bool AutofillModelAssociator::AssociateModels(SyncError* error) {
return false;
}
- WebDataService::NotifyOfMultipleAutofillChanges(profile_);
+ WebDataService::NotifyOfMultipleAutofillChanges(
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS));
return true;
}
diff --git a/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc b/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
index a731eea..e387ea4 100644
--- a/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
@@ -25,10 +25,9 @@ void AutofillProfileDataTypeController::CreateSyncComponents() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
ProfileSyncFactory::SyncComponents sync_components =
profile_sync_factory()->
- CreateAutofillProfileSyncComponents(
- profile_sync_service(),
- web_data_service()->GetDatabase(),
- this);
+ CreateAutofillProfileSyncComponents(profile_sync_service(),
+ web_data_service(),
+ this);
set_model_associator(sync_components.model_associator);
set_change_processor(sync_components.change_processor);
}
diff --git a/chrome/browser/sync/profile_sync_factory.h b/chrome/browser/sync/profile_sync_factory.h
index e4bd347..5b652b0 100644
--- a/chrome/browser/sync/profile_sync_factory.h
+++ b/chrome/browser/sync/profile_sync_factory.h
@@ -20,6 +20,7 @@ class PasswordStore;
class PersonalDataManager;
class ProfileSyncService;
class WebDatabase;
+class WebDataService;
namespace browser_sync {
class DataTypeManager;
@@ -84,7 +85,7 @@ class ProfileSyncFactory {
// by the caller.
virtual SyncComponents CreateAutofillProfileSyncComponents(
ProfileSyncService* profile_sync_service,
- WebDatabase* web_database,
+ WebDataService* web_data_service,
browser_sync::UnrecoverableErrorHandler* error_handler) = 0;
// Instantiates both a model associator and change processor for the
diff --git a/chrome/browser/sync/profile_sync_factory_impl.cc b/chrome/browser/sync/profile_sync_factory_impl.cc
index 7658635..5f093e3 100644
--- a/chrome/browser/sync/profile_sync_factory_impl.cc
+++ b/chrome/browser/sync/profile_sync_factory_impl.cc
@@ -220,11 +220,10 @@ ProfileSyncFactoryImpl::CreateAutofillSyncComponents(
ProfileSyncFactory::SyncComponents
ProfileSyncFactoryImpl::CreateAutofillProfileSyncComponents(
ProfileSyncService* profile_sync_service,
- WebDatabase* web_database,
+ WebDataService* web_data_service,
browser_sync::UnrecoverableErrorHandler* error_handler) {
AutofillProfileSyncableService* sync_service =
- new AutofillProfileSyncableService(web_database,
- profile_sync_service->profile());
+ new AutofillProfileSyncableService(web_data_service);
sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
GenericChangeProcessor* change_processor =
new GenericChangeProcessor(sync_service, error_handler, user_share);
diff --git a/chrome/browser/sync/profile_sync_factory_impl.h b/chrome/browser/sync/profile_sync_factory_impl.h
index cab83cf..5d8873b 100644
--- a/chrome/browser/sync/profile_sync_factory_impl.h
+++ b/chrome/browser/sync/profile_sync_factory_impl.h
@@ -41,7 +41,7 @@ class ProfileSyncFactoryImpl : public ProfileSyncFactory {
virtual SyncComponents CreateAutofillProfileSyncComponents(
ProfileSyncService* profile_sync_service,
- WebDatabase* web_database,
+ WebDataService* web_data_service,
browser_sync::UnrecoverableErrorHandler* error_handler);
virtual SyncComponents CreateBookmarkSyncComponents(
diff --git a/chrome/browser/sync/profile_sync_factory_mock.h b/chrome/browser/sync/profile_sync_factory_mock.h
index 2fb8e12..5bb5445 100644
--- a/chrome/browser/sync/profile_sync_factory_mock.h
+++ b/chrome/browser/sync/profile_sync_factory_mock.h
@@ -44,7 +44,7 @@ class ProfileSyncFactoryMock : public ProfileSyncFactory {
MOCK_METHOD3(CreateAutofillProfileSyncComponents,
SyncComponents(
ProfileSyncService* profile_sync_service,
- WebDatabase* web_database,
+ WebDataService* web_data_service,
browser_sync::UnrecoverableErrorHandler* error_handler));
MOCK_METHOD2(CreateBookmarkSyncComponents,
SyncComponents(ProfileSyncService* profile_sync_service,
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index d196ce4..b099148 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -179,12 +179,12 @@ ACTION_P3(MakeAutofillSyncComponents, service, wd, dtc) {
change_processor);
}
-ACTION_P3(MakeAutofillProfileSyncComponents, service, wd, dtc) {
+ACTION_P3(MakeAutofillProfileSyncComponents, service, wds, dtc) {
EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
if (!BrowserThread::CurrentlyOn(BrowserThread::DB))
return ProfileSyncFactory::SyncComponents(NULL, NULL);
AutofillProfileSyncableService* sync_service =
- new AutofillProfileSyncableService(wd, service->profile());
+ new AutofillProfileSyncableService(wds);
sync_api::UserShare* user_share = service->GetUserShare();
GenericChangeProcessor* change_processor =
new GenericChangeProcessor(sync_service, dtc, user_share);
@@ -203,9 +203,9 @@ class AbstractAutofillFactory {
ProfileMock* profile,
ProfileSyncService* service) = 0;
virtual void SetExpectation(ProfileSyncFactoryMock* factory,
- ProfileSyncService* service,
- WebDatabase* wd,
- DataTypeController* dtc) = 0;
+ ProfileSyncService* service,
+ WebDataService* wds,
+ DataTypeController* dtc) = 0;
virtual ~AbstractAutofillFactory() {}
};
@@ -220,11 +220,11 @@ class AutofillEntryFactory : public AbstractAutofillFactory {
}
void SetExpectation(ProfileSyncFactoryMock* factory,
- ProfileSyncService* service,
- WebDatabase* wd,
- DataTypeController* dtc) {
+ ProfileSyncService* service,
+ WebDataService* wds,
+ DataTypeController* dtc) {
EXPECT_CALL(*factory, CreateAutofillSyncComponents(_,_,_)).
- WillOnce(MakeAutofillSyncComponents(service, wd, dtc));
+ WillOnce(MakeAutofillSyncComponents(service, wds->GetDatabase(), dtc));
}
};
@@ -239,11 +239,11 @@ class AutofillProfileFactory : public AbstractAutofillFactory {
}
void SetExpectation(ProfileSyncFactoryMock* factory,
- ProfileSyncService* service,
- WebDatabase* wd,
- DataTypeController* dtc) {
+ ProfileSyncService* service,
+ WebDataService* wds,
+ DataTypeController* dtc) {
EXPECT_CALL(*factory, CreateAutofillProfileSyncComponents(_,_,_)).
- WillOnce(MakeAutofillProfileSyncComponents(service, wd, dtc));
+ WillOnce(MakeAutofillProfileSyncComponents(service, wds, dtc));
}
};
@@ -325,7 +325,7 @@ class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest {
factory->SetExpectation(&factory_,
service_.get(),
- web_database_.get(),
+ web_data_service_.get(),
data_type_controller);
EXPECT_CALL(factory_, CreateDataTypeManager(_, _)).
diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.cc b/chrome/browser/webdata/autofill_profile_syncable_service.cc
index cf94ea2..8dfe601 100644
--- a/chrome/browser/webdata/autofill_profile_syncable_service.cc
+++ b/chrome/browser/webdata/autofill_profile_syncable_service.cc
@@ -39,18 +39,14 @@ namespace browser_sync {
const char kAutofillProfileTag[] = "google_chrome_autofill_profiles";
AutofillProfileSyncableService::AutofillProfileSyncableService(
- WebDatabase* web_database,
- Profile* profile)
- : web_database_(web_database),
- profile_(profile),
+ WebDataService* web_data_service)
+ : web_data_service_(web_data_service),
sync_processor_(NULL) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
- DCHECK(web_database_);
- DCHECK(profile);
+ DCHECK(web_data_service_);
notification_registrar_.Add(this,
- chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
- Source<WebDataService>(
- profile_->GetWebDataService(Profile::EXPLICIT_ACCESS)));
+ chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
+ Source<WebDataService>(web_data_service_));
}
AutofillProfileSyncableService::~AutofillProfileSyncableService() {
@@ -58,8 +54,7 @@ AutofillProfileSyncableService::~AutofillProfileSyncableService() {
}
AutofillProfileSyncableService::AutofillProfileSyncableService()
- : web_database_(NULL),
- profile_(NULL),
+ : web_data_service_(NULL),
sync_processor_(NULL) {
}
@@ -120,7 +115,7 @@ SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing(
SyncError error = sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
- WebDataService::NotifyOfMultipleAutofillChanges(profile_);
+ WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_);
return error;
}
@@ -188,7 +183,7 @@ SyncError AutofillProfileSyncableService::ProcessSyncChanges(
if (!SaveChangesToWebData(bundle))
return SyncError(FROM_HERE, "Failed to update webdata.", model_type());
- WebDataService::NotifyOfMultipleAutofillChanges(profile_);
+ WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_);
return SyncError();
}
@@ -197,24 +192,21 @@ void AutofillProfileSyncableService::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK_EQ(type, chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED);
+ DCHECK_EQ(web_data_service_, Source<WebDataService>(source).ptr());
// Check if sync is on. If we receive notification prior to the sync being set
// up we are going to process all when MergeData..() is called. If we receive
// notification after the sync exited, it will be sinced next time Chrome
// starts.
if (!sync_processor_)
return;
- WebDataService* wds = Source<WebDataService>(source).ptr();
-
- DCHECK(wds && wds->GetDatabase() == web_database_);
AutofillProfileChange* change = Details<AutofillProfileChange>(details).ptr();
-
ActOnChange(*change);
}
bool AutofillProfileSyncableService::LoadAutofillData(
std::vector<AutofillProfile*>* profiles) {
- return web_database_->GetAutofillTable()->GetAutofillProfiles(profiles);
+ return GetAutofillTable()->GetAutofillProfiles(profiles);
}
bool AutofillProfileSyncableService::SaveChangesToWebData(
@@ -222,19 +214,19 @@ bool AutofillProfileSyncableService::SaveChangesToWebData(
DCHECK(CalledOnValidThread());
for (size_t i = 0; i < bundle.profiles_to_add.size(); i++) {
- if (!web_database_->GetAutofillTable()->AddAutofillProfile(
+ if (!GetAutofillTable()->AddAutofillProfile(
*bundle.profiles_to_add[i]))
return false;
}
for (size_t i = 0; i < bundle.profiles_to_update.size(); i++) {
- if (!web_database_->GetAutofillTable()->UpdateAutofillProfile(
+ if (!GetAutofillTable()->UpdateAutofillProfile(
*bundle.profiles_to_update[i]))
return false;
}
for (size_t i = 0; i< bundle.profiles_to_delete.size(); ++i) {
- if (!web_database_->GetAutofillTable()->RemoveAutofillProfile(
+ if (!GetAutofillTable()->RemoveAutofillProfile(
bundle.profiles_to_delete[i]))
return false;
}
@@ -408,6 +400,10 @@ SyncData AutofillProfileSyncableService::CreateData(
return SyncData::CreateLocalData(profile.guid(), profile.guid(), specifics);
}
+AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const {
+ return web_data_service_->GetDatabase()->GetAutofillTable();
+}
+
AutofillProfileSyncableService::DataBundle::DataBundle() {}
AutofillProfileSyncableService::DataBundle::~DataBundle() {
diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.h b/chrome/browser/webdata/autofill_profile_syncable_service.h
index 74397b9..77ef314 100644
--- a/chrome/browser/webdata/autofill_profile_syncable_service.h
+++ b/chrome/browser/webdata/autofill_profile_syncable_service.h
@@ -25,10 +25,9 @@
#include "content/common/notification_registrar.h"
class AutofillProfile;
-class Profile;
+class AutofillTable;
class ProfileSyncServiceAutofillTest;
-
-class WebDatabase;
+class WebDataService;
namespace browser_sync {
@@ -45,7 +44,7 @@ class AutofillProfileSyncableService
public NotificationObserver,
public base::NonThreadSafe {
public:
- AutofillProfileSyncableService(WebDatabase* web_database, Profile* profile);
+ explicit AutofillProfileSyncableService(WebDataService* web_data_service);
virtual ~AutofillProfileSyncableService();
static syncable::ModelType model_type() { return syncable::AUTOFILL_PROFILE; }
@@ -126,14 +125,15 @@ class AutofillProfileSyncableService
// Creates SyncData based on supplied |profile|.
static SyncData CreateData(const AutofillProfile& profile);
+ AutofillTable* GetAutofillTable() const;
+
// For unit-tests.
AutofillProfileSyncableService();
void set_sync_processor(SyncChangeProcessor* sync_processor) {
sync_processor_ = sync_processor;
}
- WebDatabase* web_database_;
- Profile* profile_;
+ WebDataService* web_data_service_; // WEAK
NotificationRegistrar notification_registrar_;
// Cached Autofill profiles. *Warning* deleted profiles are still in the
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index 35fed88..80fae632 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -81,14 +81,10 @@ WebDataService::WebDataService()
}
// static
-void WebDataService::NotifyOfMultipleAutofillChanges(Profile* profile) {
+void WebDataService::NotifyOfMultipleAutofillChanges(
+ WebDataService* web_data_service) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
- if (!profile)
- return;
-
- WebDataService* web_data_service =
- profile->GetWebDataService(Profile::EXPLICIT_ACCESS);
if (!web_data_service)
return;
diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h
index b5faa9e..98c5d0a 100644
--- a/chrome/browser/webdata/web_data_service.h
+++ b/chrome/browser/webdata/web_data_service.h
@@ -277,8 +277,8 @@ class WebDataService
// to Autofill records of the database.
// NOTE: This method is intended to be called from the DB thread. It
// it asynchronously notifies listeners on the UI thread.
- // |profile| may be NULL for testing purposes.
- static void NotifyOfMultipleAutofillChanges(Profile* profile);
+ // |web_data_service| may be NULL for testing purposes.
+ static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service);
// Initializes the web data service. Returns false on failure
// Takes the path of the profile directory as its argument.