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 <string> | |
10 #include <vector> | |
11 | |
12 #include "chrome/browser/predictors/predictor_table_base.h" | |
dominich
2012/05/21 16:16:53
This include should be first as it provides the ba
Shishir
2012/05/23 01:46:46
Done.
| |
13 #include "googleurl/src/gurl.h" | |
14 #include "webkit/glue/resource_type.h" | |
15 | |
16 namespace predictors { | |
17 | |
18 // Interface for database tables used by the ResourcePrefetchPredictor. | |
19 // All methods except the constructor and destructor need to be called on the DB | |
20 // thread. | |
21 // NOTE: This class is named in plural as it will hold other tables shortly. | |
22 class ResourcePrefetchPredictorTables : public PredictorTableBase { | |
23 public: | |
24 struct UrlTableRow { | |
25 UrlTableRow(); | |
26 UrlTableRow(const UrlTableRow& other); | |
dominich
2012/05/21 16:16:53
check if you can mark this explicit - STL may not
Shishir
2012/05/23 01:46:46
Doesnt work with STL.
| |
27 void UpdateScore(); | |
28 | |
29 GURL main_frame_url_; | |
30 GURL resource_url_; | |
31 ResourceType::Type resource_type_; | |
32 int number_of_hits_; | |
33 int number_of_misses_; | |
34 int consecutive_misses_; | |
35 double average_position_; | |
dominich
2012/05/21 16:16:53
Can this be a float?
Shishir
2012/05/23 01:46:46
Since sql/statement doesnt expose float , keeping
| |
36 | |
37 // Not stored. | |
38 double score_; | |
dominich
2012/05/21 16:16:53
Can this be a float?
Shishir
2012/05/23 01:46:46
Done.
| |
39 }; | |
40 | |
41 // Sorts the UrlTableRows by score. | |
dominich
2012/05/21 16:16:53
ascending or descending?
Shishir
2012/05/23 01:46:46
Done.
| |
42 struct UrlTableRowSorter { | |
43 bool operator()(const UrlTableRow& x, const UrlTableRow& y) const; | |
44 }; | |
45 | |
46 void GetAllRows(std::vector<UrlTableRow>* url_row_buffer); | |
47 void UpdateRowsForUrl(const GURL& main_page_url, | |
48 const std::vector<UrlTableRow>& row_buffer); | |
49 void DeleteUrlRows(const std::vector<GURL>& urls); | |
50 | |
51 private: | |
52 friend class PredictorDatabaseInternal; | |
53 | |
54 ResourcePrefetchPredictorTables(); | |
55 virtual ~ResourcePrefetchPredictorTables(); | |
56 | |
57 // PredictorTableBase methods. | |
58 virtual void CreateTableIfNonExistent() OVERRIDE; | |
59 virtual void LogDatabaseStats() OVERRIDE; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables); | |
62 }; | |
63 | |
64 } // namespace predictors | |
65 | |
66 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ | |
OLD | NEW |