OLD | NEW |
---|---|
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 Loading... | |
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(); |
cbentzel
2012/04/24 18:33:57
Should this be using observing_history_service_?
tburkard
2012/04/24 18:39:57
Makes no difference, since it'd be the same one.
cbentzel
2012/04/24 18:47:22
Sounds reasonable. Can you add a comment about thi
| |
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 } |
104 } | 103 } |
105 | 104 |
106 void PrerenderLocalPredictor::OnLookupURL(history::URLID url_id, | 105 void PrerenderLocalPredictor::OnLookupURL(history::URLID url_id, |
107 const GURL& url) { | 106 const GURL& url) { |
108 } | 107 } |
(...skipping 17 matching lines...) Expand all Loading... | |
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 |
OLD | NEW |