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

Side by Side Diff: chrome/browser/prerender/prerender_local_predictor.cc

Issue 10214004: Fix destruction concurrency issue in PrerenderLocalPredictor: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prerender/prerender_local_predictor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/prerender/prerender_local_predictor.h" 5 #include "chrome/browser/prerender/prerender_local_predictor.h"
6 6
7 #include "base/timer.h" 7 #include "base/timer.h"
8 #include "chrome/browser/prerender/prerender_manager.h" 8 #include "chrome/browser/prerender/prerender_manager.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 visit_history_initialized_(false) { 81 visit_history_initialized_(false) {
82 if (MessageLoop::current()) { 82 if (MessageLoop::current()) {
83 timer_.Start(FROM_HERE, 83 timer_.Start(FROM_HERE,
84 base::TimeDelta::FromMilliseconds(kInitDelayMs), 84 base::TimeDelta::FromMilliseconds(kInitDelayMs),
85 this, 85 this,
86 &PrerenderLocalPredictor::Init); 86 &PrerenderLocalPredictor::Init);
87 } 87 }
88 } 88 }
89 89
90 PrerenderLocalPredictor::~PrerenderLocalPredictor() { 90 PrerenderLocalPredictor::~PrerenderLocalPredictor() {
91 HistoryService* history = GetHistoryIfExists(); 91 if (observing_history_service_.get())
92 if (history) 92 observing_history_service_->RemoveVisitDatabaseObserver(this);
93 history->RemoveVisitDatabaseObserver(this);
94 } 93 }
95 94
96 void PrerenderLocalPredictor::OnAddVisit(const history::BriefVisitInfo& info) { 95 void PrerenderLocalPredictor::OnAddVisit(const history::BriefVisitInfo& info) {
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
98 HistoryService* history = GetHistoryIfExists(); 97 HistoryService* history = GetHistoryIfExists();
99 if (history) { 98 if (history) {
100 history->ScheduleDBTask( 99 history->ScheduleDBTask(
101 new GetURLForURLIDTask(this, info.url_id), 100 new GetURLForURLIDTask(this, info.url_id),
102 &history_db_consumer_); 101 &history_db_consumer_);
103 } 102 }
(...skipping 22 matching lines...) Expand all
126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
127 HistoryService* history = GetHistoryIfExists(); 126 HistoryService* history = GetHistoryIfExists();
128 if (!history) { 127 if (!history) {
129 // TODO(tburkard): Record this somewhere (eg histogram) and/or try again 128 // TODO(tburkard): Record this somewhere (eg histogram) and/or try again
130 // later. 129 // later.
131 return; 130 return;
132 } 131 }
133 history->ScheduleDBTask( 132 history->ScheduleDBTask(
134 new GetVisitHistoryTask(this, kMaxVisitHistory), 133 new GetVisitHistoryTask(this, kMaxVisitHistory),
135 &history_db_consumer_); 134 &history_db_consumer_);
136 history->AddVisitDatabaseObserver(this); 135 observing_history_service_ = history;
136 observing_history_service_->AddVisitDatabaseObserver(this);
137 } 137 }
138 138
139 } // namespace prerender 139 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_local_predictor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698