| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 258 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 259 TestPrefetchingDurationHistogram); | 259 TestPrefetchingDurationHistogram); |
| 260 | 260 |
| 261 enum InitializationState { | 261 enum InitializationState { |
| 262 NOT_INITIALIZED = 0, | 262 NOT_INITIALIZED = 0, |
| 263 INITIALIZING = 1, | 263 INITIALIZING = 1, |
| 264 INITIALIZED = 2 | 264 INITIALIZED = 2 |
| 265 }; | 265 }; |
| 266 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; | 266 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; |
| 267 typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap; | 267 typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap; |
| 268 typedef ResourcePrefetchPredictorTables::ManifestDataMap ManifestDataMap; |
| 268 | 269 |
| 269 typedef std::map<NavigationID, std::unique_ptr<PageRequestSummary>> | 270 typedef std::map<NavigationID, std::unique_ptr<PageRequestSummary>> |
| 270 NavigationMap; | 271 NavigationMap; |
| 271 | 272 |
| 272 // Returns true if the main page request is supported for prediction. | 273 // Returns true if the main page request is supported for prediction. |
| 273 static bool IsHandledMainPage(net::URLRequest* request); | 274 static bool IsHandledMainPage(net::URLRequest* request); |
| 274 | 275 |
| 275 // Returns true if the subresource request is supported for prediction. | 276 // Returns true if the subresource request is supported for prediction. |
| 276 static bool IsHandledSubresource(net::URLRequest* request, | 277 static bool IsHandledSubresource(net::URLRequest* request, |
| 277 content::ResourceType resource_type); | 278 content::ResourceType resource_type); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // prefetched. |urls| pointer may be equal nullptr to get return value only. | 317 // prefetched. |urls| pointer may be equal nullptr to get return value only. |
| 317 bool PopulatePrefetcherRequest(const std::string& main_frame_key, | 318 bool PopulatePrefetcherRequest(const std::string& main_frame_key, |
| 318 const PrefetchDataMap& data_map, | 319 const PrefetchDataMap& data_map, |
| 319 std::vector<GURL>* urls) const; | 320 std::vector<GURL>* urls) const; |
| 320 | 321 |
| 321 // Callback for task to read predictor database. Takes ownership of | 322 // Callback for task to read predictor database. Takes ownership of |
| 322 // all arguments. | 323 // all arguments. |
| 323 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, | 324 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, |
| 324 std::unique_ptr<PrefetchDataMap> host_data_map, | 325 std::unique_ptr<PrefetchDataMap> host_data_map, |
| 325 std::unique_ptr<RedirectDataMap> url_redirect_data_map, | 326 std::unique_ptr<RedirectDataMap> url_redirect_data_map, |
| 326 std::unique_ptr<RedirectDataMap> host_redirect_data_map); | 327 std::unique_ptr<RedirectDataMap> host_redirect_data_map, |
| 328 std::unique_ptr<ManifestDataMap> manifest_data_map); |
| 327 | 329 |
| 328 // Called during initialization when history is read and the predictor | 330 // Called during initialization when history is read and the predictor |
| 329 // database has been read. | 331 // database has been read. |
| 330 void OnHistoryAndCacheLoaded(); | 332 void OnHistoryAndCacheLoaded(); |
| 331 | 333 |
| 332 // Cleanup inflight_navigations_, inflight_prefetches_, and prefetcher_stats_. | 334 // Cleanup inflight_navigations_, inflight_prefetches_, and prefetcher_stats_. |
| 333 void CleanupAbandonedNavigations(const NavigationID& navigation_id); | 335 void CleanupAbandonedNavigations(const NavigationID& navigation_id); |
| 334 | 336 |
| 335 // Deletes all URLs from the predictor database, the caches and removes all | 337 // Deletes all URLs from the predictor database, the caches and removes all |
| 336 // inflight navigations. | 338 // inflight navigations. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 InitializationState initialization_state_; | 404 InitializationState initialization_state_; |
| 403 scoped_refptr<ResourcePrefetchPredictorTables> tables_; | 405 scoped_refptr<ResourcePrefetchPredictorTables> tables_; |
| 404 scoped_refptr<ResourcePrefetcherManager> prefetch_manager_; | 406 scoped_refptr<ResourcePrefetcherManager> prefetch_manager_; |
| 405 base::CancelableTaskTracker history_lookup_consumer_; | 407 base::CancelableTaskTracker history_lookup_consumer_; |
| 406 | 408 |
| 407 // Copy of the data in the predictor tables. | 409 // Copy of the data in the predictor tables. |
| 408 std::unique_ptr<PrefetchDataMap> url_table_cache_; | 410 std::unique_ptr<PrefetchDataMap> url_table_cache_; |
| 409 std::unique_ptr<PrefetchDataMap> host_table_cache_; | 411 std::unique_ptr<PrefetchDataMap> host_table_cache_; |
| 410 std::unique_ptr<RedirectDataMap> url_redirect_table_cache_; | 412 std::unique_ptr<RedirectDataMap> url_redirect_table_cache_; |
| 411 std::unique_ptr<RedirectDataMap> host_redirect_table_cache_; | 413 std::unique_ptr<RedirectDataMap> host_redirect_table_cache_; |
| 414 std::unique_ptr<ManifestDataMap> manifest_table_cache_; |
| 412 | 415 |
| 413 std::map<GURL, base::TimeTicks> inflight_prefetches_; | 416 std::map<GURL, base::TimeTicks> inflight_prefetches_; |
| 414 NavigationMap inflight_navigations_; | 417 NavigationMap inflight_navigations_; |
| 415 | 418 |
| 416 std::map<GURL, std::unique_ptr<ResourcePrefetcher::PrefetcherStats>> | 419 std::map<GURL, std::unique_ptr<ResourcePrefetcher::PrefetcherStats>> |
| 417 prefetcher_stats_; | 420 prefetcher_stats_; |
| 418 | 421 |
| 419 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 422 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 420 history_service_observer_; | 423 history_service_observer_; |
| 421 | 424 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 448 | 451 |
| 449 private: | 452 private: |
| 450 ResourcePrefetchPredictor* predictor_; | 453 ResourcePrefetchPredictor* predictor_; |
| 451 | 454 |
| 452 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 455 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 453 }; | 456 }; |
| 454 | 457 |
| 455 } // namespace predictors | 458 } // namespace predictors |
| 456 | 459 |
| 457 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 460 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |