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

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: Created 6 years, 3 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/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..3d4e64a73db370d7608f52bc54047ad0bface4a8 100644
--- a/chrome/browser/predictors/autocomplete_action_predictor.cc
+++ b/chrome/browser/predictors/autocomplete_action_predictor.cc
@@ -97,6 +97,10 @@ AutocompleteActionPredictor::AutocompleteActionPredictor(Profile* profile)
}
AutocompleteActionPredictor::~AutocompleteActionPredictor() {
+ HistoryService* history_service =
sdefresne 2014/09/23 08:45:09 AutocompleteActionPredictor is a KeyedService. Sho
sdefresne 2014/10/20 13:15:42 Please move the unregistration into AutocompleteAc
nshaik 2014/10/29 08:43:39 Done.
+ HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
+ if (history_service)
sdefresne 2014/10/20 13:15:42 Use ScopedObserver<>.
+ history_service->RemoveHistoryServiceObserver(this);
if (main_profile_predictor_)
main_profile_predictor_->incognito_predictor_ = NULL;
else if (incognito_predictor_)
@@ -257,15 +261,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 +476,7 @@ 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_));
+ history_service->AddHistoryServiceObserver(this);
}
}
@@ -609,4 +603,10 @@ AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() {
AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() {
}
+void AutocompleteActionPredictor::HistoryServiceLoaded(
+ HistoryService* history_service) {
+ TryDeleteOldEntries(history_service);
+ history_service->RemoveHistoryServiceObserver(this);
+}
+
} // namespace predictors

Powered by Google App Engine
This is Rietveld 408576698