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

Side by Side Diff: content/browser/loader/resource_loader.cc

Issue 451623002: Getting rid of net::LOAD_ENABLE_LOAD_TIMING (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed content/browser/loader/resource_scheduler_unittest.cc. Created 6 years, 4 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/loader/resource_loader.h" 5 #include "content/browser/loader/resource_loader.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 20 matching lines...) Expand all
31 #include "net/http/http_response_headers.h" 31 #include "net/http/http_response_headers.h"
32 #include "net/ssl/client_cert_store.h" 32 #include "net/ssl/client_cert_store.h"
33 #include "net/url_request/url_request_status.h" 33 #include "net/url_request/url_request_status.h"
34 34
35 using base::TimeDelta; 35 using base::TimeDelta;
36 using base::TimeTicks; 36 using base::TimeTicks;
37 37
38 namespace content { 38 namespace content {
39 namespace { 39 namespace {
40 40
41 void PopulateResourceResponse(net::URLRequest* request, 41 void PopulateResourceResponse(ResourceRequestInfoImpl* info,
42 net::URLRequest* request,
42 ResourceResponse* response) { 43 ResourceResponse* response) {
43 response->head.error_code = request->status().error(); 44 response->head.error_code = request->status().error();
44 response->head.request_time = request->request_time(); 45 response->head.request_time = request->request_time();
45 response->head.response_time = request->response_time(); 46 response->head.response_time = request->response_time();
46 response->head.headers = request->response_headers(); 47 response->head.headers = request->response_headers();
47 request->GetCharset(&response->head.charset); 48 request->GetCharset(&response->head.charset);
48 response->head.content_length = request->GetExpectedContentSize(); 49 response->head.content_length = request->GetExpectedContentSize();
49 request->GetMimeType(&response->head.mime_type); 50 request->GetMimeType(&response->head.mime_type);
50 net::HttpResponseInfo response_info = request->response_info(); 51 net::HttpResponseInfo response_info = request->response_info();
51 response->head.was_fetched_via_spdy = response_info.was_fetched_via_spdy; 52 response->head.was_fetched_via_spdy = response_info.was_fetched_via_spdy;
52 response->head.was_npn_negotiated = response_info.was_npn_negotiated; 53 response->head.was_npn_negotiated = response_info.was_npn_negotiated;
53 response->head.npn_negotiated_protocol = 54 response->head.npn_negotiated_protocol =
54 response_info.npn_negotiated_protocol; 55 response_info.npn_negotiated_protocol;
55 response->head.connection_info = response_info.connection_info; 56 response->head.connection_info = response_info.connection_info;
56 response->head.was_fetched_via_proxy = request->was_fetched_via_proxy(); 57 response->head.was_fetched_via_proxy = request->was_fetched_via_proxy();
57 response->head.socket_address = request->GetSocketAddress(); 58 response->head.socket_address = request->GetSocketAddress();
58 if (ServiceWorkerRequestHandler* handler = 59 if (ServiceWorkerRequestHandler* handler =
59 ServiceWorkerRequestHandler::GetHandler(request)) { 60 ServiceWorkerRequestHandler::GetHandler(request)) {
60 handler->GetExtraResponseInfo( 61 handler->GetExtraResponseInfo(
61 &response->head.was_fetched_via_service_worker, 62 &response->head.was_fetched_via_service_worker,
62 &response->head.original_url_via_service_worker); 63 &response->head.original_url_via_service_worker);
63 } 64 }
64 AppCacheInterceptor::GetExtraResponseInfo( 65 AppCacheInterceptor::GetExtraResponseInfo(
65 request, 66 request,
66 &response->head.appcache_id, 67 &response->head.appcache_id,
67 &response->head.appcache_manifest_url); 68 &response->head.appcache_manifest_url);
68 // TODO(mmenke): Figure out if LOAD_ENABLE_LOAD_TIMING is safe to remove. 69 if (info->is_load_timing_enabled())
69 if (request->load_flags() & net::LOAD_ENABLE_LOAD_TIMING)
70 request->GetLoadTimingInfo(&response->head.load_timing); 70 request->GetLoadTimingInfo(&response->head.load_timing);
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 ResourceLoader::ResourceLoader(scoped_ptr<net::URLRequest> request, 75 ResourceLoader::ResourceLoader(scoped_ptr<net::URLRequest> request,
76 scoped_ptr<ResourceHandler> handler, 76 scoped_ptr<ResourceHandler> handler,
77 ResourceLoaderDelegate* delegate) 77 ResourceLoaderDelegate* delegate)
78 : deferred_stage_(DEFERRED_NONE), 78 : deferred_stage_(DEFERRED_NONE),
79 request_(request.Pass()), 79 request_(request.Pass()),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 delegate_->DidReceiveRedirect(this, new_url); 222 delegate_->DidReceiveRedirect(this, new_url);
223 223
224 if (delegate_->HandleExternalProtocol(this, new_url)) { 224 if (delegate_->HandleExternalProtocol(this, new_url)) {
225 // The request is complete so we can remove it. 225 // The request is complete so we can remove it.
226 CancelAndIgnore(); 226 CancelAndIgnore();
227 return; 227 return;
228 } 228 }
229 229
230 scoped_refptr<ResourceResponse> response(new ResourceResponse()); 230 scoped_refptr<ResourceResponse> response(new ResourceResponse());
231 PopulateResourceResponse(request_.get(), response.get()); 231 PopulateResourceResponse(info, request_.get(), response.get());
232 232
233 if (!handler_->OnRequestRedirected(new_url, response.get(), defer)) { 233 if (!handler_->OnRequestRedirected(new_url, response.get(), defer)) {
234 Cancel(); 234 Cancel();
235 } else if (*defer) { 235 } else if (*defer) {
236 deferred_stage_ = DEFERRED_REDIRECT; // Follow redirect when resumed. 236 deferred_stage_ = DEFERRED_REDIRECT; // Follow redirect when resumed.
237 } 237 }
238 } 238 }
239 239
240 void ResourceLoader::OnAuthRequired(net::URLRequest* unused, 240 void ResourceLoader::OnAuthRequired(net::URLRequest* unused,
241 net::AuthChallengeInfo* auth_info) { 241 net::AuthChallengeInfo* auth_info) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 const int sct_id(sct_store->Store(iter->sct, process_id)); 520 const int sct_id(sct_store->Store(iter->sct, process_id));
521 sct_ids->push_back( 521 sct_ids->push_back(
522 SignedCertificateTimestampIDAndStatus(sct_id, iter->status)); 522 SignedCertificateTimestampIDAndStatus(sct_id, iter->status));
523 } 523 }
524 } 524 }
525 525
526 void ResourceLoader::CompleteResponseStarted() { 526 void ResourceLoader::CompleteResponseStarted() {
527 ResourceRequestInfoImpl* info = GetRequestInfo(); 527 ResourceRequestInfoImpl* info = GetRequestInfo();
528 528
529 scoped_refptr<ResourceResponse> response(new ResourceResponse()); 529 scoped_refptr<ResourceResponse> response(new ResourceResponse());
530 PopulateResourceResponse(request_.get(), response.get()); 530 PopulateResourceResponse(info, request_.get(), response.get());
531 531
532 if (request_->ssl_info().cert.get()) { 532 if (request_->ssl_info().cert.get()) {
533 int cert_id = CertStore::GetInstance()->StoreCert( 533 int cert_id = CertStore::GetInstance()->StoreCert(
534 request_->ssl_info().cert.get(), info->GetChildID()); 534 request_->ssl_info().cert.get(), info->GetChildID());
535 535
536 SignedCertificateTimestampIDStatusList signed_certificate_timestamp_ids; 536 SignedCertificateTimestampIDStatusList signed_certificate_timestamp_ids;
537 StoreSignedCertificateTimestamps( 537 StoreSignedCertificateTimestamps(
538 request_->ssl_info().signed_certificate_timestamps, 538 request_->ssl_info().signed_certificate_timestamps,
539 info->GetChildID(), 539 info->GetChildID(),
540 &signed_certificate_timestamp_ids); 540 &signed_certificate_timestamp_ids);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 case net::URLRequestStatus::FAILED: 703 case net::URLRequestStatus::FAILED:
704 status = STATUS_UNDEFINED; 704 status = STATUS_UNDEFINED;
705 break; 705 break;
706 } 706 }
707 707
708 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); 708 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX);
709 } 709 }
710 } 710 }
711 711
712 } // namespace content 712 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/browser/loader/resource_request_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698