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 |