summaryrefslogtreecommitdiffstats
path: root/chrome/browser/webdata
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 /chrome/browser/webdata
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
Diffstat (limited to 'chrome/browser/webdata')
-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
4 files changed, 27 insertions, 35 deletions
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.