| 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 5e18536c6c84d175716afadcb5a6b65f08ce5dec..3920d883bd45162926013b565bf4d31d5bad2116 100644
|
| --- a/chrome/browser/predictors/resource_prefetch_predictor_test_util.cc
|
| +++ b/chrome/browser/predictors/resource_prefetch_predictor_test_util.cc
|
| @@ -8,29 +8,26 @@
|
|
|
| namespace predictors {
|
|
|
| -using PrefetchData = ResourcePrefetchPredictorTables::PrefetchData;
|
| -
|
| -ResourceData CreateResourceData(const std::string& resource_url,
|
| - content::ResourceType resource_type,
|
| - int number_of_hits,
|
| - int number_of_misses,
|
| - int consecutive_misses,
|
| - double average_position,
|
| - net::RequestPriority priority,
|
| - bool has_validators,
|
| - bool always_revalidate) {
|
| - ResourceData resource;
|
| - resource.set_resource_url(resource_url);
|
| - resource.set_resource_type(
|
| +void InitializeResourceData(ResourceData* resource,
|
| + const std::string& resource_url,
|
| + content::ResourceType resource_type,
|
| + int number_of_hits,
|
| + int number_of_misses,
|
| + int consecutive_misses,
|
| + double average_position,
|
| + net::RequestPriority priority,
|
| + bool has_validators,
|
| + bool always_revalidate) {
|
| + resource->set_resource_url(resource_url);
|
| + resource->set_resource_type(
|
| static_cast<ResourceData::ResourceType>(resource_type));
|
| - resource.set_number_of_hits(number_of_hits);
|
| - resource.set_number_of_misses(number_of_misses);
|
| - resource.set_consecutive_misses(consecutive_misses);
|
| - resource.set_average_position(average_position);
|
| - resource.set_priority(static_cast<ResourceData::Priority>(priority));
|
| - resource.set_has_validators(has_validators);
|
| - resource.set_always_revalidate(always_revalidate);
|
| - return resource;
|
| + resource->set_number_of_hits(number_of_hits);
|
| + resource->set_number_of_misses(number_of_misses);
|
| + resource->set_consecutive_misses(consecutive_misses);
|
| + resource->set_average_position(average_position);
|
| + resource->set_priority(static_cast<ResourceData::Priority>(priority));
|
| + resource->set_has_validators(has_validators);
|
| + resource->set_always_revalidate(always_revalidate);
|
| }
|
|
|
| void InitializeRedirectStat(RedirectStat* redirect,
|
| @@ -44,16 +41,25 @@ void InitializeRedirectStat(RedirectStat* redirect,
|
| redirect->set_consecutive_misses(consecutive_misses);
|
| }
|
|
|
| -RedirectData CreateRedirectData(const std::string& primary_key) {
|
| +PrefetchData CreatePrefetchData(const std::string& primary_key,
|
| + uint64_t last_visit_time) {
|
| + PrefetchData data;
|
| + data.set_primary_key(primary_key);
|
| + data.set_last_visit_time(last_visit_time);
|
| + return data;
|
| +}
|
| +
|
| +RedirectData CreateRedirectData(const std::string& primary_key,
|
| + uint64_t last_visit_time) {
|
| RedirectData data;
|
| data.set_primary_key(primary_key);
|
| + data.set_last_visit_time(last_visit_time);
|
| 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 << "[" << data.primary_key() << "," << data.last_visit_time() << "]\n";
|
| + for (const ResourceData& resource : data.resources()) {
|
| *os << "\t\t";
|
| PrintTo(resource, os);
|
| *os << "\n";
|
| @@ -69,12 +75,6 @@ void PrintTo(const ResourceData& resource, ::std::ostream* os) {
|
| << "]";
|
| }
|
|
|
| -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()) {
|
| @@ -84,16 +84,21 @@ void PrintTo(const RedirectData& data, ::std::ostream* os) {
|
| }
|
| }
|
|
|
| +void PrintTo(const RedirectStat& redirect, ::std::ostream* os) {
|
| + *os << "[" << redirect.url() << "," << redirect.number_of_hits() << ","
|
| + << redirect.number_of_misses() << "," << redirect.consecutive_misses()
|
| + << "]";
|
| +}
|
| +
|
| 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 equal = 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];
|
| + for (int i = 0; i < lhs.resources_size(); ++i)
|
| + equal = equal && lhs.resources(i) == rhs.resources(i);
|
|
|
| return equal;
|
| }
|
| @@ -110,13 +115,6 @@ bool operator==(const ResourceData& lhs, const ResourceData& rhs) {
|
| lhs.always_revalidate() == rhs.always_revalidate();
|
| }
|
|
|
| -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();
|
| @@ -130,4 +128,11 @@ bool operator==(const RedirectData& lhs, const RedirectData& rhs) {
|
| return equal;
|
| }
|
|
|
| +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();
|
| +}
|
| +
|
| } // namespace predictors
|
|
|