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

Unified Diff: chrome/browser/prerender/prerender_local_predictor.cc

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ScopedObserver to InMemoryHistoryBackend,PrerenderLocalPredictor,ChromeTemplateURLServiceClient Created 6 years, 1 month 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/prerender/prerender_local_predictor.cc
diff --git a/chrome/browser/prerender/prerender_local_predictor.cc b/chrome/browser/prerender/prerender_local_predictor.cc
index a4168535af65f56bbbc9abb057d3b72ad2e21629..6b112c8679a863e0f3070530d073967a3356cc00 100644
--- a/chrome/browser/prerender/prerender_local_predictor.cc
+++ b/chrome/browser/prerender/prerender_local_predictor.cc
@@ -528,9 +528,9 @@ class PrerenderLocalPredictor::PrefetchList {
PrerenderLocalPredictor::PrerenderLocalPredictor(
PrerenderManager* prerender_manager)
: prerender_manager_(prerender_manager),
- is_history_service_observer_(false),
weak_factory_(this),
- prefetch_list_(new PrefetchList()) {
+ prefetch_list_(new PrefetchList()),
+ history_service_observer_(this) {
RecordEvent(EVENT_CONSTRUCTED);
if (base::MessageLoop::current()) {
timer_.Start(FROM_HERE,
@@ -583,12 +583,7 @@ PrerenderLocalPredictor::~PrerenderLocalPredictor() {
void PrerenderLocalPredictor::Shutdown() {
timer_.Stop();
- if (is_history_service_observer_) {
- HistoryService* history = GetHistoryIfExists();
- CHECK(history);
- history->RemoveObserver(this);
- is_history_service_observer_ = false;
- }
+ history_service_observer_.RemoveAll();
}
void PrerenderLocalPredictor::OnAddVisit(HistoryService* history_service,
@@ -1139,13 +1134,12 @@ void PrerenderLocalPredictor::Init() {
}
HistoryService* history = GetHistoryIfExists();
if (history) {
- CHECK(!is_history_service_observer_);
+ CHECK(!history_service_observer_.IsObserving(history));
history->ScheduleDBTask(
scoped_ptr<history::HistoryDBTask>(
new GetVisitHistoryTask(this, kMaxVisitHistory)),
&history_db_tracker_);
- history->AddObserver(this);
- is_history_service_observer_ = true;
+ history_service_observer_.Add(history);
} else {
RecordEvent(EVENT_INIT_FAILED_NO_HISTORY);
}

Powered by Google App Engine
This is Rietveld 408576698