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

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

Issue 10388186: RefCounted types should not have public destructors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
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"
11 #include "chrome/browser/history/history_database.h" 11 #include "chrome/browser/history/history_database.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 13
14 using content::BrowserThread; 14 using content::BrowserThread;
15 15
16 namespace prerender { 16 namespace prerender {
17 17
18 namespace { 18 namespace {
19 19
20 // Task to lookup the URL for a given URLID. 20 // Task to lookup the URL for a given URLID.
21 class GetURLForURLIDTask : public HistoryDBTask { 21 class GetURLForURLIDTask : public HistoryDBTask {
22 public: 22 public:
23 GetURLForURLIDTask(PrerenderLocalPredictor* local_predictor, 23 GetURLForURLIDTask(PrerenderLocalPredictor* local_predictor,
24 history::URLID url_id) 24 history::URLID url_id)
25 : local_predictor_(local_predictor), 25 : local_predictor_(local_predictor),
26 url_id_(url_id), 26 url_id_(url_id),
27 success_(false) { 27 success_(false) {
28 } 28 }
29
29 virtual bool RunOnDBThread(history::HistoryBackend* backend, 30 virtual bool RunOnDBThread(history::HistoryBackend* backend,
30 history::HistoryDatabase* db) { 31 history::HistoryDatabase* db) OVERRIDE {
31 history::URLRow url_row; 32 history::URLRow url_row;
32 success_ = db->GetURLRow(url_id_, &url_row); 33 success_ = db->GetURLRow(url_id_, &url_row);
33 if (success_) 34 if (success_)
34 url_ = url_row.url(); 35 url_ = url_row.url();
35 return true; 36 return true;
36 } 37 }
37 virtual void DoneRunOnMainThread() { 38
39 virtual void DoneRunOnMainThread() OVERRIDE {
38 if (success_) 40 if (success_)
39 local_predictor_->OnLookupURL(url_id_, url_); 41 local_predictor_->OnLookupURL(url_id_, url_);
40 } 42 }
43
41 private: 44 private:
45 virtual ~GetURLForURLIDTask() {}
46
42 PrerenderLocalPredictor* local_predictor_; 47 PrerenderLocalPredictor* local_predictor_;
43 history::URLID url_id_; 48 history::URLID url_id_;
44 bool success_; 49 bool success_;
45 GURL url_; 50 GURL url_;
46 DISALLOW_COPY_AND_ASSIGN(GetURLForURLIDTask); 51 DISALLOW_COPY_AND_ASSIGN(GetURLForURLIDTask);
47 }; 52 };
48 53
49 // Task to load history from the visit database on startup. 54 // Task to load history from the visit database on startup.
50 class GetVisitHistoryTask : public HistoryDBTask { 55 class GetVisitHistoryTask : public HistoryDBTask {
51 public: 56 public:
52 GetVisitHistoryTask(PrerenderLocalPredictor* local_predictor, 57 GetVisitHistoryTask(PrerenderLocalPredictor* local_predictor,
53 int max_visits) 58 int max_visits)
54 : local_predictor_(local_predictor), 59 : local_predictor_(local_predictor),
55 max_visits_(max_visits), 60 max_visits_(max_visits),
56 visit_history_(new std::vector<history::BriefVisitInfo>) { 61 visit_history_(new std::vector<history::BriefVisitInfo>) {
57 } 62 }
63
58 virtual bool RunOnDBThread(history::HistoryBackend* backend, 64 virtual bool RunOnDBThread(history::HistoryBackend* backend,
59 history::HistoryDatabase* db) { 65 history::HistoryDatabase* db) OVERRIDE {
60 db->GetBriefVisitInfoOfMostRecentVisits(max_visits_, visit_history_.get()); 66 db->GetBriefVisitInfoOfMostRecentVisits(max_visits_, visit_history_.get());
61 return true; 67 return true;
62 } 68 }
63 virtual void DoneRunOnMainThread() { 69
70 virtual void DoneRunOnMainThread() OVERRIDE {
64 local_predictor_->OnGetInitialVisitHistory(visit_history_.Pass()); 71 local_predictor_->OnGetInitialVisitHistory(visit_history_.Pass());
65 } 72 }
73
66 private: 74 private:
75 virtual ~GetVisitHistoryTask() {}
76
67 PrerenderLocalPredictor* local_predictor_; 77 PrerenderLocalPredictor* local_predictor_;
68 int max_visits_; 78 int max_visits_;
69 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history_; 79 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history_;
70 DISALLOW_COPY_AND_ASSIGN(GetVisitHistoryTask); 80 DISALLOW_COPY_AND_ASSIGN(GetVisitHistoryTask);
71 }; 81 };
72 82
73 // Maximum visit history to retrieve from the visit database. 83 // Maximum visit history to retrieve from the visit database.
74 const int kMaxVisitHistory = 100 * 1000; 84 const int kMaxVisitHistory = 100 * 1000;
75 85
76 } // namespace 86 } // namespace
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return; 140 return;
131 } 141 }
132 history->ScheduleDBTask( 142 history->ScheduleDBTask(
133 new GetVisitHistoryTask(this, kMaxVisitHistory), 143 new GetVisitHistoryTask(this, kMaxVisitHistory),
134 &history_db_consumer_); 144 &history_db_consumer_);
135 observing_history_service_ = history; 145 observing_history_service_ = history;
136 observing_history_service_->AddVisitDatabaseObserver(this); 146 observing_history_service_->AddVisitDatabaseObserver(this);
137 } 147 }
138 148
139 } // namespace prerender 149 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_unittest.cc ('k') | chrome/renderer/spellchecker/spellcheck.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698