Chromium Code Reviews| 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 "chrome/browser/predictors/resource_prefetch_predictor_tables.h" | 7 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" |
| 8 | 8 |
| 9 namespace predictors { | 9 namespace predictors { |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 } | 50 } |
| 51 | 51 |
| 52 RedirectData CreateRedirectData(const std::string& primary_key, | 52 RedirectData CreateRedirectData(const std::string& primary_key, |
| 53 uint64_t last_visit_time) { | 53 uint64_t last_visit_time) { |
| 54 RedirectData data; | 54 RedirectData data; |
| 55 data.set_primary_key(primary_key); | 55 data.set_primary_key(primary_key); |
| 56 data.set_last_visit_time(last_visit_time); | 56 data.set_last_visit_time(last_visit_time); |
| 57 return data; | 57 return data; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void PrintTo(const PrefetchData& data, ::std::ostream* os) { | 60 std::ostream& operator<<(std::ostream& os, const PrefetchData& data) { |
| 61 *os << "[" << data.primary_key() << "," << data.last_visit_time() << "]\n"; | 61 os << "[" << data.primary_key() << "," << data.last_visit_time() << "]\n"; |
| 62 for (const ResourceData& resource : data.resources()) { | 62 for (const ResourceData& resource : data.resources()) |
| 63 *os << "\t\t"; | 63 os << "\t\t" << resource << "\n"; |
|
pasko
2016/10/17 14:46:42
nit: std::endl instead of '\n' for extra pretty on
alexilin
2016/10/17 15:32:35
Uh, I've thought that std::endl is kinda undesirab
pasko
2016/10/17 16:09:19
TIL:
1. std::endl also does flushing of the buffer
| |
| 64 PrintTo(resource, os); | 64 return os; |
| 65 *os << "\n"; | |
| 66 } | |
| 67 } | 65 } |
| 68 | 66 |
| 69 void PrintTo(const ResourceData& resource, ::std::ostream* os) { | 67 std::ostream& operator<<(std::ostream& os, const ResourceData& resource) { |
| 70 *os << "[" << resource.resource_url() << "," << resource.resource_type() | 68 return os << "[" << resource.resource_url() << "," << resource.resource_type() |
| 71 << "," << resource.number_of_hits() << "," << resource.number_of_misses() | 69 << "," << resource.number_of_hits() << "," |
| 72 << "," << resource.consecutive_misses() << "," | 70 << resource.number_of_misses() << "," |
| 73 << resource.average_position() << "," << resource.priority() << "," | 71 << resource.consecutive_misses() << "," |
| 74 << resource.has_validators() << "," << resource.always_revalidate() | 72 << resource.average_position() << "," << resource.priority() << "," |
| 75 << "]"; | 73 << resource.has_validators() << "," << resource.always_revalidate() |
| 74 << "]"; | |
| 76 } | 75 } |
| 77 | 76 |
| 78 void PrintTo(const RedirectData& data, ::std::ostream* os) { | 77 std::ostream& operator<<(std::ostream& os, const RedirectData& data) { |
| 79 *os << "[" << data.primary_key() << "," << data.last_visit_time() << "]\n"; | 78 os << "[" << data.primary_key() << "," << data.last_visit_time() << "]\n"; |
| 80 for (const RedirectStat& redirect : data.redirect_endpoints()) { | 79 for (const RedirectStat& redirect : data.redirect_endpoints()) |
| 81 *os << "\t\t"; | 80 os << "\t\t" << redirect << os; |
|
alexilin
2016/10/17 15:32:35
oh, wow
pasko
2016/10/17 16:09:19
:)
| |
| 82 PrintTo(redirect, os); | 81 return os; |
| 83 *os << "\n"; | |
| 84 } | |
| 85 } | 82 } |
| 86 | 83 |
| 87 void PrintTo(const RedirectStat& redirect, ::std::ostream* os) { | 84 std::ostream& operator<<(std::ostream& os, const RedirectStat& redirect) { |
| 88 *os << "[" << redirect.url() << "," << redirect.number_of_hits() << "," | 85 return os << "[" << redirect.url() << "," << redirect.number_of_hits() << "," |
| 89 << redirect.number_of_misses() << "," << redirect.consecutive_misses() | 86 << redirect.number_of_misses() << "," |
| 90 << "]"; | 87 << redirect.consecutive_misses() << "]"; |
| 91 } | 88 } |
| 92 | 89 |
| 93 bool operator==(const PrefetchData& lhs, const PrefetchData& rhs) { | 90 bool operator==(const PrefetchData& lhs, const PrefetchData& rhs) { |
| 94 bool equal = lhs.primary_key() == rhs.primary_key() && | 91 bool equal = lhs.primary_key() == rhs.primary_key() && |
| 95 lhs.resources_size() == rhs.resources_size(); | 92 lhs.resources_size() == rhs.resources_size(); |
| 96 | 93 |
| 97 if (!equal) | 94 if (!equal) |
| 98 return false; | 95 return false; |
| 99 | 96 |
| 100 for (int i = 0; i < lhs.resources_size(); ++i) | 97 for (int i = 0; i < lhs.resources_size(); ++i) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 129 } | 126 } |
| 130 | 127 |
| 131 bool operator==(const RedirectStat& lhs, const RedirectStat& rhs) { | 128 bool operator==(const RedirectStat& lhs, const RedirectStat& rhs) { |
| 132 return lhs.url() == rhs.url() && | 129 return lhs.url() == rhs.url() && |
| 133 lhs.number_of_hits() == rhs.number_of_hits() && | 130 lhs.number_of_hits() == rhs.number_of_hits() && |
| 134 lhs.number_of_misses() == rhs.number_of_misses() && | 131 lhs.number_of_misses() == rhs.number_of_misses() && |
| 135 lhs.consecutive_misses() == rhs.consecutive_misses(); | 132 lhs.consecutive_misses() == rhs.consecutive_misses(); |
| 136 } | 133 } |
| 137 | 134 |
| 138 } // namespace predictors | 135 } // namespace predictors |
| OLD | NEW |