| OLD | NEW |
| 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 Loading... |
| 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 | |
| 232 URLRequestSummary CreateRedirectRequestSummary( | 191 URLRequestSummary CreateRedirectRequestSummary( |
| 233 int process_id, | 192 int process_id, |
| 234 int render_frame_id, | 193 int render_frame_id, |
| 235 const std::string& main_frame_url, | 194 const std::string& main_frame_url, |
| 236 const std::string& redirect_url) { | 195 const std::string& redirect_url) { |
| 237 URLRequestSummary summary = | 196 URLRequestSummary summary = |
| 238 CreateURLRequestSummary(process_id, render_frame_id, main_frame_url); | 197 CreateURLRequestSummary(process_id, render_frame_id, main_frame_url); |
| 239 summary.redirect_url = GURL(redirect_url); | 198 summary.redirect_url = GURL(redirect_url); |
| 240 return summary; | 199 return summary; |
| 241 } | 200 } |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1585 net::MEDIUM, false, false); | 1544 net::MEDIUM, false, false); |
| 1586 predictor_->url_table_cache_->insert( | 1545 predictor_->url_table_cache_->insert( |
| 1587 std::make_pair(www_google_url.primary_key(), www_google_url)); | 1546 std::make_pair(www_google_url.primary_key(), www_google_url)); |
| 1588 | 1547 |
| 1589 urls.clear(); | 1548 urls.clear(); |
| 1590 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); | 1549 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); |
| 1591 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); | 1550 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); |
| 1592 } | 1551 } |
| 1593 | 1552 |
| 1594 } // namespace predictors | 1553 } // namespace predictors |
| OLD | NEW |