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 <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 has_validators(other.has_validators), | 318 has_validators(other.has_validators), |
319 always_revalidate(other.always_revalidate) {} | 319 always_revalidate(other.always_revalidate) {} |
320 | 320 |
321 ResourcePrefetchPredictor::URLRequestSummary::~URLRequestSummary() { | 321 ResourcePrefetchPredictor::URLRequestSummary::~URLRequestSummary() { |
322 } | 322 } |
323 | 323 |
324 // static | 324 // static |
325 bool ResourcePrefetchPredictor::URLRequestSummary::SummarizeResponse( | 325 bool ResourcePrefetchPredictor::URLRequestSummary::SummarizeResponse( |
326 const net::URLRequest& request, | 326 const net::URLRequest& request, |
327 URLRequestSummary* summary) { | 327 URLRequestSummary* summary) { |
328 const content::ResourceRequestInfo* info = | 328 const content::ResourceRequestInfo* request_info = |
329 content::ResourceRequestInfo::ForRequest(&request); | 329 content::ResourceRequestInfo::ForRequest(&request); |
330 if (!info) | 330 if (!request_info) |
331 return false; | 331 return false; |
332 | 332 |
333 int render_process_id, render_frame_id; | |
334 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) | |
335 return false; | |
336 | |
337 summary->navigation_id = NavigationID(render_process_id, render_frame_id, | |
338 request.first_party_for_cookies()); | |
339 summary->navigation_id.creation_time = request.creation_time(); | |
340 summary->resource_url = request.original_url(); | 333 summary->resource_url = request.original_url(); |
341 content::ResourceType resource_type_from_request = info->GetResourceType(); | 334 content::ResourceType resource_type_from_request = |
| 335 request_info->GetResourceType(); |
342 summary->priority = request.priority(); | 336 summary->priority = request.priority(); |
343 request.GetMimeType(&summary->mime_type); | 337 request.GetMimeType(&summary->mime_type); |
344 summary->was_cached = request.was_cached(); | 338 summary->was_cached = request.was_cached(); |
345 summary->resource_type = | 339 summary->resource_type = |
346 GetResourceType(resource_type_from_request, summary->mime_type); | 340 GetResourceType(resource_type_from_request, summary->mime_type); |
347 | 341 |
348 scoped_refptr<net::HttpResponseHeaders> headers = | 342 scoped_refptr<net::HttpResponseHeaders> headers = |
349 request.response_info().headers; | 343 request.response_info().headers; |
350 if (headers.get()) { | 344 if (headers.get()) { |
351 summary->has_validators = headers->HasValidators(); | 345 summary->has_validators = headers->HasValidators(); |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 TestObserver::~TestObserver() { | 1151 TestObserver::~TestObserver() { |
1158 predictor_->SetObserverForTesting(nullptr); | 1152 predictor_->SetObserverForTesting(nullptr); |
1159 } | 1153 } |
1160 | 1154 |
1161 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) | 1155 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) |
1162 : predictor_(predictor) { | 1156 : predictor_(predictor) { |
1163 predictor_->SetObserverForTesting(this); | 1157 predictor_->SetObserverForTesting(this); |
1164 } | 1158 } |
1165 | 1159 |
1166 } // namespace predictors | 1160 } // namespace predictors |
OLD | NEW |