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

Unified Diff: chrome/browser/search/instant_service.cc

Issue 845013002: Remove TopSites notification in favor of Observers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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
« no previous file with comments | « chrome/browser/search/instant_service.h ('k') | chrome/browser/ui/views/frame/global_menu_bar_x11.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/instant_service.cc
diff --git a/chrome/browser/search/instant_service.cc b/chrome/browser/search/instant_service.cc
index 1144e405f7885dd2572749e7fd40575caf337fa9..31b68d6fd76e44fe86b706559255f50e5f94f57d 100644
--- a/chrome/browser/search/instant_service.cc
+++ b/chrome/browser/search/instant_service.cc
@@ -93,11 +93,8 @@ InstantService::InstantService(Profile* profile)
content::NotificationService::AllSources());
history::TopSites* top_sites = profile_->GetTopSites();
- if (top_sites) {
- registrar_.Add(this,
- chrome::NOTIFICATION_TOP_SITES_CHANGED,
- content::Source<history::TopSites>(top_sites));
- }
+ if (top_sites)
+ top_sites->AddObserver(this);
if (profile_ && profile_->GetResourceContext()) {
content::BrowserThread::PostTask(
@@ -206,6 +203,11 @@ void InstantService::Shutdown() {
base::Bind(&InstantIOContext::ClearInstantProcessesOnIO,
instant_io_context_));
}
+
+ history::TopSites* top_sites = profile_->GetTopSites();
+ if (top_sites)
+ top_sites->RemoveObserver(this);
+
instant_io_context_ = NULL;
}
@@ -221,15 +223,6 @@ void InstantService::Observe(int type,
OnRendererProcessTerminated(
content::Source<content::RenderProcessHost>(source)->GetID());
break;
- case chrome::NOTIFICATION_TOP_SITES_CHANGED: {
- history::TopSites* top_sites = profile_->GetTopSites();
- if (top_sites) {
- top_sites->GetMostVisitedURLs(
- base::Bind(&InstantService::OnMostVisitedItemsReceived,
- weak_ptr_factory_.GetWeakPtr()), false);
- }
- break;
- }
#if defined(ENABLE_THEMES)
case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
OnThemeChanged(content::Source<ThemeService>(source).ptr());
@@ -423,6 +416,16 @@ void InstantService::OnTemplateURLServiceChanged() {
}
}
+void InstantService::TopSitesLoaded(history::TopSites* top_sites) {
+}
+
+void InstantService::TopSitesChanged(history::TopSites* top_sites) {
+ top_sites->GetMostVisitedURLs(
+ base::Bind(&InstantService::OnMostVisitedItemsReceived,
+ weak_ptr_factory_.GetWeakPtr()),
+ false);
+}
+
void InstantService::ResetInstantSearchPrerenderer() {
if (!chrome::ShouldPrefetchSearchResults())
return;
« no previous file with comments | « chrome/browser/search/instant_service.h ('k') | chrome/browser/ui/views/frame/global_menu_bar_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698