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

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

Issue 12476031: Refactor notifications of chrome/browser/webdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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/autocomplete_syncable_service.cc
diff --git a/chrome/browser/webdata/autocomplete_syncable_service.cc b/chrome/browser/webdata/autocomplete_syncable_service.cc
index f635e60c0a67eca042c5f954956c91017967f2b5..9fca26e8d06fae4cf62dca939276f2ff30524d88 100644
--- a/chrome/browser/webdata/autocomplete_syncable_service.cc
+++ b/chrome/browser/webdata/autocomplete_syncable_service.cc
@@ -11,9 +11,7 @@
#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 "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_service.h"
#include "net/base/escape.h"
#include "sync/api/sync_error.h"
#include "sync/api/sync_error_factory.h"
@@ -87,13 +85,13 @@ AutocompleteSyncableService::AutocompleteSyncableService(
cull_expired_entries_(false) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
DCHECK(web_data_service_);
- notification_registrar_.Add(
- this, chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
- content::Source<WebDataService>(web_data_service));
+ web_data_service_->AddObserver(this);
}
AutocompleteSyncableService::~AutocompleteSyncableService() {
DCHECK(CalledOnValidThread());
+ if (web_data_service_)
+ web_data_service_->RemoveObserver(this);
}
AutocompleteSyncableService::AutocompleteSyncableService()
@@ -277,24 +275,14 @@ syncer::SyncError AutocompleteSyncableService::ProcessSyncChanges(
return list_processing_error;
}
-void AutocompleteSyncableService::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, type);
-
+void AutocompleteSyncableService::AutofillEntriesChanged(
+ const AutofillChangeList& changes) {
// 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;
- WebDataService* wds = content::Source<WebDataService>(source).ptr();
-
- DCHECK_EQ(web_data_service_, wds);
-
- AutofillChangeList* changes =
- content::Details<AutofillChangeList>(details).ptr();
- ActOnChanges(*changes);
+ if (sync_processor_.get())
+ ActOnChanges(changes);
}
bool AutocompleteSyncableService::LoadAutofillData(

Powered by Google App Engine
This is Rietveld 408576698