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

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

Issue 2887133003: predictors: Refactor resource_prefetch_predictor triggering. (Closed)
Patch Set: . Created 3 years, 6 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 summary.was_cached = was_cached; 169 summary.was_cached = was_cached;
170 if (!redirect_url.empty()) 170 if (!redirect_url.empty())
171 summary.redirect_url = GURL(redirect_url); 171 summary.redirect_url = GURL(redirect_url);
172 summary.has_validators = has_validators; 172 summary.has_validators = has_validators;
173 summary.always_revalidate = always_revalidate; 173 summary.always_revalidate = always_revalidate;
174 summary.is_no_store = false; 174 summary.is_no_store = false;
175 summary.network_accessed = true; 175 summary.network_accessed = true;
176 return summary; 176 return summary;
177 } 177 }
178 178
179 void PopulateTestConfig(LoadingPredictorConfig* config, bool small_db) {
180 if (small_db) {
181 config->max_urls_to_track = 3;
182 config->max_hosts_to_track = 2;
183 config->min_url_visit_count = 2;
184 config->max_resources_per_entry = 4;
185 config->max_consecutive_misses = 2;
186 config->max_redirect_consecutive_misses = 2;
187 config->min_resource_confidence_to_trigger_prefetch = 0.5;
188 }
189 config->is_url_learning_enabled = true;
190 config->is_manifests_enabled = true;
191 config->is_origin_learning_enabled = true;
192 config->mode = LoadingPredictorConfig::LEARNING;
193 }
194
179 std::ostream& operator<<(std::ostream& os, const PrefetchData& data) { 195 std::ostream& operator<<(std::ostream& os, const PrefetchData& data) {
180 os << "[" << data.primary_key() << "," << data.last_visit_time() << "]" 196 os << "[" << data.primary_key() << "," << data.last_visit_time() << "]"
181 << std::endl; 197 << std::endl;
182 for (const ResourceData& resource : data.resources()) 198 for (const ResourceData& resource : data.resources())
183 os << "\t\t" << resource << std::endl; 199 os << "\t\t" << resource << std::endl;
184 return os; 200 return os;
185 } 201 }
186 202
187 std::ostream& operator<<(std::ostream& os, const ResourceData& resource) { 203 std::ostream& operator<<(std::ostream& os, const ResourceData& resource) {
188 return os << "[" << resource.resource_url() << "," << resource.resource_type() 204 return os << "[" << resource.resource_url() << "," << resource.resource_type()
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 377
362 return equal; 378 return equal;
363 } 379 }
364 380
365 bool operator==(const PrecacheResource& lhs, const PrecacheResource& rhs) { 381 bool operator==(const PrecacheResource& lhs, const PrecacheResource& rhs) {
366 return lhs.url() == rhs.url() && 382 return lhs.url() == rhs.url() &&
367 AlmostEqual(lhs.weight_ratio(), rhs.weight_ratio()); 383 AlmostEqual(lhs.weight_ratio(), rhs.weight_ratio());
368 } 384 }
369 385
370 } // namespace precache 386 } // namespace precache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698