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

Unified Diff: chrome/browser/history/in_memory_url_index.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/history/in_memory_url_index.cc
diff --git a/chrome/browser/history/in_memory_url_index.cc b/chrome/browser/history/in_memory_url_index.cc
index 71244d31aa872a73964387b66f3dc625abd915f7..6bb0f4c4e6b7822c2f58d443c4f422fa66372837 100644
--- a/chrome/browser/history/in_memory_url_index.cc
+++ b/chrome/browser/history/in_memory_url_index.cc
@@ -137,6 +137,10 @@ void InMemoryURLIndex::Init() {
}
void InMemoryURLIndex::ShutDown() {
+ HistoryService* service =
+ HistoryServiceFactory::GetForProfileWithoutCreating(profile_);
+ if (service)
+ service->RemoveHistoryServiceObserver(this);
sdefresne 2014/10/20 13:15:42 You can use ScopedObserver<> to simplify the code.
registrar_.RemoveAll();
cache_reader_tracker_.TryCancelAll();
shutdown_ = true;
@@ -194,11 +198,6 @@ void InMemoryURLIndex::Observe(int notification_type,
OnURLsDeleted(
content::Details<history::URLsDeletedDetails>(details).ptr());
break;
- case chrome::NOTIFICATION_HISTORY_LOADED:
- registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_LOADED,
- content::Source<Profile>(profile_));
- ScheduleRebuildFromHistory();
- break;
default:
// For simplicity, the unit tests send us all notifications, even when
// we haven't registered for them, so don't assert here.
@@ -302,8 +301,7 @@ void InMemoryURLIndex::OnCacheLoadDone(
if (service && service->backend_loaded()) {
sdefresne 2014/10/20 13:15:41 |service| can only be NULL if running tests, so re
nshaik 2014/10/29 08:43:39 Done.
ScheduleRebuildFromHistory();
} else {
- registrar_.Add(this, chrome::NOTIFICATION_HISTORY_LOADED,
- content::Source<Profile>(profile_));
+ service->AddHistoryServiceObserver(this);
}
}
}
@@ -377,4 +375,9 @@ void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) {
save_cache_observer_->OnCacheSaveFinished(succeeded);
}
+void InMemoryURLIndex::HistoryServiceLoaded(HistoryService* history_service) {
+ ScheduleRebuildFromHistory();
+ history_service->RemoveHistoryServiceObserver(this);
+}
+
} // namespace history

Powered by Google App Engine
This is Rietveld 408576698