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 25 matching lines...) Expand all Loading... | |
| 36 class URLRequest; | 36 class URLRequest; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace predictors { | 39 namespace predictors { |
| 40 | 40 |
| 41 namespace internal { | 41 namespace internal { |
| 42 constexpr char kResourcePrefetchPredictorPrecisionHistogram[] = | 42 constexpr char kResourcePrefetchPredictorPrecisionHistogram[] = |
| 43 "ResourcePrefetchPredictor.LearningPrecision"; | 43 "ResourcePrefetchPredictor.LearningPrecision"; |
| 44 constexpr char kResourcePrefetchPredictorRecallHistogram[] = | 44 constexpr char kResourcePrefetchPredictorRecallHistogram[] = |
| 45 "ResourcePrefetchPredictor.LearningRecall"; | 45 "ResourcePrefetchPredictor.LearningRecall"; |
| 46 constexpr char kResourcePrefetchPredictorCountHistogram[] = | |
| 47 "ResourcePrefetchPredictor.LearningCount"; | |
| 48 constexpr char kResourcePrefetchPredictorPrefetchingDurationHistogram[] = | |
| 49 "ResourcePrefetchPredictor.PrefetchingDuration"; | |
| 46 } // namespace internal | 50 } // namespace internal |
| 47 | 51 |
| 48 class TestObserver; | 52 class TestObserver; |
| 49 class ResourcePrefetcherManager; | 53 class ResourcePrefetcherManager; |
| 50 | 54 |
| 51 // Contains logic for learning what can be prefetched and for kicking off | 55 // Contains logic for learning what can be prefetched and for kicking off |
| 52 // speculative prefetching. | 56 // speculative prefetching. |
| 53 // - The class is a profile keyed service owned by the profile. | 57 // - The class is a profile keyed service owned by the profile. |
| 54 // - All the non-static methods of this class need to be called on the UI | 58 // - All the non-static methods of this class need to be called on the UI |
| 55 // thread. | 59 // thread. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 207 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 204 OnSubresourceResponse); | 208 OnSubresourceResponse); |
| 205 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); | 209 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); |
| 206 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes); | 210 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes); |
| 207 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 211 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 208 PopulatePrefetcherRequest); | 212 PopulatePrefetcherRequest); |
| 209 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint); | 213 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint); |
| 210 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData); | 214 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData); |
| 211 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 215 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 212 TestPrecisionRecallHistograms); | 216 TestPrecisionRecallHistograms); |
| 217 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | |
| 218 TestPrefetchingDurationHistogram); | |
| 213 | 219 |
| 214 enum InitializationState { | 220 enum InitializationState { |
| 215 NOT_INITIALIZED = 0, | 221 NOT_INITIALIZED = 0, |
| 216 INITIALIZING = 1, | 222 INITIALIZING = 1, |
| 217 INITIALIZED = 2 | 223 INITIALIZED = 2 |
| 218 }; | 224 }; |
| 219 | 225 |
| 220 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; | 226 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; |
| 221 typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap; | 227 typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap; |
| 222 | 228 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, | 282 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, |
| 277 std::unique_ptr<PrefetchDataMap> host_data_map, | 283 std::unique_ptr<PrefetchDataMap> host_data_map, |
| 278 std::unique_ptr<RedirectDataMap> url_redirect_data_map, | 284 std::unique_ptr<RedirectDataMap> url_redirect_data_map, |
| 279 std::unique_ptr<RedirectDataMap> host_redirect_data_map); | 285 std::unique_ptr<RedirectDataMap> host_redirect_data_map); |
| 280 | 286 |
| 281 // Called during initialization when history is read and the predictor | 287 // Called during initialization when history is read and the predictor |
| 282 // database has been read. | 288 // database has been read. |
| 283 void OnHistoryAndCacheLoaded(); | 289 void OnHistoryAndCacheLoaded(); |
| 284 | 290 |
| 285 // Removes data for navigations where the onload never fired. Will cleanup | 291 // Removes data for navigations where the onload never fired. Will cleanup |
| 286 // inflight_navigations_. | 292 // inflight_navigations_ and inflight_prefetchings_. |
|
Benoit L
2017/02/09 02:24:52
nit: s/prefetchings/prefetches/
alexilin
2017/02/09 15:50:19
Done.
| |
| 287 void CleanupAbandonedNavigations(const NavigationID& navigation_id); | 293 void CleanupAbandonedNavigations(const NavigationID& navigation_id); |
| 288 | 294 |
| 289 // Deletes all URLs from the predictor database, the caches and removes all | 295 // Deletes all URLs from the predictor database, the caches and removes all |
| 290 // inflight navigations. | 296 // inflight navigations. |
| 291 void DeleteAllUrls(); | 297 void DeleteAllUrls(); |
| 292 | 298 |
| 293 // Deletes data for the input |urls| and their corresponding hosts from the | 299 // Deletes data for the input |urls| and their corresponding hosts from the |
| 294 // predictor database and caches. | 300 // predictor database and caches. |
| 295 void DeleteUrls(const history::URLRows& urls); | 301 void DeleteUrls(const history::URLRows& urls); |
| 296 | 302 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 scoped_refptr<ResourcePrefetchPredictorTables> tables_; | 363 scoped_refptr<ResourcePrefetchPredictorTables> tables_; |
| 358 scoped_refptr<ResourcePrefetcherManager> prefetch_manager_; | 364 scoped_refptr<ResourcePrefetcherManager> prefetch_manager_; |
| 359 base::CancelableTaskTracker history_lookup_consumer_; | 365 base::CancelableTaskTracker history_lookup_consumer_; |
| 360 | 366 |
| 361 // Copy of the data in the predictor tables. | 367 // Copy of the data in the predictor tables. |
| 362 std::unique_ptr<PrefetchDataMap> url_table_cache_; | 368 std::unique_ptr<PrefetchDataMap> url_table_cache_; |
| 363 std::unique_ptr<PrefetchDataMap> host_table_cache_; | 369 std::unique_ptr<PrefetchDataMap> host_table_cache_; |
| 364 std::unique_ptr<RedirectDataMap> url_redirect_table_cache_; | 370 std::unique_ptr<RedirectDataMap> url_redirect_table_cache_; |
| 365 std::unique_ptr<RedirectDataMap> host_redirect_table_cache_; | 371 std::unique_ptr<RedirectDataMap> host_redirect_table_cache_; |
| 366 | 372 |
| 373 std::map<GURL, base::TimeTicks> inflight_prefetchings_; | |
|
Benoit L
2017/02/09 02:24:52
nit: ditto, for the renaming.
alexilin
2017/02/09 15:50:19
Done.
| |
| 367 NavigationMap inflight_navigations_; | 374 NavigationMap inflight_navigations_; |
| 368 | 375 |
| 369 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 376 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 370 history_service_observer_; | 377 history_service_observer_; |
| 371 | 378 |
| 372 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); | 379 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); |
| 373 }; | 380 }; |
| 374 | 381 |
| 375 // An interface used to notify that data in the ResourcePrefetchPredictor | 382 // An interface used to notify that data in the ResourcePrefetchPredictor |
| 376 // has changed. All methods are invoked on the UI thread. | 383 // has changed. All methods are invoked on the UI thread. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 394 | 401 |
| 395 private: | 402 private: |
| 396 ResourcePrefetchPredictor* predictor_; | 403 ResourcePrefetchPredictor* predictor_; |
| 397 | 404 |
| 398 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 405 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 399 }; | 406 }; |
| 400 | 407 |
| 401 } // namespace predictors | 408 } // namespace predictors |
| 402 | 409 |
| 403 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 410 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |