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

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

Issue 2397943004: predictors: Use redirect data in prefetch. (Closed)
Patch Set: Non-empty check. Created 4 years, 2 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>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // misses from |data|. 88 // misses from |data|.
89 static void TrimResources(PrefetchData* data, size_t max_consecutive_misses); 89 static void TrimResources(PrefetchData* data, size_t max_consecutive_misses);
90 90
91 // Sorts the resources by score, decreasing. 91 // Sorts the resources by score, decreasing.
92 static void SortResources(PrefetchData* data); 92 static void SortResources(PrefetchData* data);
93 93
94 // Removes the redirects with more than |max_consecutive_misses| consecutive 94 // Removes the redirects with more than |max_consecutive_misses| consecutive
95 // misses from |data|. 95 // misses from |data|.
96 static void TrimRedirects(RedirectData* data, size_t max_consecutive_misses); 96 static void TrimRedirects(RedirectData* data, size_t max_consecutive_misses);
97 97
98 // Sorts the redirects by score, decreasing.
99 static void SortRedirects(RedirectData* data);
100
101 // The maximum length of the string that can be stored in the DB. 98 // The maximum length of the string that can be stored in the DB.
102 static constexpr size_t kMaxStringLength = 1024; 99 static constexpr size_t kMaxStringLength = 1024;
103 100
104 private: 101 private:
105 // Represents the type of information that is stored in prefetch database. 102 // Represents the type of information that is stored in prefetch database.
106 enum class PrefetchDataType { RESOURCE, REDIRECT }; 103 enum class PrefetchDataType { RESOURCE, REDIRECT };
107 104
108 enum class TableOperationType { INSERT, REMOVE }; 105 enum class TableOperationType { INSERT, REMOVE };
109 106
110 friend class PredictorDatabaseInternal; 107 friend class PredictorDatabaseInternal;
(...skipping 17 matching lines...) Expand all
128 bool UpdateDataHelper(PrefetchKeyType key_type, 125 bool UpdateDataHelper(PrefetchKeyType key_type,
129 PrefetchDataType data_type, 126 PrefetchDataType data_type,
130 const std::string& key, 127 const std::string& key,
131 const google::protobuf::MessageLite& data); 128 const google::protobuf::MessageLite& data);
132 void DeleteDataHelper(PrefetchKeyType key_type, 129 void DeleteDataHelper(PrefetchKeyType key_type,
133 PrefetchDataType data_type, 130 PrefetchDataType data_type,
134 const std::vector<std::string>& keys); 131 const std::vector<std::string>& keys);
135 132
136 // Computes score of |data|. 133 // Computes score of |data|.
137 static float ComputeResourceScore(const ResourceData& data); 134 static float ComputeResourceScore(const ResourceData& data);
138 static float ComputeRedirectScore(const RedirectStat& data);
139 135
140 // PredictorTableBase methods. 136 // PredictorTableBase methods.
141 void CreateTableIfNonExistent() override; 137 void CreateTableIfNonExistent() override;
142 void LogDatabaseStats() override; 138 void LogDatabaseStats() override;
143 139
144 // Database version. Always increment it when any change is made to the data 140 // Database version. Always increment it when any change is made to the data
145 // schema (including the .proto). 141 // schema (including the .proto).
146 static constexpr int kDatabaseVersion = 4; 142 static constexpr int kDatabaseVersion = 4;
147 143
148 static bool DropTablesIfOutdated(sql::Connection* db); 144 static bool DropTablesIfOutdated(sql::Connection* db);
149 static int GetDatabaseVersion(sql::Connection* db); 145 static int GetDatabaseVersion(sql::Connection* db);
150 static bool SetDatabaseVersion(sql::Connection* db, int version); 146 static bool SetDatabaseVersion(sql::Connection* db, int version);
151 147
152 // Helper to return Statements for cached Statements. 148 // Helper to return Statements for cached Statements.
153 std::unique_ptr<sql::Statement> GetTableUpdateStatement( 149 std::unique_ptr<sql::Statement> GetTableUpdateStatement(
154 PrefetchKeyType key_type, 150 PrefetchKeyType key_type,
155 PrefetchDataType data_type, 151 PrefetchDataType data_type,
156 TableOperationType op_type); 152 TableOperationType op_type);
157 153
158 static const char* GetTableName(PrefetchKeyType key_type, 154 static const char* GetTableName(PrefetchKeyType key_type,
159 PrefetchDataType data_type); 155 PrefetchDataType data_type);
160 156
161 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables); 157 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables);
162 }; 158 };
163 159
164 } // namespace predictors 160 } // namespace predictors
165 161
166 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ 162 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698