Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7513)

Unified Diff: chrome/browser/webdata/autofill_profile_syncable_service.cc

Issue 12476031: Refactor notifications of chrome/browser/webdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/webdata/autofill_profile_syncable_service.cc
diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.cc b/chrome/browser/webdata/autofill_profile_syncable_service.cc
index 967a793701ccb5bfb4f6bacfcd356e6b3bd9a070..0453abdd0e044b04273ab8aa5d23002163a77ad1 100644
--- a/chrome/browser/webdata/autofill_profile_syncable_service.cc
+++ b/chrome/browser/webdata/autofill_profile_syncable_service.cc
@@ -12,12 +12,9 @@
#include "chrome/browser/webdata/autofill_table.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_database.h"
-#include "chrome/common/chrome_notification_types.h"
#include "components/autofill/browser/autofill_profile.h"
#include "components/autofill/browser/form_group.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_source.h"
#include "sync/api/sync_error.h"
#include "sync/api/sync_error_factory.h"
#include "sync/protocol/sync.pb.h"
@@ -42,14 +39,13 @@ AutofillProfileSyncableService::AutofillProfileSyncableService(
: web_data_service_(web_data_service) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
DCHECK(web_data_service_);
- notification_registrar_.Add(
- this,
- chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
- content::Source<WebDataService>(web_data_service_));
+ web_data_service_->AddObserver(this);
}
AutofillProfileSyncableService::~AutofillProfileSyncableService() {
DCHECK(CalledOnValidThread());
+ if (web_data_service_)
+ web_data_service_->RemoveObserver(this);
}
AutofillProfileSyncableService::AutofillProfileSyncableService()
@@ -238,21 +234,14 @@ syncer::SyncError AutofillProfileSyncableService::ProcessSyncChanges(
return syncer::SyncError();
}
-void AutofillProfileSyncableService::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(type, chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED);
- DCHECK_EQ(web_data_service_, content::Source<WebDataService>(source).ptr());
+void AutofillProfileSyncableService::AutofillProfileChanged(
+ const AutofillProfileChange& change) {
// 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_.get())
- return;
-
- AutofillProfileChange* change =
- content::Details<AutofillProfileChange>(details).ptr();
- ActOnChange(*change);
+ if (sync_processor_.get())
+ ActOnChange(change);
}
bool AutofillProfileSyncableService::LoadAutofillData(

Powered by Google App Engine
This is Rietveld 408576698