OLD | NEW |
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 Loading... |
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) { |
| 180 config->max_urls_to_track = 3; |
| 181 config->max_hosts_to_track = 2; |
| 182 config->min_url_visit_count = 2; |
| 183 config->max_resources_per_entry = 4; |
| 184 config->max_consecutive_misses = 2; |
| 185 config->max_redirect_consecutive_misses = 2; |
| 186 config->min_resource_confidence_to_trigger_prefetch = 0.5; |
| 187 config->is_url_learning_enabled = true; |
| 188 config->is_manifests_enabled = true; |
| 189 config->is_origin_learning_enabled = true; |
| 190 config->mode = LoadingPredictorConfig::LEARNING; |
| 191 } |
| 192 |
179 std::ostream& operator<<(std::ostream& os, const PrefetchData& data) { | 193 std::ostream& operator<<(std::ostream& os, const PrefetchData& data) { |
180 os << "[" << data.primary_key() << "," << data.last_visit_time() << "]" | 194 os << "[" << data.primary_key() << "," << data.last_visit_time() << "]" |
181 << std::endl; | 195 << std::endl; |
182 for (const ResourceData& resource : data.resources()) | 196 for (const ResourceData& resource : data.resources()) |
183 os << "\t\t" << resource << std::endl; | 197 os << "\t\t" << resource << std::endl; |
184 return os; | 198 return os; |
185 } | 199 } |
186 | 200 |
187 std::ostream& operator<<(std::ostream& os, const ResourceData& resource) { | 201 std::ostream& operator<<(std::ostream& os, const ResourceData& resource) { |
188 return os << "[" << resource.resource_url() << "," << resource.resource_type() | 202 return os << "[" << resource.resource_url() << "," << resource.resource_type() |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 375 |
362 return equal; | 376 return equal; |
363 } | 377 } |
364 | 378 |
365 bool operator==(const PrecacheResource& lhs, const PrecacheResource& rhs) { | 379 bool operator==(const PrecacheResource& lhs, const PrecacheResource& rhs) { |
366 return lhs.url() == rhs.url() && | 380 return lhs.url() == rhs.url() && |
367 AlmostEqual(lhs.weight_ratio(), rhs.weight_ratio()); | 381 AlmostEqual(lhs.weight_ratio(), rhs.weight_ratio()); |
368 } | 382 } |
369 | 383 |
370 } // namespace precache | 384 } // namespace precache |
OLD | NEW |