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() { |
} |