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 <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 public: | 169 public: |
170 GetURLForURLIDTask( | 170 GetURLForURLIDTask( |
171 PrerenderLocalPredictor::CandidatePrerenderInfo* request, | 171 PrerenderLocalPredictor::CandidatePrerenderInfo* request, |
172 const base::Closure& callback) | 172 const base::Closure& callback) |
173 : request_(request), | 173 : request_(request), |
174 callback_(callback), | 174 callback_(callback), |
175 start_time_(base::Time::Now()) { | 175 start_time_(base::Time::Now()) { |
176 } | 176 } |
177 | 177 |
178 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 178 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
179 history::HistoryDatabase* db) OVERRIDE { | 179 history::HistoryDatabase* db) override { |
180 DoURLLookup(db, &request_->source_url_); | 180 DoURLLookup(db, &request_->source_url_); |
181 for (int i = 0; i < static_cast<int>(request_->candidate_urls_.size()); i++) | 181 for (int i = 0; i < static_cast<int>(request_->candidate_urls_.size()); i++) |
182 DoURLLookup(db, &request_->candidate_urls_[i]); | 182 DoURLLookup(db, &request_->candidate_urls_[i]); |
183 return true; | 183 return true; |
184 } | 184 } |
185 | 185 |
186 virtual void DoneRunOnMainThread() OVERRIDE { | 186 virtual void DoneRunOnMainThread() override { |
187 callback_.Run(); | 187 callback_.Run(); |
188 TIMING_HISTOGRAM("Prerender.LocalPredictorURLLookupTime", | 188 TIMING_HISTOGRAM("Prerender.LocalPredictorURLLookupTime", |
189 base::Time::Now() - start_time_); | 189 base::Time::Now() - start_time_); |
190 } | 190 } |
191 | 191 |
192 private: | 192 private: |
193 virtual ~GetURLForURLIDTask() {} | 193 virtual ~GetURLForURLIDTask() {} |
194 | 194 |
195 void DoURLLookup(history::HistoryDatabase* db, | 195 void DoURLLookup(history::HistoryDatabase* db, |
196 PrerenderLocalPredictor::LocalPredictorURLInfo* request) { | 196 PrerenderLocalPredictor::LocalPredictorURLInfo* request) { |
(...skipping 13 matching lines...) Expand all Loading... |
210 class GetVisitHistoryTask : public history::HistoryDBTask { | 210 class GetVisitHistoryTask : public history::HistoryDBTask { |
211 public: | 211 public: |
212 GetVisitHistoryTask(PrerenderLocalPredictor* local_predictor, | 212 GetVisitHistoryTask(PrerenderLocalPredictor* local_predictor, |
213 int max_visits) | 213 int max_visits) |
214 : local_predictor_(local_predictor), | 214 : local_predictor_(local_predictor), |
215 max_visits_(max_visits), | 215 max_visits_(max_visits), |
216 visit_history_(new vector<history::BriefVisitInfo>) { | 216 visit_history_(new vector<history::BriefVisitInfo>) { |
217 } | 217 } |
218 | 218 |
219 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 219 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
220 history::HistoryDatabase* db) OVERRIDE { | 220 history::HistoryDatabase* db) override { |
221 db->GetBriefVisitInfoOfMostRecentVisits(max_visits_, visit_history_.get()); | 221 db->GetBriefVisitInfoOfMostRecentVisits(max_visits_, visit_history_.get()); |
222 return true; | 222 return true; |
223 } | 223 } |
224 | 224 |
225 virtual void DoneRunOnMainThread() OVERRIDE { | 225 virtual void DoneRunOnMainThread() override { |
226 local_predictor_->OnGetInitialVisitHistory(visit_history_.Pass()); | 226 local_predictor_->OnGetInitialVisitHistory(visit_history_.Pass()); |
227 } | 227 } |
228 | 228 |
229 private: | 229 private: |
230 virtual ~GetVisitHistoryTask() {} | 230 virtual ~GetVisitHistoryTask() {} |
231 | 231 |
232 PrerenderLocalPredictor* local_predictor_; | 232 PrerenderLocalPredictor* local_predictor_; |
233 int max_visits_; | 233 int max_visits_; |
234 scoped_ptr<vector<history::BriefVisitInfo> > visit_history_; | 234 scoped_ptr<vector<history::BriefVisitInfo> > visit_history_; |
235 DISALLOW_COPY_AND_ASSIGN(GetVisitHistoryTask); | 235 DISALLOW_COPY_AND_ASSIGN(GetVisitHistoryTask); |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 break; | 1572 break; |
1573 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: | 1573 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: |
1574 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); | 1574 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); |
1575 break; | 1575 break; |
1576 default: | 1576 default: |
1577 NOTREACHED(); | 1577 NOTREACHED(); |
1578 } | 1578 } |
1579 } | 1579 } |
1580 | 1580 |
1581 } // namespace prerender | 1581 } // namespace prerender |
OLD | NEW |