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_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ | |
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ | |
7 #pragma once | |
8 | |
9 #include "chrome/browser/predictors/predictor_table_base.h" | |
10 | |
11 #include <string> | |
12 #include <vector> | |
13 | |
14 #include "googleurl/src/gurl.h" | |
15 #include "webkit/glue/resource_type.h" | |
16 | |
17 namespace predictors { | |
18 | |
19 // Interface for database tables used by the ResourcePrefetchPredictor. | |
20 // All methods except the constructor and destructor need to be called on the DB | |
21 // thread. | |
22 // NOTE: This class is named in plural as it will hold other tables shortly. | |
23 class ResourcePrefetchPredictorTables : public PredictorTableBase { | |
willchan no longer on Chromium
2012/05/24 22:28:52
Why is PredictorTableBase inherited? The Google st
Shishir
2012/05/30 01:07:51
I added a todo for this. I would like to do that i
| |
24 public: | |
25 struct UrlTableRow { | |
26 UrlTableRow(); | |
27 UrlTableRow(const UrlTableRow& other); | |
28 void UpdateScore(); | |
29 | |
30 GURL main_frame_url_; | |
31 GURL resource_url_; | |
32 ResourceType::Type resource_type_; | |
33 int number_of_hits_; | |
34 int number_of_misses_; | |
35 int consecutive_misses_; | |
36 double average_position_; | |
37 | |
38 // Not stored. | |
39 float score_; | |
40 }; | |
41 | |
42 // Sorts the UrlTableRows by score, descending. | |
43 struct UrlTableRowSorter { | |
44 bool operator()(const UrlTableRow& x, const UrlTableRow& y) const; | |
45 }; | |
46 | |
47 void GetAllRows(std::vector<UrlTableRow>* url_row_buffer); | |
48 void UpdateRowsForUrl(const GURL& main_page_url, | |
49 const std::vector<UrlTableRow>& row_buffer); | |
50 void DeleteUrlRows(const std::vector<GURL>& urls); | |
51 | |
52 private: | |
53 friend class PredictorDatabaseInternal; | |
54 | |
55 ResourcePrefetchPredictorTables(); | |
56 virtual ~ResourcePrefetchPredictorTables(); | |
57 | |
58 // PredictorTableBase methods. | |
59 virtual void CreateTableIfNonExistent() OVERRIDE; | |
60 virtual void LogDatabaseStats() OVERRIDE; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables); | |
63 }; | |
64 | |
65 } // namespace predictors | |
66 | |
67 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ | |
OLD | NEW |