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

Unified Diff: chrome/browser/sync/glue/autofill_data_type_controller.cc

Issue 12476031: Refactor notifications of chrome/browser/webdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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/sync/glue/autofill_data_type_controller.cc
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller.cc b/chrome/browser/sync/glue/autofill_data_type_controller.cc
index 313a87f7b6bb4b3811fe9c46119fe2d5cf53cf02..e1c7665bf1635ddbaac676b1fdba7b725afb340d 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller.cc
@@ -12,9 +12,7 @@
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/webdata/autocomplete_syncable_service.h"
#include "chrome/browser/webdata/autofill_web_data_service.h"
-#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_source.h"
#include "sync/api/sync_error.h"
#include "sync/internal_api/public/util/experiments.h"
@@ -34,24 +32,24 @@ syncer::ModelType AutofillDataTypeController::type() const {
return syncer::AUTOFILL;
}
-syncer::ModelSafeGroup AutofillDataTypeController::model_safe_group()
- const {
+syncer::ModelSafeGroup AutofillDataTypeController::model_safe_group() const {
return syncer::GROUP_DB;
}
-void AutofillDataTypeController::Observe(
- int notification_type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void AutofillDataTypeController::WebDatabaseLoaded() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK_EQ(chrome::NOTIFICATION_WEB_DATABASE_LOADED, notification_type);
DCHECK_EQ(MODEL_STARTING, state());
- notification_registrar_.RemoveAll();
+
+ if (web_data_service_)
+ web_data_service_->RemoveObserver(this);
+
OnModelLoaded();
}
AutofillDataTypeController::~AutofillDataTypeController() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (web_data_service_)
+ web_data_service_->RemoveObserver(this);
}
bool AutofillDataTypeController::PostTaskOnBackendThread(
@@ -69,9 +67,7 @@ bool AutofillDataTypeController::StartModels() {
if (web_data_service_->IsDatabaseLoaded()) {
return true;
} else {
- notification_registrar_.Add(
- this, chrome::NOTIFICATION_WEB_DATABASE_LOADED,
- content::Source<AutofillWebDataService>(web_data_service_.get()));
+ web_data_service_->AddObserver(this);
return false;
}
}
@@ -80,7 +76,8 @@ void AutofillDataTypeController::StopModels() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(state() == STOPPING || state() == NOT_RUNNING || state() == DISABLED);
DVLOG(1) << "AutofillDataTypeController::StopModels() : State = " << state();
- notification_registrar_.RemoveAll();
+ if (web_data_service_)
+ web_data_service_->RemoveObserver(this);
}
void AutofillDataTypeController::StartAssociating(

Powered by Google App Engine
This is Rietveld 408576698