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

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

Issue 23710022: Convert NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED to CallbackList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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/search_engine_data_type_controller.cc
diff --git a/chrome/browser/sync/glue/search_engine_data_type_controller.cc b/chrome/browser/sync/glue/search_engine_data_type_controller.cc
index 9718b23ccdb54638e3e523f1cc4334e65e7772b0..351fe6d7dfd41aa8fc5a828b32699542db72d65c 100644
--- a/chrome/browser/sync/glue/search_engine_data_type_controller.cc
+++ b/chrome/browser/sync/glue/search_engine_data_type_controller.cc
@@ -5,13 +5,10 @@
#include "chrome/browser/sync/glue/search_engine_data_type_controller.h"
#include "base/metrics/histogram.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
-#include "content/public/browser/notification_source.h"
#include "sync/api/syncable_service.h"
using content::BrowserThread;
@@ -28,17 +25,6 @@ SearchEngineDataTypeController::SearchEngineDataTypeController(
sync_service) {
}
-void SearchEngineDataTypeController::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK_EQ(chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, type);
- registrar_.RemoveAll();
- DCHECK_EQ(state_, MODEL_STARTING);
- OnModelLoaded();
-}
-
SearchEngineDataTypeController::~SearchEngineDataTypeController() {}
// We want to start the TemplateURLService before we begin associating.
@@ -54,15 +40,19 @@ bool SearchEngineDataTypeController::StartModels() {
return true; // Continue to Associate().
}
- // Add an observer and continue when the TemplateURLService is loaded.
- registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
- content::Source<TemplateURLService>(turl_service));
+ // Register a callback and continue when the TemplateURLService is loaded.
+ template_url_subscription_ = turl_service->RegisterOnLoadedCallback(
+ base::Bind(&SearchEngineDataTypeController::OnTemplateURLServiceLoaded,
+ this));
+
return false; // Don't continue Start.
}
-// Cleanup for our extra registrar usage.
-void SearchEngineDataTypeController::StopModels() {
- registrar_.RemoveAll();
+void SearchEngineDataTypeController::OnTemplateURLServiceLoaded() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_EQ(state_, MODEL_STARTING);
+ template_url_subscription_.reset();
+ OnModelLoaded();
}
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698