Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 65 |
| 66 const uint32_t kVersionedRemovedExperiment = 0x03ff25e3; | |
| 66 const uint32_t kUnusedRemovedExperiment = 0xf7f77166; | 67 const uint32_t kUnusedRemovedExperiment = 0xf7f77166; |
| 68 const uint32_t kNoStoreRemovedExperiment = 0xd90a199a; | |
| 67 } // namespace internal | 69 } // namespace internal |
| 68 | 70 |
| 69 class TestObserver; | 71 class TestObserver; |
| 70 class ResourcePrefetcherManager; | 72 class ResourcePrefetcherManager; |
| 71 | 73 |
| 72 // Contains logic for learning what can be prefetched and for kicking off | 74 // Contains logic for learning what can be prefetched and for kicking off |
| 73 // speculative prefetching. | 75 // speculative prefetching. |
| 74 // - The class is a profile keyed service owned by the profile. | 76 // - The class is a profile keyed service owned by the profile. |
| 75 // - All the non-static methods of this class need to be called on the UI | 77 // - All the non-static methods of this class need to be called on the UI |
| 76 // thread. | 78 // thread. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 283 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 282 ManifestUnusedRemoved); | 284 ManifestUnusedRemoved); |
| 283 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest); | 285 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest); |
| 284 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect); | 286 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect); |
| 285 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 287 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 286 OnSubresourceResponse); | 288 OnSubresourceResponse); |
| 287 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); | 289 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); |
| 288 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes); | 290 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes); |
| 289 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 291 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 290 PopulatePrefetcherRequest); | 292 PopulatePrefetcherRequest); |
| 293 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | |
| 294 PopulatePrefetcherRequestByManifest); | |
| 291 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint); | 295 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint); |
| 292 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData); | 296 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData); |
| 293 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 297 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 294 TestPrecisionRecallHistograms); | 298 TestPrecisionRecallHistograms); |
| 295 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 299 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 296 TestPrefetchingDurationHistogram); | 300 TestPrefetchingDurationHistogram); |
| 297 | 301 |
| 298 enum InitializationState { | 302 enum InitializationState { |
| 299 NOT_INITIALIZED = 0, | 303 NOT_INITIALIZED = 0, |
| 300 INITIALIZING = 1, | 304 INITIALIZING = 1, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 bool GetPrefetchData(const GURL& main_frame_url, | 361 bool GetPrefetchData(const GURL& main_frame_url, |
| 358 Prediction* prediction) const; | 362 Prediction* prediction) const; |
| 359 | 363 |
| 360 // Returns true iff the |data_map| contains PrefetchData that can be used | 364 // Returns true iff the |data_map| contains PrefetchData that can be used |
| 361 // for a |main_frame_key| and fills |urls| with resources that need to be | 365 // for a |main_frame_key| and fills |urls| with resources that need to be |
| 362 // prefetched. |urls| pointer may be equal nullptr to get return value only. | 366 // prefetched. |urls| pointer may be equal nullptr to get return value only. |
| 363 bool PopulatePrefetcherRequest(const std::string& main_frame_key, | 367 bool PopulatePrefetcherRequest(const std::string& main_frame_key, |
| 364 const PrefetchDataMap& data_map, | 368 const PrefetchDataMap& data_map, |
| 365 std::vector<GURL>* urls) const; | 369 std::vector<GURL>* urls) const; |
| 366 | 370 |
| 371 // Returns true iff the manifest table contains PrecacheManifest that can be | |
| 372 // used for a |manifest_host| and fills |urls| with resources that need to be | |
| 373 // prefetched. |urls| pointer may be equal nullptr to get return value only. | |
|
Benoit L
2017/04/18 16:28:39
nit: |urls| may be nullptr to get the return value
alexilin
2017/04/19 07:59:25
Done.
| |
| 374 bool PopulatePrefetcherRequestByManifest(const std::string& manifest_host, | |
| 375 std::vector<GURL>* urls) const; | |
|
Benoit L
2017/04/18 16:28:39
nit: PopulateFromManifest()?
alexilin
2017/04/19 07:59:25
Done.
| |
| 376 | |
| 367 // Callback for task to read predictor database. Takes ownership of | 377 // Callback for task to read predictor database. Takes ownership of |
| 368 // all arguments. | 378 // all arguments. |
| 369 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, | 379 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, |
| 370 std::unique_ptr<PrefetchDataMap> host_data_map, | 380 std::unique_ptr<PrefetchDataMap> host_data_map, |
| 371 std::unique_ptr<RedirectDataMap> url_redirect_data_map, | 381 std::unique_ptr<RedirectDataMap> url_redirect_data_map, |
| 372 std::unique_ptr<RedirectDataMap> host_redirect_data_map, | 382 std::unique_ptr<RedirectDataMap> host_redirect_data_map, |
| 373 std::unique_ptr<ManifestDataMap> manifest_data_map, | 383 std::unique_ptr<ManifestDataMap> manifest_data_map, |
| 374 std::unique_ptr<OriginDataMap> origin_data_map); | 384 std::unique_ptr<OriginDataMap> origin_data_map); |
| 375 | 385 |
| 376 // Called during initialization when history is read and the predictor | 386 // Called during initialization when history is read and the predictor |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 | 519 |
| 510 private: | 520 private: |
| 511 ResourcePrefetchPredictor* predictor_; | 521 ResourcePrefetchPredictor* predictor_; |
| 512 | 522 |
| 513 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 523 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 514 }; | 524 }; |
| 515 | 525 |
| 516 } // namespace predictors | 526 } // namespace predictors |
| 517 | 527 |
| 518 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 528 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |