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

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

Issue 2449323005: predictors: Basic browsertest checks predictor learning. (Closed)
Patch Set: Get rid of mime type. Created 4 years, 1 month 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 "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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 RedirectData CreateRedirectData(const std::string& primary_key, 55 RedirectData CreateRedirectData(const std::string& primary_key,
56 uint64_t last_visit_time) { 56 uint64_t last_visit_time) {
57 RedirectData data; 57 RedirectData data;
58 data.set_primary_key(primary_key); 58 data.set_primary_key(primary_key);
59 data.set_last_visit_time(last_visit_time); 59 data.set_last_visit_time(last_visit_time);
60 return data; 60 return data;
61 } 61 }
62 62
63 NavigationID CreateNavigationID(int process_id,
64 int render_frame_id,
65 const std::string& main_frame_url) {
66 NavigationID navigation_id(process_id, render_frame_id, GURL(main_frame_url));
67 navigation_id.creation_time = base::TimeTicks::Now();
68 return navigation_id;
69 }
70
71 PageRequestSummary CreatePageRequestSummary(
72 const std::string& main_frame_url,
73 const std::string& initial_url,
74 const std::vector<URLRequestSummary>& subresource_requests) {
75 GURL main_frame_gurl(main_frame_url);
76 PageRequestSummary summary(main_frame_gurl);
77 summary.initial_url = GURL(initial_url);
78 summary.subresource_requests = subresource_requests;
79 return summary;
80 }
81
82 URLRequestSummary CreateURLRequestSummary(int process_id,
83 int render_frame_id,
84 const std::string& main_frame_url,
85 const std::string& resource_url,
86 content::ResourceType resource_type,
87 net::RequestPriority priority,
88 const std::string& mime_type,
89 bool was_cached,
90 const std::string& redirect_url,
91 bool has_validators,
92 bool always_revalidate) {
93 URLRequestSummary summary;
94 summary.navigation_id =
95 CreateNavigationID(process_id, render_frame_id, main_frame_url);
96 summary.resource_url =
97 resource_url.empty() ? GURL(main_frame_url) : GURL(resource_url);
98 summary.resource_type = resource_type;
99 summary.priority = priority;
100 summary.mime_type = mime_type;
101 summary.was_cached = was_cached;
102 if (!redirect_url.empty())
103 summary.redirect_url = GURL(redirect_url);
104 summary.has_validators = has_validators;
105 summary.always_revalidate = always_revalidate;
106 return summary;
107 }
108
63 std::ostream& operator<<(std::ostream& os, const PrefetchData& data) { 109 std::ostream& operator<<(std::ostream& os, const PrefetchData& data) {
64 os << "[" << data.primary_key() << "," << data.last_visit_time() << "]" 110 os << "[" << data.primary_key() << "," << data.last_visit_time() << "]"
65 << std::endl; 111 << std::endl;
66 for (const ResourceData& resource : data.resources()) 112 for (const ResourceData& resource : data.resources())
67 os << "\t\t" << resource << std::endl; 113 os << "\t\t" << resource << std::endl;
68 return os; 114 return os;
69 } 115 }
70 116
71 std::ostream& operator<<(std::ostream& os, const ResourceData& resource) { 117 std::ostream& operator<<(std::ostream& os, const ResourceData& resource) {
72 return os << "[" << resource.resource_url() << "," << resource.resource_type() 118 return os << "[" << resource.resource_url() << "," << resource.resource_type()
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 lhs.resource_url == rhs.resource_url && 216 lhs.resource_url == rhs.resource_url &&
171 lhs.resource_type == rhs.resource_type && 217 lhs.resource_type == rhs.resource_type &&
172 lhs.priority == rhs.priority && lhs.mime_type == rhs.mime_type && 218 lhs.priority == rhs.priority && lhs.mime_type == rhs.mime_type &&
173 lhs.was_cached == rhs.was_cached && 219 lhs.was_cached == rhs.was_cached &&
174 lhs.redirect_url == rhs.redirect_url && 220 lhs.redirect_url == rhs.redirect_url &&
175 lhs.has_validators == rhs.has_validators && 221 lhs.has_validators == rhs.has_validators &&
176 lhs.always_revalidate == rhs.always_revalidate; 222 lhs.always_revalidate == rhs.always_revalidate;
177 } 223 }
178 224
179 } // namespace predictors 225 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698