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

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

Issue 2587443002: predictors: Make speculative_prefetch_predictor work with PlzNavigate (Closed)
Patch Set: Reworked Tests Created 4 years 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, 63 NavigationID CreateNavigationID(int session_id,
64 int render_frame_id, 64 int frame_tree_node_id,
65 const std::string& main_frame_url) { 65 const std::string& main_frame_url) {
66 NavigationID navigation_id; 66 NavigationID navigation_id;
67 navigation_id.render_process_id = process_id; 67 navigation_id.session_id.set_id(session_id);
68 navigation_id.render_frame_id = render_frame_id; 68 navigation_id.frame_tree_node_id = frame_tree_node_id;
69 navigation_id.main_frame_url = GURL(main_frame_url); 69 navigation_id.main_frame_url = GURL(main_frame_url);
70 navigation_id.creation_time = base::TimeTicks::Now(); 70 navigation_id.creation_time = base::TimeTicks::Now();
71 return navigation_id; 71 return navigation_id;
72 } 72 }
73 73
74 PageRequestSummary CreatePageRequestSummary( 74 PageRequestSummary CreatePageRequestSummary(
75 const std::string& main_frame_url, 75 const std::string& main_frame_url,
76 const std::string& initial_url, 76 const std::string& initial_url,
77 const std::vector<URLRequestSummary>& subresource_requests) { 77 const std::vector<URLRequestSummary>& subresource_requests) {
78 GURL main_frame_gurl(main_frame_url); 78 GURL main_frame_gurl(main_frame_url);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 std::ostream& operator<<(std::ostream& os, const URLRequestSummary& summary) { 152 std::ostream& operator<<(std::ostream& os, const URLRequestSummary& summary) {
153 return os << "[" << summary.navigation_id << "," << summary.resource_url 153 return os << "[" << summary.navigation_id << "," << summary.resource_url
154 << "," << summary.resource_type << "," << summary.priority << "," 154 << "," << summary.resource_type << "," << summary.priority << ","
155 << summary.mime_type << "," << summary.was_cached << "," 155 << summary.mime_type << "," << summary.was_cached << ","
156 << summary.redirect_url << "," << summary.has_validators << "," 156 << summary.redirect_url << "," << summary.has_validators << ","
157 << summary.always_revalidate << "]"; 157 << summary.always_revalidate << "]";
158 } 158 }
159 159
160 std::ostream& operator<<(std::ostream& os, const NavigationID& navigation_id) { 160 std::ostream& operator<<(std::ostream& os, const NavigationID& navigation_id) {
161 return os << navigation_id.render_process_id << "," 161 return os << navigation_id.session_id.id() << ","
162 << navigation_id.render_frame_id << "," 162 << navigation_id.frame_tree_node_id << ","
163 << navigation_id.main_frame_url; 163 << navigation_id.main_frame_url;
164 } 164 }
165 165
166 std::ostream& operator<<(
167 std::ostream& os,
168 const std::map<NavigationID, std::unique_ptr<PageRequestSummary>>& map) {
169 os << "Navigation Map, " << map.size() << " elements" << std::endl;
170 int i = 0;
171 for (auto nav_it = map.begin(); nav_it != map.end(); ++nav_it, ++i)
172 os << "Element " << i << ": " << nav_it->first << std::endl;
173 return os;
174 }
175
166 bool operator==(const PrefetchData& lhs, const PrefetchData& rhs) { 176 bool operator==(const PrefetchData& lhs, const PrefetchData& rhs) {
167 bool equal = lhs.primary_key() == rhs.primary_key() && 177 bool equal = lhs.primary_key() == rhs.primary_key() &&
168 lhs.resources_size() == rhs.resources_size(); 178 lhs.resources_size() == rhs.resources_size();
169 179
170 if (!equal) 180 if (!equal)
171 return false; 181 return false;
172 182
173 for (int i = 0; i < lhs.resources_size(); ++i) 183 for (int i = 0; i < lhs.resources_size(); ++i)
174 equal = equal && lhs.resources(i) == rhs.resources(i); 184 equal = equal && lhs.resources(i) == rhs.resources(i);
175 185
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 lhs.resource_url == rhs.resource_url && 229 lhs.resource_url == rhs.resource_url &&
220 lhs.resource_type == rhs.resource_type && 230 lhs.resource_type == rhs.resource_type &&
221 lhs.priority == rhs.priority && lhs.mime_type == rhs.mime_type && 231 lhs.priority == rhs.priority && lhs.mime_type == rhs.mime_type &&
222 lhs.was_cached == rhs.was_cached && 232 lhs.was_cached == rhs.was_cached &&
223 lhs.redirect_url == rhs.redirect_url && 233 lhs.redirect_url == rhs.redirect_url &&
224 lhs.has_validators == rhs.has_validators && 234 lhs.has_validators == rhs.has_validators &&
225 lhs.always_revalidate == rhs.always_revalidate; 235 lhs.always_revalidate == rhs.always_revalidate;
226 } 236 }
227 237
228 } // namespace predictors 238 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698