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

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: Modified after clamy@ review 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(SessionID::id_type tab_id,
64 int render_frame_id,
65 const std::string& main_frame_url) { 64 const std::string& main_frame_url) {
66 NavigationID navigation_id; 65 NavigationID navigation_id;
67 navigation_id.render_process_id = process_id; 66 navigation_id.tab_id = tab_id;
68 navigation_id.render_frame_id = render_frame_id;
69 navigation_id.main_frame_url = GURL(main_frame_url); 67 navigation_id.main_frame_url = GURL(main_frame_url);
70 navigation_id.creation_time = base::TimeTicks::Now(); 68 navigation_id.creation_time = base::TimeTicks::Now();
71 return navigation_id; 69 return navigation_id;
72 } 70 }
73 71
74 PageRequestSummary CreatePageRequestSummary( 72 PageRequestSummary CreatePageRequestSummary(
75 const std::string& main_frame_url, 73 const std::string& main_frame_url,
76 const std::string& initial_url, 74 const std::string& initial_url,
77 const std::vector<URLRequestSummary>& subresource_requests) { 75 const std::vector<URLRequestSummary>& subresource_requests) {
78 GURL main_frame_gurl(main_frame_url); 76 GURL main_frame_gurl(main_frame_url);
79 PageRequestSummary summary(main_frame_gurl); 77 PageRequestSummary summary(main_frame_gurl);
80 summary.initial_url = GURL(initial_url); 78 summary.initial_url = GURL(initial_url);
81 summary.subresource_requests = subresource_requests; 79 summary.subresource_requests = subresource_requests;
82 return summary; 80 return summary;
83 } 81 }
84 82
85 URLRequestSummary CreateURLRequestSummary(int process_id, 83 URLRequestSummary CreateURLRequestSummary(SessionID::id_type tab_id,
86 int render_frame_id,
87 const std::string& main_frame_url, 84 const std::string& main_frame_url,
88 const std::string& resource_url, 85 const std::string& resource_url,
89 content::ResourceType resource_type, 86 content::ResourceType resource_type,
90 net::RequestPriority priority, 87 net::RequestPriority priority,
91 const std::string& mime_type, 88 const std::string& mime_type,
92 bool was_cached, 89 bool was_cached,
93 const std::string& redirect_url, 90 const std::string& redirect_url,
94 bool has_validators, 91 bool has_validators,
95 bool always_revalidate) { 92 bool always_revalidate) {
96 URLRequestSummary summary; 93 URLRequestSummary summary;
97 summary.navigation_id = 94 summary.navigation_id = CreateNavigationID(tab_id, main_frame_url);
98 CreateNavigationID(process_id, render_frame_id, main_frame_url);
99 summary.resource_url = 95 summary.resource_url =
100 resource_url.empty() ? GURL(main_frame_url) : GURL(resource_url); 96 resource_url.empty() ? GURL(main_frame_url) : GURL(resource_url);
101 summary.resource_type = resource_type; 97 summary.resource_type = resource_type;
102 summary.priority = priority; 98 summary.priority = priority;
103 summary.mime_type = mime_type; 99 summary.mime_type = mime_type;
104 summary.was_cached = was_cached; 100 summary.was_cached = was_cached;
105 if (!redirect_url.empty()) 101 if (!redirect_url.empty())
106 summary.redirect_url = GURL(redirect_url); 102 summary.redirect_url = GURL(redirect_url);
107 summary.has_validators = has_validators; 103 summary.has_validators = has_validators;
108 summary.always_revalidate = always_revalidate; 104 summary.always_revalidate = always_revalidate;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 147
152 std::ostream& operator<<(std::ostream& os, const URLRequestSummary& summary) { 148 std::ostream& operator<<(std::ostream& os, const URLRequestSummary& summary) {
153 return os << "[" << summary.navigation_id << "," << summary.resource_url 149 return os << "[" << summary.navigation_id << "," << summary.resource_url
154 << "," << summary.resource_type << "," << summary.priority << "," 150 << "," << summary.resource_type << "," << summary.priority << ","
155 << summary.mime_type << "," << summary.was_cached << "," 151 << summary.mime_type << "," << summary.was_cached << ","
156 << summary.redirect_url << "," << summary.has_validators << "," 152 << summary.redirect_url << "," << summary.has_validators << ","
157 << summary.always_revalidate << "]"; 153 << summary.always_revalidate << "]";
158 } 154 }
159 155
160 std::ostream& operator<<(std::ostream& os, const NavigationID& navigation_id) { 156 std::ostream& operator<<(std::ostream& os, const NavigationID& navigation_id) {
161 return os << navigation_id.render_process_id << "," 157 return os << navigation_id.tab_id << "," << navigation_id.main_frame_url;
162 << navigation_id.render_frame_id << ","
163 << navigation_id.main_frame_url;
164 } 158 }
165 159
166 bool operator==(const PrefetchData& lhs, const PrefetchData& rhs) { 160 bool operator==(const PrefetchData& lhs, const PrefetchData& rhs) {
167 bool equal = lhs.primary_key() == rhs.primary_key() && 161 bool equal = lhs.primary_key() == rhs.primary_key() &&
168 lhs.resources_size() == rhs.resources_size(); 162 lhs.resources_size() == rhs.resources_size();
169 163
170 if (!equal) 164 if (!equal)
171 return false; 165 return false;
172 166
173 for (int i = 0; i < lhs.resources_size(); ++i) 167 for (int i = 0; i < lhs.resources_size(); ++i)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 lhs.resource_url == rhs.resource_url && 213 lhs.resource_url == rhs.resource_url &&
220 lhs.resource_type == rhs.resource_type && 214 lhs.resource_type == rhs.resource_type &&
221 lhs.priority == rhs.priority && lhs.mime_type == rhs.mime_type && 215 lhs.priority == rhs.priority && lhs.mime_type == rhs.mime_type &&
222 lhs.was_cached == rhs.was_cached && 216 lhs.was_cached == rhs.was_cached &&
223 lhs.redirect_url == rhs.redirect_url && 217 lhs.redirect_url == rhs.redirect_url &&
224 lhs.has_validators == rhs.has_validators && 218 lhs.has_validators == rhs.has_validators &&
225 lhs.always_revalidate == rhs.always_revalidate; 219 lhs.always_revalidate == rhs.always_revalidate;
226 } 220 }
227 221
228 } // namespace predictors 222 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698