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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_tables.h

Issue 2195503003: predictors: Add the request priority to the reource_prefetch_predictor DB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fix. Created 4 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/browser/predictors/predictor_table_base.h" 16 #include "chrome/browser/predictors/predictor_table_base.h"
17 #include "chrome/browser/predictors/resource_prefetch_common.h" 17 #include "chrome/browser/predictors/resource_prefetch_common.h"
18 #include "content/public/common/resource_type.h" 18 #include "content/public/common/resource_type.h"
19 #include "net/base/request_priority.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace sql { 22 namespace sql {
22 class Statement; 23 class Statement;
23 } 24 }
24 25
25 namespace predictors { 26 namespace predictors {
26 27
27 // Interface for database tables used by the ResourcePrefetchPredictor. 28 // Interface for database tables used by the ResourcePrefetchPredictor.
28 // All methods except the constructor and destructor need to be called on the DB 29 // All methods except the constructor and destructor need to be called on the DB
(...skipping 10 matching lines...) Expand all
39 // required for the page or host. 40 // required for the page or host.
40 struct ResourceRow { 41 struct ResourceRow {
41 ResourceRow(); 42 ResourceRow();
42 ResourceRow(const ResourceRow& other); 43 ResourceRow(const ResourceRow& other);
43 ResourceRow(const std::string& main_frame_url, 44 ResourceRow(const std::string& main_frame_url,
44 const std::string& resource_url, 45 const std::string& resource_url,
45 content::ResourceType resource_type, 46 content::ResourceType resource_type,
46 int number_of_hits, 47 int number_of_hits,
47 int number_of_misses, 48 int number_of_misses,
48 int consecutive_misses, 49 int consecutive_misses,
49 double average_position); 50 double average_position,
51 net::RequestPriority priority);
50 void UpdateScore(); 52 void UpdateScore();
51 bool operator==(const ResourceRow& rhs) const; 53 bool operator==(const ResourceRow& rhs) const;
52 54
53 // Stores the host for host based data, main frame Url for the Url based 55 // Stores the host for host based data, main frame Url for the Url based
54 // data. This field is cleared for efficiency reasons and the code outside 56 // data. This field is cleared for efficiency reasons and the code outside
55 // this class should not assume it is set. 57 // this class should not assume it is set.
56 std::string primary_key; 58 std::string primary_key;
57 59
58 GURL resource_url; 60 GURL resource_url;
59 content::ResourceType resource_type; 61 content::ResourceType resource_type;
60 size_t number_of_hits; 62 size_t number_of_hits;
61 size_t number_of_misses; 63 size_t number_of_misses;
62 size_t consecutive_misses; 64 size_t consecutive_misses;
63 double average_position; 65 double average_position;
66 net::RequestPriority priority;
64 67
65 // Not stored. 68 // Not stored.
66 float score; 69 float score;
67 }; 70 };
68 typedef std::vector<ResourceRow> ResourceRows; 71 typedef std::vector<ResourceRow> ResourceRows;
69 72
70 // Sorts the ResourceRows by score, descending. 73 // Sorts the ResourceRows by score, descending.
71 struct ResourceRowSorter { 74 struct ResourceRowSorter {
72 bool operator()(const ResourceRow& x, const ResourceRow& y) const; 75 bool operator()(const ResourceRow& x, const ResourceRow& y) const;
73 }; 76 };
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const std::vector<std::string>& keys); 138 const std::vector<std::string>& keys);
136 139
137 // Returns true if the strings in the |data| are less than |kMaxStringLength| 140 // Returns true if the strings in the |data| are less than |kMaxStringLength|
138 // in length. 141 // in length.
139 bool StringsAreSmallerThanDBLimit(const PrefetchData& data) const; 142 bool StringsAreSmallerThanDBLimit(const PrefetchData& data) const;
140 143
141 // PredictorTableBase methods. 144 // PredictorTableBase methods.
142 void CreateTableIfNonExistent() override; 145 void CreateTableIfNonExistent() override;
143 void LogDatabaseStats() override; 146 void LogDatabaseStats() override;
144 147
148 bool DropTablesIfOutdated(sql::Connection* db);
149
145 // Helpers to return Statements for cached Statements. The caller must take 150 // Helpers to return Statements for cached Statements. The caller must take
146 // ownership of the return Statements. 151 // ownership of the return Statements.
147 sql::Statement* GetUrlResourceDeleteStatement(); 152 sql::Statement* GetUrlResourceDeleteStatement();
148 sql::Statement* GetUrlResourceUpdateStatement(); 153 sql::Statement* GetUrlResourceUpdateStatement();
149 sql::Statement* GetUrlMetadataDeleteStatement(); 154 sql::Statement* GetUrlMetadataDeleteStatement();
150 sql::Statement* GetUrlMetadataUpdateStatement(); 155 sql::Statement* GetUrlMetadataUpdateStatement();
151 156
152 sql::Statement* GetHostResourceDeleteStatement(); 157 sql::Statement* GetHostResourceDeleteStatement();
153 sql::Statement* GetHostResourceUpdateStatement(); 158 sql::Statement* GetHostResourceUpdateStatement();
154 sql::Statement* GetHostMetadataDeleteStatement(); 159 sql::Statement* GetHostMetadataDeleteStatement();
155 sql::Statement* GetHostMetadataUpdateStatement(); 160 sql::Statement* GetHostMetadataUpdateStatement();
156 161
157 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables); 162 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables);
158 }; 163 };
159 164
160 } // namespace predictors 165 } // namespace predictors
161 166
162 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ 167 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698