| 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, PopulateFromManifest); |
| 291 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint); | 294 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint); |
| 292 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData); | 295 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData); |
| 293 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 296 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 294 TestPrecisionRecallHistograms); | 297 TestPrecisionRecallHistograms); |
| 295 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 298 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 296 TestPrefetchingDurationHistogram); | 299 TestPrefetchingDurationHistogram); |
| 297 | 300 |
| 298 enum InitializationState { | 301 enum InitializationState { |
| 299 NOT_INITIALIZED = 0, | 302 NOT_INITIALIZED = 0, |
| 300 INITIALIZING = 1, | 303 INITIALIZING = 1, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 355 |
| 353 // Returns true iff there is PrefetchData that can be used for a | 356 // Returns true iff there is PrefetchData that can be used for a |
| 354 // |main_frame_url| and fills |prediction| with resources that need to be | 357 // |main_frame_url| and fills |prediction| with resources that need to be |
| 355 // prefetched. |prediction| pointer may be equal nullptr to get return value | 358 // prefetched. |prediction| pointer may be equal nullptr to get return value |
| 356 // only. | 359 // only. |
| 357 bool GetPrefetchData(const GURL& main_frame_url, | 360 bool GetPrefetchData(const GURL& main_frame_url, |
| 358 Prediction* prediction) const; | 361 Prediction* prediction) const; |
| 359 | 362 |
| 360 // Returns true iff the |data_map| contains PrefetchData that can be used | 363 // 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 | 364 // 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. | 365 // prefetched. |urls| may be nullptr to get the return value only. |
| 363 bool PopulatePrefetcherRequest(const std::string& main_frame_key, | 366 bool PopulatePrefetcherRequest(const std::string& main_frame_key, |
| 364 const PrefetchDataMap& data_map, | 367 const PrefetchDataMap& data_map, |
| 365 std::vector<GURL>* urls) const; | 368 std::vector<GURL>* urls) const; |
| 366 | 369 |
| 370 // Returns true iff the manifest table contains PrecacheManifest that can be |
| 371 // used for a |manifest_host| and fills |urls| with resources that need to be |
| 372 // prefetched. |urls| may be nullptr to get the return value only. |
| 373 bool PopulateFromManifest(const std::string& manifest_host, |
| 374 std::vector<GURL>* urls) const; |
| 375 |
| 367 // Callback for task to read predictor database. Takes ownership of | 376 // Callback for task to read predictor database. Takes ownership of |
| 368 // all arguments. | 377 // all arguments. |
| 369 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, | 378 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, |
| 370 std::unique_ptr<PrefetchDataMap> host_data_map, | 379 std::unique_ptr<PrefetchDataMap> host_data_map, |
| 371 std::unique_ptr<RedirectDataMap> url_redirect_data_map, | 380 std::unique_ptr<RedirectDataMap> url_redirect_data_map, |
| 372 std::unique_ptr<RedirectDataMap> host_redirect_data_map, | 381 std::unique_ptr<RedirectDataMap> host_redirect_data_map, |
| 373 std::unique_ptr<ManifestDataMap> manifest_data_map, | 382 std::unique_ptr<ManifestDataMap> manifest_data_map, |
| 374 std::unique_ptr<OriginDataMap> origin_data_map); | 383 std::unique_ptr<OriginDataMap> origin_data_map); |
| 375 | 384 |
| 376 // Called during initialization when history is read and the predictor | 385 // Called during initialization when history is read and the predictor |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 | 518 |
| 510 private: | 519 private: |
| 511 ResourcePrefetchPredictor* predictor_; | 520 ResourcePrefetchPredictor* predictor_; |
| 512 | 521 |
| 513 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 522 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 514 }; | 523 }; |
| 515 | 524 |
| 516 } // namespace predictors | 525 } // namespace predictors |
| 517 | 526 |
| 518 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 527 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |