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

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: Address review comments Created 6 years, 2 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..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

Powered by Google App Engine
This is Rietveld 408576698