Index: components/precache/core/precache_fetcher.cc |
diff --git a/components/precache/core/precache_fetcher.cc b/components/precache/core/precache_fetcher.cc |
index 0bc2e1b2b40cb1e2c17a5bfdf84000c00aec1a08..e13d85649ca576239dc99d4707687f1d53b5e614 100644 |
--- a/components/precache/core/precache_fetcher.cc |
+++ b/components/precache/core/precache_fetcher.cc |
@@ -392,7 +392,8 @@ void PrecacheFetcher::Fetcher::OnURLFetchComplete( |
void PrecacheFetcher::RecordCompletionStatistics( |
const PrecacheUnfinishedWork& unfinished_work, |
size_t remaining_manifest_urls_to_fetch, |
- size_t remaining_resource_urls_to_fetch) { |
+ size_t remaining_resource_urls_to_fetch, |
+ base::Optional<double> min_weight_fetched) { |
// These may be unset in tests. |
if (!unfinished_work.has_start_time()) |
return; |
@@ -419,6 +420,11 @@ void PrecacheFetcher::RecordCompletionStatistics( |
UMA_HISTOGRAM_CUSTOM_COUNTS("Precache.Fetch.ResponseBytes.Network", |
unfinished_work.network_bytes(), 1, |
kMaxResponseBytes, 100); |
+ |
+ if (min_weight_fetched.has_value()) { |
+ UMA_HISTOGRAM_COUNTS_1000("Precache.Fetch.MinWeight", |
+ min_weight_fetched.value() * 1000); |
twifkak
2017/02/22 18:20:00
BTW, the bucket boundaries will look approximately
|
+ } |
} |
// static |
@@ -561,12 +567,12 @@ void PrecacheFetcher::StartNextManifestFetches() { |
} |
} |
-void PrecacheFetcher::NotifyDone( |
- size_t remaining_manifest_urls_to_fetch, |
- size_t remaining_resource_urls_to_fetch) { |
- RecordCompletionStatistics(*unfinished_work_, |
- remaining_manifest_urls_to_fetch, |
- remaining_resource_urls_to_fetch); |
+void PrecacheFetcher::NotifyDone(size_t remaining_manifest_urls_to_fetch, |
+ size_t remaining_resource_urls_to_fetch, |
+ base::Optional<double> min_weight_fetched) { |
+ RecordCompletionStatistics( |
+ *unfinished_work_, remaining_manifest_urls_to_fetch, |
+ remaining_resource_urls_to_fetch, min_weight_fetched); |
precache_delegate_->OnDone(); |
} |
@@ -578,8 +584,13 @@ void PrecacheFetcher::StartNextFetch() { |
unfinished_work_->config_settings().max_bytes_total()) || |
quota_.remaining() == 0) { |
pool_.DeleteAll(); |
+ base::Optional<double> min_weight; |
+ if (unfinished_work_->config_settings().global_ranking() && |
+ !resources_to_fetch_.empty()) |
jamartin
2017/02/22 22:54:07
If resources_to_fetch_.empty(), shouldn't you repo
twifkak
2017/02/23 23:28:41
Yes. This is a bit of an edge case, I think. If th
|
+ min_weight.emplace(resources_to_fetch_.front().weight); |
NotifyDone(top_hosts_to_fetch_.size() + top_hosts_fetching_.size(), |
- resources_to_fetch_.size() + resources_fetching_.size()); |
+ resources_to_fetch_.size() + resources_fetching_.size(), |
+ min_weight); |
jamartin
2017/02/22 22:54:07
I wonder if we may want to report also the rank di
twifkak
2017/02/23 23:28:41
The problem is that rank 23 for host A may mean so
|
return; |
} |
@@ -588,7 +599,10 @@ void PrecacheFetcher::StartNextFetch() { |
if (top_hosts_to_fetch_.empty() && resources_to_fetch_.empty() && |
pool_.IsEmpty()) { |
// There are no more URLs to fetch, so end the precache cycle. |
- NotifyDone(0, 0); |
+ base::Optional<double> min_weight; |
+ if (unfinished_work_->config_settings().global_ranking()) |
+ min_weight.emplace(0); |
jamartin
2017/02/22 22:54:07
(nit/opt) I prefer min_weight = 0.
twifkak
2017/02/23 23:28:42
Me too. Somehow I missed operator= when scanning t
|
+ NotifyDone(0, 0, min_weight); |
// OnDone may have deleted this PrecacheFetcher, so don't do anything after |
// it is called. |
} |
@@ -660,7 +674,7 @@ void PrecacheFetcher::OnManifestInfoRetrieved( |
// is invalid. |
top_hosts_to_fetch_.clear(); |
unfinished_work_->set_num_manifest_urls(manifests_info.size()); |
- NotifyDone(manifests_info.size(), resources_to_rank_.size()); |
+ NotifyDone(manifests_info.size(), resources_to_rank_.size(), base::nullopt); |
return; |
} |