Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(730)

Unified Diff: components/precache/core/precache_fetcher.cc

Issue 2707053005: precache: Fix top_resources_count + experiments. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..56bec9ff45e51de96cb826022eb24b552dd94dcb 100644
--- a/components/precache/core/precache_fetcher.cc
+++ b/components/precache/core/precache_fetcher.cc
@@ -743,12 +743,13 @@ void PrecacheFetcher::OnManifestFetchComplete(int64_t host_visits,
PrecacheManifest manifest;
if (ParseProtoFromFetchResponse(*source.network_url_fetcher(), &manifest)) {
- const int32_t len =
- std::min(manifest.resource_size(),
- unfinished_work_->config_settings().top_resources_count());
const uint64_t resource_bitset =
GetResourceBitset(manifest, experiment_id_);
- for (int i = 0; i < len; ++i) {
+ const int32_t max_to_include =
+ unfinished_work_->config_settings().top_resources_count();
+ int32_t num_included = 0;
+ for (int i = 0;
+ i < manifest.resource_size() && num_included < max_to_include; ++i) {
if (((0x1ULL << i) & resource_bitset) &&
manifest.resource(i).has_url()) {
GURL url(manifest.resource(i).url());
@@ -756,8 +757,10 @@ void PrecacheFetcher::OnManifestFetchComplete(int64_t host_visits,
double weight = ResourceWeight(
unfinished_work_->config_settings().resource_weight_function(),
manifest.resource(i).weight_ratio(), host_visits);
- if (weight >= unfinished_work_->config_settings().min_weight())
+ if (weight >= unfinished_work_->config_settings().min_weight()) {
resources_to_rank_.emplace_back(url, source.referrer(), weight);
+ ++num_included;
bengr 2017/02/24 21:04:13 nit: I would be a bit clearer: num_included -> inc
twifkak 2017/02/24 21:35:55 Done.
+ }
}
}
}
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698