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

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

Issue 2470143007: Revert of predictors: Basic browsertest checks predictor learning. (Closed)
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 GURL(url), 181 GURL(url),
182 base::string16(), 182 base::string16(),
183 visit_count, 183 visit_count,
184 0, 184 0,
185 base::Time::Now(), 185 base::Time::Now(),
186 false, 186 false,
187 history::SOURCE_BROWSED); 187 history::SOURCE_BROWSED);
188 profile_->BlockUntilHistoryProcessesPendingRequests(); 188 profile_->BlockUntilHistoryProcessesPendingRequests();
189 } 189 }
190 190
191 NavigationID CreateNavigationID(int process_id,
192 int render_frame_id,
193 const std::string& main_frame_url) {
194 NavigationID navigation_id(process_id, render_frame_id,
195 GURL(main_frame_url));
196 navigation_id.creation_time = base::TimeTicks::Now();
197 return navigation_id;
198 }
199
200 PageRequestSummary CreatePageRequestSummary(
201 const std::string& main_frame_url,
202 const std::string& initial_url,
203 const std::vector<URLRequestSummary>& subresource_requests) {
204 GURL main_frame_gurl(main_frame_url);
205 PageRequestSummary summary(main_frame_gurl);
206 summary.initial_url = GURL(initial_url);
207 summary.subresource_requests = subresource_requests;
208 return summary;
209 }
210
211 URLRequestSummary CreateURLRequestSummary(
212 int process_id,
213 int render_frame_id,
214 const std::string& main_frame_url,
215 const std::string& resource_url = std::string(),
216 content::ResourceType resource_type = content::RESOURCE_TYPE_MAIN_FRAME,
217 net::RequestPriority priority = net::MEDIUM,
218 const std::string& mime_type = std::string(),
219 bool was_cached = false) {
220 URLRequestSummary summary;
221 summary.navigation_id = CreateNavigationID(process_id, render_frame_id,
222 main_frame_url);
223 summary.resource_url =
224 resource_url.empty() ? GURL(main_frame_url) : GURL(resource_url);
225 summary.resource_type = resource_type;
226 summary.priority = priority;
227 summary.mime_type = mime_type;
228 summary.was_cached = was_cached;
229 return summary;
230 }
231
191 URLRequestSummary CreateRedirectRequestSummary( 232 URLRequestSummary CreateRedirectRequestSummary(
192 int process_id, 233 int process_id,
193 int render_frame_id, 234 int render_frame_id,
194 const std::string& main_frame_url, 235 const std::string& main_frame_url,
195 const std::string& redirect_url) { 236 const std::string& redirect_url) {
196 URLRequestSummary summary = 237 URLRequestSummary summary =
197 CreateURLRequestSummary(process_id, render_frame_id, main_frame_url); 238 CreateURLRequestSummary(process_id, render_frame_id, main_frame_url);
198 summary.redirect_url = GURL(redirect_url); 239 summary.redirect_url = GURL(redirect_url);
199 return summary; 240 return summary;
200 } 241 }
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 net::MEDIUM, false, false); 1585 net::MEDIUM, false, false);
1545 predictor_->url_table_cache_->insert( 1586 predictor_->url_table_cache_->insert(
1546 std::make_pair(www_google_url.primary_key(), www_google_url)); 1587 std::make_pair(www_google_url.primary_key(), www_google_url));
1547 1588
1548 urls.clear(); 1589 urls.clear();
1549 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); 1590 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls));
1550 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); 1591 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url)));
1551 } 1592 }
1552 1593
1553 } // namespace predictors 1594 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_test_util.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698