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

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor_test_util.cc

Issue 2355273002: Redirect handling in the resource_prefetch_predictor. (Closed)
Patch Set: Fix compilation complaints. Created 4 years, 3 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
Index: chrome/browser/predictors/resource_prefetch_predictor_test_util.cc
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_test_util.cc b/chrome/browser/predictors/resource_prefetch_predictor_test_util.cc
index 013e1d466f03687aa0072990a003df2a0785e393..5e18536c6c84d175716afadcb5a6b65f08ce5dec 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_test_util.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor_test_util.cc
@@ -33,6 +33,33 @@ ResourceData CreateResourceData(const std::string& resource_url,
return resource;
}
+void InitializeRedirectStat(RedirectStat* redirect,
+ const std::string& url,
+ int number_of_hits,
+ int number_of_misses,
+ int consecutive_misses) {
+ redirect->set_url(url);
+ redirect->set_number_of_hits(number_of_hits);
+ redirect->set_number_of_misses(number_of_misses);
+ redirect->set_consecutive_misses(consecutive_misses);
+}
+
+RedirectData CreateRedirectData(const std::string& primary_key) {
+ RedirectData data;
+ data.set_primary_key(primary_key);
+ return data;
+}
+
+void PrintTo(const PrefetchData& data, ::std::ostream* os) {
+ *os << "[" << data.key_type << "," << data.primary_key << ","
+ << data.last_visit.ToInternalValue() << "]\n";
+ for (const ResourceData& resource : data.resources) {
+ *os << "\t\t";
+ PrintTo(resource, os);
+ *os << "\n";
+ }
+}
+
void PrintTo(const ResourceData& resource, ::std::ostream* os) {
*os << "[" << resource.resource_url() << "," << resource.resource_type()
<< "," << resource.number_of_hits() << "," << resource.number_of_misses()
@@ -42,16 +69,35 @@ void PrintTo(const ResourceData& resource, ::std::ostream* os) {
<< "]";
}
-void PrintTo(const PrefetchData& data, ::std::ostream* os) {
- *os << "[" << data.key_type << "," << data.primary_key << ","
- << data.last_visit.ToInternalValue() << "]\n";
- for (const ResourceData& resource : data.resources) {
+void PrintTo(const RedirectStat& redirect, ::std::ostream* os) {
+ *os << "[" << redirect.url() << "," << redirect.number_of_hits() << ","
+ << redirect.number_of_misses() << "," << redirect.consecutive_misses()
+ << "]";
+}
+
+void PrintTo(const RedirectData& data, ::std::ostream* os) {
+ *os << "[" << data.primary_key() << "," << data.last_visit_time() << "]\n";
+ for (const RedirectStat& redirect : data.redirect_endpoints()) {
*os << "\t\t";
- PrintTo(resource, os);
+ PrintTo(redirect, os);
*os << "\n";
}
}
+bool operator==(const PrefetchData& lhs, const PrefetchData& rhs) {
+ bool equal = lhs.key_type == rhs.key_type &&
+ lhs.primary_key == rhs.primary_key &&
+ lhs.resources.size() == rhs.resources.size();
+
+ if (!equal)
+ return false;
+
+ for (size_t i = 0; i < lhs.resources.size(); ++i)
+ equal = equal && lhs.resources[i] == rhs.resources[i];
+
+ return equal;
+}
+
bool operator==(const ResourceData& lhs, const ResourceData& rhs) {
return lhs.resource_url() == rhs.resource_url() &&
lhs.resource_type() == rhs.resource_type() &&
@@ -64,16 +110,22 @@ bool operator==(const ResourceData& lhs, const ResourceData& rhs) {
lhs.always_revalidate() == rhs.always_revalidate();
}
-bool operator==(const PrefetchData& lhs, const PrefetchData& rhs) {
- bool equal = lhs.key_type == rhs.key_type &&
- lhs.primary_key == rhs.primary_key &&
- lhs.resources.size() == rhs.resources.size();
+bool operator==(const RedirectStat& lhs, const RedirectStat& rhs) {
+ return lhs.url() == rhs.url() &&
+ lhs.number_of_hits() == rhs.number_of_hits() &&
+ lhs.number_of_misses() == rhs.number_of_misses() &&
+ lhs.consecutive_misses() == rhs.consecutive_misses();
+}
+
+bool operator==(const RedirectData& lhs, const RedirectData& rhs) {
+ bool equal = lhs.primary_key() == rhs.primary_key() &&
+ lhs.redirect_endpoints_size() == rhs.redirect_endpoints_size();
if (!equal)
return false;
- for (size_t i = 0; i < lhs.resources.size(); ++i)
- equal = equal && lhs.resources[i] == rhs.resources[i];
+ for (int i = 0; i < lhs.redirect_endpoints_size(); ++i)
+ equal = equal && lhs.redirect_endpoints(i) == rhs.redirect_endpoints(i);
return equal;
}

Powered by Google App Engine
This is Rietveld 408576698