Chromium Code Reviews| 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 7eb73c424f476b0fc18125d80845a2a5d77f1e6e..dad939b14fff3e0a13a935004b484fb113487b4a 100644 |
| --- a/chrome/browser/sync/glue/autofill_data_type_controller.cc |
| +++ b/chrome/browser/sync/glue/autofill_data_type_controller.cc |
| @@ -13,9 +13,7 @@ |
| #include "chrome/browser/webdata/autocomplete_syncable_service.h" |
| #include "chrome/browser/webdata/web_data_service.h" |
| #include "chrome/browser/webdata/web_data_service_factory.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" |
| @@ -35,24 +33,23 @@ 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(); |
| + |
| OnModelLoaded(); |
| + if (web_data_service_) |
| + web_data_service_->RemoveObserver(this); |
| } |
| AutofillDataTypeController::~AutofillDataTypeController() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + if (web_data_service_) |
| + web_data_service_->RemoveObserver(this); |
|
Jói
2013/03/12 23:27:34
double-checking: this is idempotent, OK to call mo
kaiwang
2013/03/13 04:57:20
Yes, ObserverList supports this:
https://cs.corp.g
|
| } |
| bool AutofillDataTypeController::PostTaskOnBackendThread( |
| @@ -71,9 +68,7 @@ bool AutofillDataTypeController::StartModels() { |
| if (web_data_service_->IsDatabaseLoaded()) { |
| return true; |
| } else { |
| - notification_registrar_.Add( |
| - this, chrome::NOTIFICATION_WEB_DATABASE_LOADED, |
| - content::Source<WebDataService>(web_data_service_.get())); |
| + web_data_service_->AddObserver(this); |
| return false; |
| } |
| } |
| @@ -82,7 +77,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( |