OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "content/browser/appcache/appcache_interceptor.h" | 17 #include "content/browser/appcache/appcache_interceptor.h" |
18 #include "content/browser/child_process_security_policy_impl.h" | 18 #include "content/browser/child_process_security_policy_impl.h" |
19 #include "content/browser/loader/cross_site_resource_handler.h" | 19 #include "content/browser/loader/cross_site_resource_handler.h" |
20 #include "content/browser/loader/detachable_resource_handler.h" | 20 #include "content/browser/loader/detachable_resource_handler.h" |
21 #include "content/browser/loader/resource_loader_delegate.h" | 21 #include "content/browser/loader/resource_loader_delegate.h" |
22 #include "content/browser/loader/resource_request_info_impl.h" | 22 #include "content/browser/loader/resource_request_info_impl.h" |
23 #include "content/browser/service_worker/service_worker_request_handler.h" | 23 #include "content/browser/service_worker/service_worker_request_handler.h" |
24 #include "content/browser/service_worker/service_worker_response_info.h" | 24 #include "content/browser/service_worker/service_worker_response_info.h" |
25 #include "content/browser/ssl/ssl_client_auth_handler.h" | 25 #include "content/browser/ssl/ssl_client_auth_handler.h" |
26 #include "content/browser/ssl/ssl_manager.h" | 26 #include "content/browser/ssl/ssl_manager.h" |
27 #include "content/browser/ssl/ssl_policy.h" | 27 #include "content/browser/ssl/ssl_policy.h" |
28 #include "content/common/security_style_util.h" | 28 #include "content/common/security_style_util.h" |
29 #include "content/common/ssl_status_serialization.h" | |
30 #include "content/public/browser/cert_store.h" | 29 #include "content/public/browser/cert_store.h" |
31 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 30 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
32 #include "content/public/common/content_client.h" | 31 #include "content/public/common/content_client.h" |
33 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
34 #include "content/public/common/process_type.h" | 33 #include "content/public/common/process_type.h" |
35 #include "content/public/common/resource_response.h" | 34 #include "content/public/common/resource_response.h" |
36 #include "content/public/common/resource_type.h" | 35 #include "content/public/common/resource_type.h" |
37 #include "content/public/common/security_style.h" | 36 #include "content/public/common/security_style.h" |
| 37 #include "content/public/common/ssl_status.h" |
38 #include "net/base/io_buffer.h" | 38 #include "net/base/io_buffer.h" |
39 #include "net/base/load_flags.h" | 39 #include "net/base/load_flags.h" |
40 #include "net/http/http_response_headers.h" | 40 #include "net/http/http_response_headers.h" |
41 #include "net/nqe/effective_connection_type.h" | 41 #include "net/nqe/effective_connection_type.h" |
42 #include "net/nqe/network_quality_estimator.h" | 42 #include "net/nqe/network_quality_estimator.h" |
43 #include "net/ssl/client_cert_store.h" | 43 #include "net/ssl/client_cert_store.h" |
44 #include "net/ssl/ssl_platform_key.h" | 44 #include "net/ssl/ssl_platform_key.h" |
45 #include "net/ssl/ssl_private_key.h" | 45 #include "net/ssl/ssl_private_key.h" |
46 #include "net/url_request/redirect_info.h" | 46 #include "net/url_request/redirect_info.h" |
47 #include "net/url_request/url_request_context.h" | 47 #include "net/url_request/url_request_context.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (service_worker_info) | 95 if (service_worker_info) |
96 service_worker_info->GetExtraResponseInfo(&response->head); | 96 service_worker_info->GetExtraResponseInfo(&response->head); |
97 AppCacheInterceptor::GetExtraResponseInfo( | 97 AppCacheInterceptor::GetExtraResponseInfo( |
98 request, &response->head.appcache_id, | 98 request, &response->head.appcache_id, |
99 &response->head.appcache_manifest_url); | 99 &response->head.appcache_manifest_url); |
100 if (info->is_load_timing_enabled()) | 100 if (info->is_load_timing_enabled()) |
101 request->GetLoadTimingInfo(&response->head.load_timing); | 101 request->GetLoadTimingInfo(&response->head.load_timing); |
102 | 102 |
103 if (request->ssl_info().cert.get()) { | 103 if (request->ssl_info().cert.get()) { |
104 SSLStatus ssl_status; | 104 SSLStatus ssl_status; |
| 105 // TODO(jam): keep this call temporarily since it's what adds the |
| 106 // certificate to the CertStore. |
105 ResourceLoader::GetSSLStatusForRequest( | 107 ResourceLoader::GetSSLStatusForRequest( |
106 request->url(), request->ssl_info(), info->GetChildID(), | 108 request->url(), request->ssl_info(), info->GetChildID(), |
107 cert_store, &ssl_status); | 109 cert_store, &ssl_status); |
108 response->head.security_info = SerializeSecurityInfo(ssl_status); | |
109 response->head.has_major_certificate_errors = | 110 response->head.has_major_certificate_errors = |
110 net::IsCertStatusError(ssl_status.cert_status) && | 111 net::IsCertStatusError(request->ssl_info().cert_status) && |
111 !net::IsCertStatusMinorError(ssl_status.cert_status); | 112 !net::IsCertStatusMinorError(request->ssl_info().cert_status); |
112 if (info->ShouldReportRawHeaders()) { | 113 if (info->ShouldReportRawHeaders()) { |
113 // Only pass these members when the network panel of the DevTools is open, | 114 // Only pass these members when the network panel of the DevTools is open, |
114 // i.e. ShouldReportRawHeaders() is set. These data are used to populate | 115 // i.e. ShouldReportRawHeaders() is set. These data are used to populate |
115 // the requests in the security panel too. | 116 // the requests in the security panel too. |
116 response->head.cert_status = request->ssl_info().cert_status; | 117 response->head.cert_status = request->ssl_info().cert_status; |
117 response->head.ssl_connection_status = | 118 response->head.ssl_connection_status = |
118 request->ssl_info().connection_status; | 119 request->ssl_info().connection_status; |
119 response->head.signed_certificate_timestamps = | 120 response->head.signed_certificate_timestamps = |
120 request->ssl_info().signed_certificate_timestamps; | 121 request->ssl_info().signed_certificate_timestamps; |
121 std::string encoded; | 122 std::string encoded; |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 } | 672 } |
672 | 673 |
673 void ResourceLoader::ResponseCompleted() { | 674 void ResourceLoader::ResponseCompleted() { |
674 TRACE_EVENT_WITH_FLOW0("loading", "ResourceLoader::ResponseCompleted", this, | 675 TRACE_EVENT_WITH_FLOW0("loading", "ResourceLoader::ResponseCompleted", this, |
675 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); | 676 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); |
676 | 677 |
677 DVLOG(1) << "ResponseCompleted: " << request_->url().spec(); | 678 DVLOG(1) << "ResponseCompleted: " << request_->url().spec(); |
678 RecordHistograms(); | 679 RecordHistograms(); |
679 ResourceRequestInfoImpl* info = GetRequestInfo(); | 680 ResourceRequestInfoImpl* info = GetRequestInfo(); |
680 | 681 |
681 std::string security_info; | |
682 const net::SSLInfo& ssl_info = request_->ssl_info(); | 682 const net::SSLInfo& ssl_info = request_->ssl_info(); |
683 if (ssl_info.cert.get() != NULL) { | 683 if (ssl_info.cert.get() != NULL) { |
684 SSLStatus ssl_status; | 684 SSLStatus ssl_status; |
| 685 // TODO(jam): keep this call temporarily since it's what adds the |
| 686 // certificate to the CertStore. |
685 GetSSLStatusForRequest(request_->url(), ssl_info, info->GetChildID(), | 687 GetSSLStatusForRequest(request_->url(), ssl_info, info->GetChildID(), |
686 cert_store_, &ssl_status); | 688 cert_store_, &ssl_status); |
687 | |
688 security_info = SerializeSecurityInfo(ssl_status); | |
689 } | 689 } |
690 | 690 |
691 bool defer = false; | 691 bool defer = false; |
692 { | 692 { |
693 // TODO(darin): Remove ScopedTracker below once crbug.com/475761 is fixed. | 693 // TODO(darin): Remove ScopedTracker below once crbug.com/475761 is fixed. |
694 tracked_objects::ScopedTracker tracking_profile( | 694 tracked_objects::ScopedTracker tracking_profile( |
695 FROM_HERE_WITH_EXPLICIT_FUNCTION("475761 OnResponseCompleted()")); | 695 FROM_HERE_WITH_EXPLICIT_FUNCTION("475761 OnResponseCompleted()")); |
696 | 696 |
697 handler_->OnResponseCompleted(request_->status(), security_info, &defer); | 697 handler_->OnResponseCompleted(request_->status(), &defer); |
698 } | 698 } |
699 if (defer) { | 699 if (defer) { |
700 // The handler is not ready to die yet. We will call DidFinishLoading when | 700 // The handler is not ready to die yet. We will call DidFinishLoading when |
701 // we resume. | 701 // we resume. |
702 deferred_stage_ = DEFERRED_FINISH; | 702 deferred_stage_ = DEFERRED_FINISH; |
703 } else { | 703 } else { |
704 // This will result in our destruction. | 704 // This will result in our destruction. |
705 CallDidFinishLoading(); | 705 CallDidFinishLoading(); |
706 } | 706 } |
707 } | 707 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 } | 754 } |
755 | 755 |
756 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 756 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
757 } else if (request_->response_info().unused_since_prefetch) { | 757 } else if (request_->response_info().unused_since_prefetch) { |
758 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); | 758 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); |
759 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time); | 759 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time); |
760 } | 760 } |
761 } | 761 } |
762 | 762 |
763 } // namespace content | 763 } // namespace content |
OLD | NEW |