OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ |
| 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <vector> |
| 10 |
| 11 #include "base/timer.h" |
| 12 #include "chrome/browser/cancelable_request.h" |
| 13 #include "chrome/browser/history/visit_database.h" |
| 14 #include "googleurl/src/gurl.h" |
| 15 |
| 16 class HistoryService; |
| 17 |
| 18 namespace prerender { |
| 19 |
| 20 class PrerenderManager; |
| 21 |
| 22 // PrerenderLocalPredictor maintains local browsing history to make prerender |
| 23 // predictions. |
| 24 // At this point, the class is just illustrating the interface with the |
| 25 // Chrome History. |
| 26 // TODO(tburkard): Fill in actual prerender prediction logic. |
| 27 class PrerenderLocalPredictor : history::VisitDatabaseObserver { |
| 28 public: |
| 29 explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager); |
| 30 ~PrerenderLocalPredictor(); |
| 31 |
| 32 // history::VisitDatabaseObserver implementation |
| 33 virtual void OnAddVisit(history::BriefVisitInfo info) OVERRIDE; |
| 34 |
| 35 void OnLookupURL(history::URLID url_id, GURL url); |
| 36 |
| 37 void OnGetInitialVisitHistory( |
| 38 std::vector<history::BriefVisitInfo>* visit_history); |
| 39 |
| 40 private: |
| 41 HistoryService* GetHistoryIfExists() const; |
| 42 void Init(); |
| 43 |
| 44 PrerenderManager* prerender_manager_; |
| 45 base::OneShotTimer<PrerenderLocalPredictor> timer_; |
| 46 |
| 47 // Delay after which to initialize, to avoid putting to much load on the |
| 48 // database thread early on when Chrome is starting up. |
| 49 static const int kInitDelayMs = 5 * 1000; |
| 50 // Maximum visit history to retrieve from the visit database. |
| 51 static const int kMaxVisitHistory = 100 * 1000; |
| 52 |
| 53 CancelableRequestConsumer history_db_consumer_; |
| 54 |
| 55 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history_; |
| 56 bool visit_history_initialized_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor); |
| 59 }; |
| 60 |
| 61 } |
| 62 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ |
OLD | NEW |