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..14fb98d412847944147956fe35d47e047afd91ca 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; |
@@ -475,15 +467,9 @@ void AutocompleteActionPredictor::CreateCaches( |
db_id_cache_[key] = it->id; |
} |
- // If the history service is ready, delete any old or invalid entries. |
sdefresne
2014/10/30 17:37:04
Please restore comment.
nshaik
2014/10/30 21:48:35
Done.
|
HistoryService* history_service = |
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
- 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_)); |
- } |
+ TryDeleteOldEntries(history_service); |
sdefresne
2014/10/30 17:37:03
Could you keep the old structure and comment and j
nshaik
2014/10/30 21:48:35
Done.
|
} |
bool AutocompleteActionPredictor::TryDeleteOldEntries(HistoryService* service) { |
@@ -495,8 +481,10 @@ bool AutocompleteActionPredictor::TryDeleteOldEntries(HistoryService* service) { |
return false; |
history::URLDatabase* url_db = service->InMemoryDatabase(); |
- if (!url_db) |
+ if (!url_db) { |
+ history_service_observer_.Add(service); |
sdefresne
2014/10/30 17:37:03
See previous comment.
nshaik
2014/10/30 21:48:35
Done.
|
return false; |
+ } |
DeleteOldEntries(url_db); |
return true; |
@@ -609,4 +597,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 |