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..6cc76e839d2b8458a3a637d09cd5053fd1ea048f 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); |
} |
} |
@@ -609,4 +601,14 @@ AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { |
AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() { |
} |
+void AutocompleteActionPredictor::Shutdown() { |
+ history_service_observer_.RemoveAll(); |
+} |
+ |
+void AutocompleteActionPredictor::OnHistoryServiceLoaded( |
+ HistoryService* history_service) { |
+ TryDeleteOldEntries(history_service); |
+ history_service_observer_.Remove(history_service); |
+} |
+ |
} // namespace predictors |