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

Unified Diff: chrome/browser/predictors/autocomplete_action_predictor.cc

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ScopedObserver to InMemoryHistoryBackend,PrerenderLocalPredictor,ChromeTemplateURLServiceClient Created 6 years, 1 month 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/predictors/autocomplete_action_predictor.cc
diff --git a/chrome/browser/predictors/autocomplete_action_predictor.cc b/chrome/browser/predictors/autocomplete_action_predictor.cc
index fed802ee7a256b6c24bed3d132d5637fb754f6e8..e13c0309904ba00c181d090ab2191bc6740a86f2 100644
--- a/chrome/browser/predictors/autocomplete_action_predictor.cc
+++ b/chrome/browser/predictors/autocomplete_action_predictor.cc
@@ -69,7 +69,8 @@ AutocompleteActionPredictor::AutocompleteActionPredictor(Profile* profile)
: profile_(profile),
main_profile_predictor_(NULL),
incognito_predictor_(NULL),
- initialized_(false) {
+ initialized_(false),
+ history_service_observer_(this) {
if (profile_->IsOffTheRecord()) {
main_profile_predictor_ = AutocompleteActionPredictorFactory::GetForProfile(
profile_->GetOriginalProfile());
@@ -257,15 +258,6 @@ void AutocompleteActionPredictor::Observe(
break;
}
- case chrome::NOTIFICATION_HISTORY_LOADED: {
- TryDeleteOldEntries(content::Details<HistoryService>(details).ptr());
-
- notification_registrar_.Remove(this,
- chrome::NOTIFICATION_HISTORY_LOADED,
- content::Source<Profile>(profile_));
- break;
- }
-
default:
NOTREACHED() << "Unexpected notification observed.";
break;
@@ -481,8 +473,8 @@ void AutocompleteActionPredictor::CreateCaches(
if (!TryDeleteOldEntries(history_service)) {
// Wait for the notification that the history service is ready and the URL
// DB is loaded.
- notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_LOADED,
- content::Source<Profile>(profile_));
+ if (history_service)
+ history_service_observer_.Add(history_service);
}
}
@@ -603,6 +595,16 @@ double AutocompleteActionPredictor::CalculateConfidenceForDbEntry(
return number_of_hits / (number_of_hits + value.number_of_misses);
}
+void AutocompleteActionPredictor::Shutdown() {
+ history_service_observer_.RemoveAll();
+}
+
+void AutocompleteActionPredictor::OnHistoryServiceLoaded(
+ HistoryService* history_service) {
+ TryDeleteOldEntries(history_service);
+ history_service_observer_.Remove(history_service);
+}
+
AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() {
}

Powered by Google App Engine
This is Rietveld 408576698