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

Unified Diff: chrome/browser/search_engines/template_url_service.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/search_engines/template_url_service.cc
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index cca1a36040ee5222592829e7b2df35ae96a7dfa2..c560e8f49ba09f82f7b04f20bc5699042737877e 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -772,10 +772,18 @@ void TemplateURLService::Load() {
load_handle_ = service_->GetKeywords(this);
} else {
ChangeToLoadedState();
- NotifyLoaded();
+ on_loaded_callbacks_.Notify();
}
}
+scoped_ptr<TemplateURLService::Subscription>
+ TemplateURLService::RegisterOnLoadedCallback(
+ const base::Closure& callback) {
+ return loaded_ ?
+ scoped_ptr<TemplateURLService::Subscription>() :
+ on_loaded_callbacks_.Add(callback);
+}
+
void TemplateURLService::OnWebDataServiceRequestDone(
WebDataService::Handle h,
const WDTypedResult* result) {
@@ -788,7 +796,7 @@ void TemplateURLService::OnWebDataServiceRequestDone(
// loaded.
load_failed_ = true;
ChangeToLoadedState();
- NotifyLoaded();
+ on_loaded_callbacks_.Notify();
return;
}
@@ -820,7 +828,7 @@ void TemplateURLService::OnWebDataServiceRequestDone(
EnsureDefaultSearchProviderExists();
NotifyObservers();
- NotifyLoaded();
+ on_loaded_callbacks_.Notify();
}
string16 TemplateURLService::GetKeywordShortName(const string16& keyword,
@@ -1570,13 +1578,6 @@ void TemplateURLService::ChangeToLoadedState() {
loaded_ = true;
}
-void TemplateURLService::NotifyLoaded() {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
- content::Source<TemplateURLService>(this),
- content::NotificationService::NoDetails());
-}
-
void TemplateURLService::SaveDefaultSearchProviderToPrefs(
const TemplateURL* t_url) {
PrefService* prefs = GetPrefs();
« no previous file with comments | « chrome/browser/search_engines/template_url_service.h ('k') | chrome/browser/search_engines/template_url_service_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698