OLD | NEW |
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 <cstddef> | 8 #include <cstddef> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 typedef std::map<std::string, OriginData> OriginDataMap; | 44 typedef std::map<std::string, OriginData> OriginDataMap; |
45 | 45 |
46 // Returns data for all Urls and Hosts. | 46 // Returns data for all Urls and Hosts. |
47 virtual void GetAllData(PrefetchDataMap* url_data_map, | 47 virtual void GetAllData(PrefetchDataMap* url_data_map, |
48 PrefetchDataMap* host_data_map, | 48 PrefetchDataMap* host_data_map, |
49 RedirectDataMap* url_redirect_data_map, | 49 RedirectDataMap* url_redirect_data_map, |
50 RedirectDataMap* host_redirect_data_map, | 50 RedirectDataMap* host_redirect_data_map, |
51 ManifestDataMap* manifest_map, | 51 ManifestDataMap* manifest_map, |
52 OriginDataMap* origin_data_map); | 52 OriginDataMap* origin_data_map); |
53 | 53 |
54 // Updates data for a Url and a host. If any of the arguments has an empty | 54 // Updates resource data for the input |data|. |
55 // primary key, it will be ignored. | 55 // Note that the primary key in |data| should be less than |kMaxStringLength| |
56 // Note that all the keys should be less |kMaxStringLength| in length. | 56 // in length. |
57 virtual void UpdateData(const PrefetchData& url_data, | 57 virtual void UpdateResourceData(const PrefetchData& data, |
58 const PrefetchData& host_data, | 58 PrefetchKeyType key_type); |
59 const RedirectData& url_redirect_data, | 59 |
60 const RedirectData& host_redirect_data); | 60 // Updates redirect data for the input |data|. |
| 61 // Note that the primary key in |data| should be less than |kMaxStringLength| |
| 62 // in length. |
| 63 virtual void UpdateRedirectData(const RedirectData& data, |
| 64 PrefetchKeyType key_type); |
61 | 65 |
62 // Updates manifest data for the input |host|. | 66 // Updates manifest data for the input |host|. |
63 virtual void UpdateManifestData( | 67 virtual void UpdateManifestData( |
64 const std::string& host, | 68 const std::string& host, |
65 const precache::PrecacheManifest& manifest_data); | 69 const precache::PrecacheManifest& manifest_data); |
66 | 70 |
67 // Updates a given origin data point. | 71 // Updates a given origin data point. |
68 virtual void UpdateOriginData(const OriginData& origin_data); | 72 virtual void UpdateOriginData(const OriginData& origin_data); |
69 | 73 |
70 // Delete data for the input |urls| and |hosts|. | 74 // Delete data for the input |urls| and |hosts|. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 147 |
144 // Helper functions below help perform functions on the Url and host table | 148 // Helper functions below help perform functions on the Url and host table |
145 // using the same code. | 149 // using the same code. |
146 void GetAllResourceDataHelper(PrefetchKeyType key_type, | 150 void GetAllResourceDataHelper(PrefetchKeyType key_type, |
147 PrefetchDataMap* data_map); | 151 PrefetchDataMap* data_map); |
148 void GetAllRedirectDataHelper(PrefetchKeyType key_type, | 152 void GetAllRedirectDataHelper(PrefetchKeyType key_type, |
149 RedirectDataMap* redirect_map); | 153 RedirectDataMap* redirect_map); |
150 void GetAllManifestDataHelper(ManifestDataMap* manifest_map); | 154 void GetAllManifestDataHelper(ManifestDataMap* manifest_map); |
151 void GetAllOriginDataHelper(OriginDataMap* manifest_map); | 155 void GetAllOriginDataHelper(OriginDataMap* manifest_map); |
152 | 156 |
153 bool UpdateDataHelper(PrefetchKeyType key_type, | 157 void UpdateDataHelper(PrefetchKeyType key_type, |
154 PrefetchDataType data_type, | 158 PrefetchDataType data_type, |
155 const std::string& key, | 159 const std::string& key, |
156 const google::protobuf::MessageLite& data); | 160 const google::protobuf::MessageLite& data); |
157 void DeleteDataHelper(PrefetchKeyType key_type, | 161 void DeleteDataHelper(PrefetchKeyType key_type, |
158 PrefetchDataType data_type, | 162 PrefetchDataType data_type, |
159 const std::vector<std::string>& keys); | 163 const std::vector<std::string>& keys); |
160 | 164 |
161 // PredictorTableBase: | 165 // PredictorTableBase: |
162 void CreateTableIfNonExistent() override; | 166 void CreateTableIfNonExistent() override; |
163 void LogDatabaseStats() override; | 167 void LogDatabaseStats() override; |
(...skipping 10 matching lines...) Expand all Loading... |
174 | 178 |
175 static const char* GetTableName(PrefetchKeyType key_type, | 179 static const char* GetTableName(PrefetchKeyType key_type, |
176 PrefetchDataType data_type); | 180 PrefetchDataType data_type); |
177 | 181 |
178 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables); | 182 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorTables); |
179 }; | 183 }; |
180 | 184 |
181 } // namespace predictors | 185 } // namespace predictors |
182 | 186 |
183 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ | 187 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_TABLES_H_ |
OLD | NEW |