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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_test_util.cc

Issue 2815513011: predictors: Remove resources marked as unused. (Closed)
Patch Set: Remove unused constants. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 namespace { 9 namespace {
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 bool accessed_network) { 69 bool accessed_network) {
70 origin_stat->set_origin(origin); 70 origin_stat->set_origin(origin);
71 origin_stat->set_number_of_hits(number_of_hits); 71 origin_stat->set_number_of_hits(number_of_hits);
72 origin_stat->set_number_of_misses(number_of_misses); 72 origin_stat->set_number_of_misses(number_of_misses);
73 origin_stat->set_consecutive_misses(consecutive_misses); 73 origin_stat->set_consecutive_misses(consecutive_misses);
74 origin_stat->set_average_position(average_position); 74 origin_stat->set_average_position(average_position);
75 origin_stat->set_always_access_network(always_access_network); 75 origin_stat->set_always_access_network(always_access_network);
76 origin_stat->set_accessed_network(accessed_network); 76 origin_stat->set_accessed_network(accessed_network);
77 } 77 }
78 78
79 void InitializeExperiment(precache::PrecacheManifest* manifest,
80 uint32_t experiment_id,
81 const std::vector<bool>& bitset) {
82 std::string binary_bitset;
83 for (size_t i = 0; i < (bitset.size() + 7) / 8; ++i) {
Benoit L 2017/04/14 08:26:56 The most likely representation of vector<bool> is
alexilin 2017/04/14 09:55:22 The world is not perfect. Especially, C++ world. W
84 char c = 0;
85 for (size_t j = 0; j < 8; ++j) {
86 if (i * 8 + j < bitset.size() && bitset[i * 8 + j])
87 c |= (1 << j);
88 }
89 binary_bitset.push_back(c);
90 }
91
92 precache::PrecacheResourceSelection prs;
93 prs.set_bitset(binary_bitset);
94 (*manifest->mutable_experiments()
95 ->mutable_resources_by_experiment_group())[experiment_id] = prs;
96 }
97
79 PrefetchData CreatePrefetchData(const std::string& primary_key, 98 PrefetchData CreatePrefetchData(const std::string& primary_key,
80 uint64_t last_visit_time) { 99 uint64_t last_visit_time) {
81 PrefetchData data; 100 PrefetchData data;
82 data.set_primary_key(primary_key); 101 data.set_primary_key(primary_key);
83 data.set_last_visit_time(last_visit_time); 102 data.set_last_visit_time(last_visit_time);
84 return data; 103 return data;
85 } 104 }
86 105
87 RedirectData CreateRedirectData(const std::string& primary_key, 106 RedirectData CreateRedirectData(const std::string& primary_key,
88 uint64_t last_visit_time) { 107 uint64_t last_visit_time) {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 354
336 return equal; 355 return equal;
337 } 356 }
338 357
339 bool operator==(const PrecacheResource& lhs, const PrecacheResource& rhs) { 358 bool operator==(const PrecacheResource& lhs, const PrecacheResource& rhs) {
340 return lhs.url() == rhs.url() && 359 return lhs.url() == rhs.url() &&
341 AlmostEqual(lhs.weight_ratio(), rhs.weight_ratio()); 360 AlmostEqual(lhs.weight_ratio(), rhs.weight_ratio());
342 } 361 }
343 362
344 } // namespace precache 363 } // namespace precache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698