| Index: chrome/browser/predictors/resource_prefetch_predictor.cc
|
| diff --git a/chrome/browser/predictors/resource_prefetch_predictor.cc b/chrome/browser/predictors/resource_prefetch_predictor.cc
|
| index 67dd25aec05b3071e51f0285cd1e853f4d21cc69..41497fe7c9a80dfa85d3a7ee640e583e282d5708 100644
|
| --- a/chrome/browser/predictors/resource_prefetch_predictor.cc
|
| +++ b/chrome/browser/predictors/resource_prefetch_predictor.cc
|
| @@ -150,6 +150,8 @@ void ReportPredictionAccuracy(
|
| precision_percentage);
|
| UMA_HISTOGRAM_PERCENTAGE(internal::kResourcePrefetchPredictorRecallHistogram,
|
| recall_percentage);
|
| + UMA_HISTOGRAM_COUNTS_100(internal::kResourcePrefetchPredictorCountHistogram,
|
| + predicted_urls.size());
|
| }
|
|
|
| } // namespace
|
| @@ -506,6 +508,12 @@ void ResourcePrefetchPredictor::StartPrefetching(const GURL& url,
|
| PrefetchOrigin origin) {
|
| TRACE_EVENT1("browser", "ResourcePrefetchPredictor::StartPrefetching", "url",
|
| url.spec());
|
| + // Save prefetch start time to report prefetching duration.
|
| + if (inflight_prefetches_.find(url) == inflight_prefetches_.end() &&
|
| + IsUrlPrefetchable(url)) {
|
| + inflight_prefetches_.insert(std::make_pair(url, base::TimeTicks::Now()));
|
| + }
|
| +
|
| if (!prefetch_manager_.get()) // Prefetching not enabled.
|
| return;
|
| if (!config_.IsPrefetchingEnabledForOrigin(profile_, origin))
|
| @@ -524,6 +532,13 @@ void ResourcePrefetchPredictor::StartPrefetching(const GURL& url,
|
| void ResourcePrefetchPredictor::StopPrefetching(const GURL& url) {
|
| TRACE_EVENT1("browser", "ResourcePrefetchPredictor::StopPrefetching", "url",
|
| url.spec());
|
| + auto it = inflight_prefetches_.find(url);
|
| + if (it != inflight_prefetches_.end()) {
|
| + UMA_HISTOGRAM_TIMES(
|
| + internal::kResourcePrefetchPredictorPrefetchingDurationHistogram,
|
| + base::TimeTicks::Now() - it->second);
|
| + inflight_prefetches_.erase(it);
|
| + }
|
| if (!prefetch_manager_.get()) // Not enabled.
|
| return;
|
|
|
| @@ -769,6 +784,14 @@ void ResourcePrefetchPredictor::CleanupAbandonedNavigations(
|
| ++it;
|
| }
|
| }
|
| +
|
| + for (auto it = inflight_prefetches_.begin();
|
| + it != inflight_prefetches_.end();) {
|
| + if (time_now - it->second > max_navigation_age)
|
| + it = inflight_prefetches_.erase(it);
|
| + else
|
| + ++it;
|
| + }
|
| }
|
|
|
| void ResourcePrefetchPredictor::DeleteAllUrls() {
|
|
|