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" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "net/url_request/redirect_info.h" | 45 #include "net/url_request/redirect_info.h" |
46 #include "net/url_request/url_request_context.h" | 46 #include "net/url_request/url_request_context.h" |
47 #include "net/url_request/url_request_status.h" | 47 #include "net/url_request/url_request_status.h" |
48 | 48 |
49 using base::TimeDelta; | 49 using base::TimeDelta; |
50 using base::TimeTicks; | 50 using base::TimeTicks; |
51 | 51 |
52 namespace content { | 52 namespace content { |
53 namespace { | 53 namespace { |
54 | 54 |
55 void GetSSLStatusForRequest(const GURL& url, | |
56 const net::SSLInfo& ssl_info, | |
57 int child_id, | |
58 CertStore* cert_store, | |
59 SSLStatus* ssl_status) { | |
60 DCHECK(ssl_info.cert); | |
61 int cert_id = cert_store->StoreCert(ssl_info.cert.get(), child_id); | |
62 | |
63 *ssl_status = SSLStatus(SSLPolicy::GetSecurityStyleForResource( | |
64 url, cert_id, ssl_info.cert_status), | |
65 cert_id, ssl_info); | |
66 } | |
67 | |
68 void PopulateResourceResponse(ResourceRequestInfoImpl* info, | 55 void PopulateResourceResponse(ResourceRequestInfoImpl* info, |
69 net::URLRequest* request, | 56 net::URLRequest* request, |
70 CertStore* cert_store, | 57 CertStore* cert_store, |
71 ResourceResponse* response) { | 58 ResourceResponse* response) { |
72 response->head.request_time = request->request_time(); | 59 response->head.request_time = request->request_time(); |
73 response->head.response_time = request->response_time(); | 60 response->head.response_time = request->response_time(); |
74 response->head.headers = request->response_headers(); | 61 response->head.headers = request->response_headers(); |
75 request->GetCharset(&response->head.charset); | 62 request->GetCharset(&response->head.charset); |
76 response->head.content_length = request->GetExpectedContentSize(); | 63 response->head.content_length = request->GetExpectedContentSize(); |
77 request->GetMimeType(&response->head.mime_type); | 64 request->GetMimeType(&response->head.mime_type); |
(...skipping 29 matching lines...) Expand all Loading... |
107 if (service_worker_info) | 94 if (service_worker_info) |
108 service_worker_info->GetExtraResponseInfo(&response->head); | 95 service_worker_info->GetExtraResponseInfo(&response->head); |
109 AppCacheInterceptor::GetExtraResponseInfo( | 96 AppCacheInterceptor::GetExtraResponseInfo( |
110 request, &response->head.appcache_id, | 97 request, &response->head.appcache_id, |
111 &response->head.appcache_manifest_url); | 98 &response->head.appcache_manifest_url); |
112 if (info->is_load_timing_enabled()) | 99 if (info->is_load_timing_enabled()) |
113 request->GetLoadTimingInfo(&response->head.load_timing); | 100 request->GetLoadTimingInfo(&response->head.load_timing); |
114 | 101 |
115 if (request->ssl_info().cert.get()) { | 102 if (request->ssl_info().cert.get()) { |
116 SSLStatus ssl_status; | 103 SSLStatus ssl_status; |
117 GetSSLStatusForRequest(request->url(), request->ssl_info(), | 104 ResourceLoader::GetSSLStatusForRequest( |
118 info->GetChildID(), cert_store, &ssl_status); | 105 request->url(), request->ssl_info(), info->GetChildID(), |
| 106 cert_store, &ssl_status); |
119 response->head.security_info = SerializeSecurityInfo(ssl_status); | 107 response->head.security_info = SerializeSecurityInfo(ssl_status); |
120 response->head.has_major_certificate_errors = | 108 response->head.has_major_certificate_errors = |
121 net::IsCertStatusError(ssl_status.cert_status) && | 109 net::IsCertStatusError(ssl_status.cert_status) && |
122 !net::IsCertStatusMinorError(ssl_status.cert_status); | 110 !net::IsCertStatusMinorError(ssl_status.cert_status); |
123 if (info->ShouldReportRawHeaders()) { | 111 if (info->ShouldReportRawHeaders()) { |
124 // Only pass the Signed Certificate Timestamps (SCTs) when the network | 112 // Only pass the Signed Certificate Timestamps (SCTs) when the network |
125 // panel of the DevTools is open, i.e. ShouldReportRawHeaders() is set. | 113 // panel of the DevTools is open, i.e. ShouldReportRawHeaders() is set. |
126 // These data are used to populate the requests in the security panel too. | 114 // These data are used to populate the requests in the security panel too. |
127 response->head.signed_certificate_timestamps = | 115 response->head.signed_certificate_timestamps = |
128 request->ssl_info().signed_certificate_timestamps; | 116 request->ssl_info().signed_certificate_timestamps; |
129 } | 117 } |
130 } else { | 118 } else { |
131 // We should not have any SSL state. | 119 // We should not have any SSL state. |
132 DCHECK(!request->ssl_info().cert_status); | 120 DCHECK(!request->ssl_info().cert_status); |
133 DCHECK_EQ(request->ssl_info().security_bits, -1); | 121 DCHECK_EQ(request->ssl_info().security_bits, -1); |
134 DCHECK_EQ(request->ssl_info().key_exchange_info, 0); | 122 DCHECK_EQ(request->ssl_info().key_exchange_info, 0); |
135 DCHECK(!request->ssl_info().connection_status); | 123 DCHECK(!request->ssl_info().connection_status); |
136 } | 124 } |
137 } | 125 } |
138 | 126 |
139 } // namespace | 127 } // namespace |
140 | 128 |
| 129 void ResourceLoader::GetSSLStatusForRequest(const GURL& url, |
| 130 const net::SSLInfo& ssl_info, |
| 131 int child_id, |
| 132 CertStore* cert_store, |
| 133 SSLStatus* ssl_status) { |
| 134 DCHECK(ssl_info.cert); |
| 135 int cert_id = cert_store->StoreCert(ssl_info.cert.get(), child_id); |
| 136 |
| 137 *ssl_status = SSLStatus(SSLPolicy::GetSecurityStyleForResource( |
| 138 url, cert_id, ssl_info.cert_status), |
| 139 cert_id, ssl_info); |
| 140 } |
| 141 |
141 ResourceLoader::ResourceLoader(std::unique_ptr<net::URLRequest> request, | 142 ResourceLoader::ResourceLoader(std::unique_ptr<net::URLRequest> request, |
142 std::unique_ptr<ResourceHandler> handler, | 143 std::unique_ptr<ResourceHandler> handler, |
143 CertStore* cert_store, | 144 CertStore* cert_store, |
144 ResourceLoaderDelegate* delegate) | 145 ResourceLoaderDelegate* delegate) |
145 : deferred_stage_(DEFERRED_NONE), | 146 : deferred_stage_(DEFERRED_NONE), |
146 request_(std::move(request)), | 147 request_(std::move(request)), |
147 handler_(std::move(handler)), | 148 handler_(std::move(handler)), |
148 delegate_(delegate), | 149 delegate_(delegate), |
149 is_transferring_(false), | 150 is_transferring_(false), |
150 times_cancelled_before_request_start_(0), | 151 times_cancelled_before_request_start_(0), |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 } | 739 } |
739 | 740 |
740 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 741 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
741 } else if (request_->response_info().unused_since_prefetch) { | 742 } else if (request_->response_info().unused_since_prefetch) { |
742 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); | 743 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); |
743 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time); | 744 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time); |
744 } | 745 } |
745 } | 746 } |
746 | 747 |
747 } // namespace content | 748 } // namespace content |
OLD | NEW |