| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_LOADING_STATS_COLLECTOR_H_ | 5 #ifndef CHROME_BROWSER_PREDICTORS_LOADING_STATS_COLLECTOR_H_ |
| 6 #define CHROME_BROWSER_PREDICTORS_LOADING_STATS_COLLECTOR_H_ | 6 #define CHROME_BROWSER_PREDICTORS_LOADING_STATS_COLLECTOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | |
| 16 #include "chrome/browser/predictors/resource_prefetcher.h" | 15 #include "chrome/browser/predictors/resource_prefetcher.h" |
| 17 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 18 | 17 |
| 19 namespace predictors { | 18 namespace predictors { |
| 20 | 19 |
| 20 class ResourcePrefetchPredictor; |
| 21 struct LoadingPredictorConfig; |
| 22 struct PageRequestSummary; |
| 23 |
| 21 namespace internal { | 24 namespace internal { |
| 22 constexpr char kResourcePrefetchPredictorPrecisionHistogram[] = | 25 constexpr char kResourcePrefetchPredictorPrecisionHistogram[] = |
| 23 "ResourcePrefetchPredictor.LearningPrecision"; | 26 "ResourcePrefetchPredictor.LearningPrecision"; |
| 24 constexpr char kResourcePrefetchPredictorRecallHistogram[] = | 27 constexpr char kResourcePrefetchPredictorRecallHistogram[] = |
| 25 "ResourcePrefetchPredictor.LearningRecall"; | 28 "ResourcePrefetchPredictor.LearningRecall"; |
| 26 constexpr char kResourcePrefetchPredictorCountHistogram[] = | 29 constexpr char kResourcePrefetchPredictorCountHistogram[] = |
| 27 "ResourcePrefetchPredictor.LearningCount"; | 30 "ResourcePrefetchPredictor.LearningCount"; |
| 28 constexpr char kResourcePrefetchPredictorPrefetchMissesCountCached[] = | 31 constexpr char kResourcePrefetchPredictorPrefetchMissesCountCached[] = |
| 29 "ResourcePrefetchPredictor.PrefetchMissesCount.Cached"; | 32 "ResourcePrefetchPredictor.PrefetchMissesCount.Cached"; |
| 30 constexpr char kResourcePrefetchPredictorPrefetchMissesCountNotCached[] = | 33 constexpr char kResourcePrefetchPredictorPrefetchMissesCountNotCached[] = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 49 const LoadingPredictorConfig& config); | 52 const LoadingPredictorConfig& config); |
| 50 ~LoadingStatsCollector(); | 53 ~LoadingStatsCollector(); |
| 51 | 54 |
| 52 // Records statistics about a finished prefetching operation. | 55 // Records statistics about a finished prefetching operation. |
| 53 void RecordPrefetcherStats( | 56 void RecordPrefetcherStats( |
| 54 std::unique_ptr<ResourcePrefetcher::PrefetcherStats> stats); | 57 std::unique_ptr<ResourcePrefetcher::PrefetcherStats> stats); |
| 55 // Records a summary of a page load. The summary is collated with speculative | 58 // Records a summary of a page load. The summary is collated with speculative |
| 56 // actions taken for a given page load if any. The summary is compared with a | 59 // actions taken for a given page load if any. The summary is compared with a |
| 57 // prediction by ResourcePrefetchPredictor as well. | 60 // prediction by ResourcePrefetchPredictor as well. |
| 58 // All results are reported to UMA. | 61 // All results are reported to UMA. |
| 59 void RecordPageRequestSummary( | 62 void RecordPageRequestSummary(const PageRequestSummary& summary); |
| 60 const ResourcePrefetchPredictor::PageRequestSummary& summary); | |
| 61 // Evicts all stale stats that are kept in memory. All speculative actions are | 63 // Evicts all stale stats that are kept in memory. All speculative actions are |
| 62 // reported and considered as waste. | 64 // reported and considered as waste. |
| 63 void CleanupAbandonedStats(); | 65 void CleanupAbandonedStats(); |
| 64 | 66 |
| 65 private: | 67 private: |
| 66 ResourcePrefetchPredictor* predictor_; | 68 ResourcePrefetchPredictor* predictor_; |
| 67 base::TimeDelta max_stats_age_; | 69 base::TimeDelta max_stats_age_; |
| 68 std::map<GURL, std::unique_ptr<ResourcePrefetcher::PrefetcherStats>> | 70 std::map<GURL, std::unique_ptr<ResourcePrefetcher::PrefetcherStats>> |
| 69 prefetcher_stats_; | 71 prefetcher_stats_; |
| 70 | 72 |
| 71 DISALLOW_COPY_AND_ASSIGN(LoadingStatsCollector); | 73 DISALLOW_COPY_AND_ASSIGN(LoadingStatsCollector); |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 } // namespace predictors | 76 } // namespace predictors |
| 75 | 77 |
| 76 #endif // CHROME_BROWSER_PREDICTORS_LOADING_STATS_COLLECTOR_H_ | 78 #endif // CHROME_BROWSER_PREDICTORS_LOADING_STATS_COLLECTOR_H_ |
| OLD | NEW |