| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 constexpr char kResourcePrefetchPredictorPrefetchHitsCountCached[] = | 55 constexpr char kResourcePrefetchPredictorPrefetchHitsCountCached[] = |
| 56 "ResourcePrefetchPredictor.PrefetchHitsCount.Cached"; | 56 "ResourcePrefetchPredictor.PrefetchHitsCount.Cached"; |
| 57 constexpr char kResourcePrefetchPredictorPrefetchHitsCountNotCached[] = | 57 constexpr char kResourcePrefetchPredictorPrefetchHitsCountNotCached[] = |
| 58 "ResourcePrefetchPredictor.PrefetchHitsCount.NotCached"; | 58 "ResourcePrefetchPredictor.PrefetchHitsCount.NotCached"; |
| 59 constexpr char kResourcePrefetchPredictorPrefetchHitsSize[] = | 59 constexpr char kResourcePrefetchPredictorPrefetchHitsSize[] = |
| 60 "ResourcePrefetchPredictor.PrefetchHitsSizeKB"; | 60 "ResourcePrefetchPredictor.PrefetchHitsSizeKB"; |
| 61 constexpr char kResourcePrefetchPredictorPrefetchMissesSize[] = | 61 constexpr char kResourcePrefetchPredictorPrefetchMissesSize[] = |
| 62 "ResourcePrefetchPredictor.PrefetchMissesSizeKB"; | 62 "ResourcePrefetchPredictor.PrefetchMissesSizeKB"; |
| 63 constexpr char kResourcePrefetchPredictorRedirectStatusHistogram[] = | 63 constexpr char kResourcePrefetchPredictorRedirectStatusHistogram[] = |
| 64 "ResourcePrefetchPredictor.RedirectStatus"; | 64 "ResourcePrefetchPredictor.RedirectStatus"; |
| 65 |
| 66 const uint32_t kUnusedRemovedExperiment = 0xf7f77166; |
| 65 } // namespace internal | 67 } // namespace internal |
| 66 | 68 |
| 67 class TestObserver; | 69 class TestObserver; |
| 68 class ResourcePrefetcherManager; | 70 class ResourcePrefetcherManager; |
| 69 | 71 |
| 70 // Contains logic for learning what can be prefetched and for kicking off | 72 // Contains logic for learning what can be prefetched and for kicking off |
| 71 // speculative prefetching. | 73 // speculative prefetching. |
| 72 // - The class is a profile keyed service owned by the profile. | 74 // - The class is a profile keyed service owned by the profile. |
| 73 // - All the non-static methods of this class need to be called on the UI | 75 // - All the non-static methods of this class need to be called on the UI |
| 74 // thread. | 76 // thread. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlInDB); | 271 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlInDB); |
| 270 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlNotInDB); | 272 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlNotInDB); |
| 271 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 273 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 272 NavigationUrlNotInDBAndDBFull); | 274 NavigationUrlNotInDBAndDBFull); |
| 273 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlNotInDB); | 275 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlNotInDB); |
| 274 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlInDB); | 276 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlInDB); |
| 275 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, ManifestHostNotInDB); | 277 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, ManifestHostNotInDB); |
| 276 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, ManifestHostInDB); | 278 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, ManifestHostInDB); |
| 277 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 279 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 278 ManifestHostNotInDBAndDBFull); | 280 ManifestHostNotInDBAndDBFull); |
| 281 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 282 ManifestUnusedRemoved); |
| 279 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest); | 283 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest); |
| 280 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect); | 284 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect); |
| 281 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 285 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 282 OnSubresourceResponse); | 286 OnSubresourceResponse); |
| 283 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); | 287 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); |
| 284 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes); | 288 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes); |
| 285 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 289 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 286 PopulatePrefetcherRequest); | 290 PopulatePrefetcherRequest); |
| 287 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint); | 291 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint); |
| 288 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData); | 292 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 432 |
| 429 // history::HistoryServiceObserver: | 433 // history::HistoryServiceObserver: |
| 430 void OnURLsDeleted(history::HistoryService* history_service, | 434 void OnURLsDeleted(history::HistoryService* history_service, |
| 431 bool all_history, | 435 bool all_history, |
| 432 bool expired, | 436 bool expired, |
| 433 const history::URLRows& deleted_rows, | 437 const history::URLRows& deleted_rows, |
| 434 const std::set<GURL>& favicon_urls) override; | 438 const std::set<GURL>& favicon_urls) override; |
| 435 void OnHistoryServiceLoaded( | 439 void OnHistoryServiceLoaded( |
| 436 history::HistoryService* history_service) override; | 440 history::HistoryService* history_service) override; |
| 437 | 441 |
| 442 // Updates list of resources in the |data_map| for the |key| according to the |
| 443 // |manifest|. |
| 444 void UpdatePrefetchDataByManifest(const std::string& key, |
| 445 PrefetchKeyType key_type, |
| 446 PrefetchDataMap* data_map, |
| 447 const precache::PrecacheManifest& manifest); |
| 448 |
| 438 // Used to connect to HistoryService or register for service loaded | 449 // Used to connect to HistoryService or register for service loaded |
| 439 // notificatioan. | 450 // notificatioan. |
| 440 void ConnectToHistoryService(); | 451 void ConnectToHistoryService(); |
| 441 | 452 |
| 442 // Used for testing to inject mock tables. | 453 // Used for testing to inject mock tables. |
| 443 void set_mock_tables(scoped_refptr<ResourcePrefetchPredictorTables> tables) { | 454 void set_mock_tables(scoped_refptr<ResourcePrefetchPredictorTables> tables) { |
| 444 tables_ = tables; | 455 tables_ = tables; |
| 445 } | 456 } |
| 446 | 457 |
| 447 Profile* const profile_; | 458 Profile* const profile_; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 509 |
| 499 private: | 510 private: |
| 500 ResourcePrefetchPredictor* predictor_; | 511 ResourcePrefetchPredictor* predictor_; |
| 501 | 512 |
| 502 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 513 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 503 }; | 514 }; |
| 504 | 515 |
| 505 } // namespace predictors | 516 } // namespace predictors |
| 506 | 517 |
| 507 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 518 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |