| 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_H_ | 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 NavigationNotRecorded); | 138 NavigationNotRecorded); |
| 139 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlInDB); | 139 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlInDB); |
| 140 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlNotInDB); | 140 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlNotInDB); |
| 141 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 141 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 142 NavigationUrlNotInDBAndDBFull); | 142 NavigationUrlNotInDBAndDBFull); |
| 143 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest); | 143 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest); |
| 144 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect); | 144 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect); |
| 145 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 145 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 146 OnSubresourceResponse); | 146 OnSubresourceResponse); |
| 147 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); | 147 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); |
| 148 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes); |
| 148 | 149 |
| 149 enum InitializationState { | 150 enum InitializationState { |
| 150 NOT_INITIALIZED = 0, | 151 NOT_INITIALIZED = 0, |
| 151 INITIALIZING = 1, | 152 INITIALIZING = 1, |
| 152 INITIALIZED = 2 | 153 INITIALIZED = 2 |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 // Stores prefetching results. | 156 // Stores prefetching results. |
| 156 struct Result { | 157 struct Result { |
| 157 // Takes ownership of requests. | 158 // Takes ownership of requests. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 171 typedef ResourcePrefetchPredictorTables::PrefetchData PrefetchData; | 172 typedef ResourcePrefetchPredictorTables::PrefetchData PrefetchData; |
| 172 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; | 173 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; |
| 173 typedef std::map<NavigationID, linked_ptr<std::vector<URLRequestSummary> > > | 174 typedef std::map<NavigationID, linked_ptr<std::vector<URLRequestSummary> > > |
| 174 NavigationMap; | 175 NavigationMap; |
| 175 typedef std::map<NavigationID, std::unique_ptr<Result>> ResultsMap; | 176 typedef std::map<NavigationID, std::unique_ptr<Result>> ResultsMap; |
| 176 | 177 |
| 177 // Returns true if the main page request is supported for prediction. | 178 // Returns true if the main page request is supported for prediction. |
| 178 static bool IsHandledMainPage(net::URLRequest* request); | 179 static bool IsHandledMainPage(net::URLRequest* request); |
| 179 | 180 |
| 180 // Returns true if the subresource request is supported for prediction. | 181 // Returns true if the subresource request is supported for prediction. |
| 181 static bool IsHandledSubresource(net::URLRequest* request); | 182 static bool IsHandledSubresource(net::URLRequest* request, |
| 183 content::ResourceType resource_type); |
| 184 |
| 185 // Returns true if the subresource has a supported type. |
| 186 static bool IsHandledResourceType(content::ResourceType resource_type, |
| 187 const std::string& mime_type); |
| 182 | 188 |
| 183 // Returns true if the request (should have a response in it) is cacheable. | 189 // Returns true if the request (should have a response in it) is cacheable. |
| 184 static bool IsCacheable(const net::URLRequest* request); | 190 static bool IsCacheable(const net::URLRequest* request); |
| 185 | 191 |
| 186 // KeyedService methods override. | 192 // KeyedService methods override. |
| 187 void Shutdown() override; | 193 void Shutdown() override; |
| 188 | 194 |
| 189 // Functions called on different network events pertaining to the loading of | 195 // Functions called on different network events pertaining to the loading of |
| 190 // main frame resource or sub resources. | 196 // main frame resource or sub resources. |
| 191 void OnMainFrameRequest(const URLRequestSummary& request); | 197 void OnMainFrameRequest(const URLRequestSummary& request); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 332 |
| 327 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 333 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 328 history_service_observer_; | 334 history_service_observer_; |
| 329 | 335 |
| 330 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); | 336 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); |
| 331 }; | 337 }; |
| 332 | 338 |
| 333 } // namespace predictors | 339 } // namespace predictors |
| 334 | 340 |
| 335 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 341 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |