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 "net/http/http_stream_factory_impl_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return std::move(dict); | 133 return std::move(dict); |
134 } | 134 } |
135 | 135 |
136 // Returns parameters associated with the Proto (with NPN negotiation) of a HTTP | 136 // Returns parameters associated with the Proto (with NPN negotiation) of a HTTP |
137 // stream. | 137 // stream. |
138 std::unique_ptr<base::Value> NetLogHttpStreamProtoCallback( | 138 std::unique_ptr<base::Value> NetLogHttpStreamProtoCallback( |
139 NextProto negotiated_protocol, | 139 NextProto negotiated_protocol, |
140 NetLogCaptureMode /* capture_mode */) { | 140 NetLogCaptureMode /* capture_mode */) { |
141 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 141 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
142 | 142 |
143 dict->SetString("proto", | 143 dict->SetString("proto", NextProtoToString(negotiated_protocol)); |
144 SSLClientSocket::NextProtoToString(negotiated_protocol)); | |
145 return std::move(dict); | 144 return std::move(dict); |
146 } | 145 } |
147 | 146 |
148 HttpStreamFactoryImpl::Job::Job(Delegate* delegate, | 147 HttpStreamFactoryImpl::Job::Job(Delegate* delegate, |
149 JobType job_type, | 148 JobType job_type, |
150 HttpNetworkSession* session, | 149 HttpNetworkSession* session, |
151 const HttpRequestInfo& request_info, | 150 const HttpRequestInfo& request_info, |
152 RequestPriority priority, | 151 RequestPriority priority, |
153 const SSLConfig& server_ssl_config, | 152 const SSLConfig& server_ssl_config, |
154 const SSLConfig& proxy_ssl_config, | 153 const SSLConfig& proxy_ssl_config, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 negotiated_protocol_(kProtoUnknown), | 206 negotiated_protocol_(kProtoUnknown), |
208 num_streams_(0), | 207 num_streams_(0), |
209 spdy_session_direct_(false), | 208 spdy_session_direct_(false), |
210 stream_type_(HttpStreamRequest::BIDIRECTIONAL_STREAM), | 209 stream_type_(HttpStreamRequest::BIDIRECTIONAL_STREAM), |
211 ptr_factory_(this) { | 210 ptr_factory_(this) { |
212 DCHECK(session); | 211 DCHECK(session); |
213 // The job can't have alternative service and alternative proxy server set at | 212 // The job can't have alternative service and alternative proxy server set at |
214 // the same time since alternative services are used for requests that are | 213 // the same time since alternative services are used for requests that are |
215 // fetched directly, while the alternative proxy server is used for requests | 214 // fetched directly, while the alternative proxy server is used for requests |
216 // that should be fetched using proxy. | 215 // that should be fetched using proxy. |
217 DCHECK(alternative_service_.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL || | 216 DCHECK(alternative_service_.protocol == kProtoUnknown || |
218 !alternative_proxy_server_.is_valid()); | 217 !alternative_proxy_server_.is_valid()); |
219 DCHECK(!alternative_proxy_server_.is_valid() || | 218 DCHECK(!alternative_proxy_server_.is_valid() || |
220 !(IsSpdyAlternative() || IsQuicAlternative())); | 219 !(IsSpdyAlternative() || IsQuicAlternative())); |
221 // If either the alternative service protocol is specified or if the | 220 // If either the alternative service protocol is specified or if the |
222 // alternative proxy server is valid, then the job type must be set to | 221 // alternative proxy server is valid, then the job type must be set to |
223 // either ALTERNATIVE or PRECONNECT. | 222 // either ALTERNATIVE or PRECONNECT. |
224 DCHECK((alternative_service_.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL && | 223 DCHECK((alternative_service_.protocol == kProtoUnknown && |
225 !alternative_proxy_server_.is_valid()) || | 224 !alternative_proxy_server_.is_valid()) || |
226 (job_type_ == ALTERNATIVE || job_type_ == PRECONNECT)); | 225 (job_type_ == ALTERNATIVE || job_type_ == PRECONNECT)); |
227 // If the alternative proxy server is valid, then the job type must be | 226 // If the alternative proxy server is valid, then the job type must be |
228 // set to ALTERNATIVE. | 227 // set to ALTERNATIVE. |
229 DCHECK(!alternative_proxy_server_.is_valid() || job_type_ == ALTERNATIVE); | 228 DCHECK(!alternative_proxy_server_.is_valid() || job_type_ == ALTERNATIVE); |
230 | 229 |
231 if (IsSpdyAlternative()) { | 230 if (IsSpdyAlternative()) { |
232 DCHECK(origin_url_.SchemeIs(url::kHttpsScheme)); | 231 DCHECK(origin_url_.SchemeIs(url::kHttpsScheme)); |
233 } | 232 } |
234 if (IsQuicAlternative()) { | 233 if (IsQuicAlternative()) { |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 // We currently only support Alternate-Protocol where the original scheme | 1304 // We currently only support Alternate-Protocol where the original scheme |
1306 // is http. | 1305 // is http. |
1307 // TODO(bnc): This comment is probably incorrect. | 1306 // TODO(bnc): This comment is probably incorrect. |
1308 DCHECK(origin_url_.SchemeIs(url::kHttpScheme)); | 1307 DCHECK(origin_url_.SchemeIs(url::kHttpScheme)); |
1309 return origin_url_.SchemeIs(url::kHttpScheme); | 1308 return origin_url_.SchemeIs(url::kHttpScheme); |
1310 } | 1309 } |
1311 return request_info_.url.SchemeIs(url::kHttpScheme); | 1310 return request_info_.url.SchemeIs(url::kHttpScheme); |
1312 } | 1311 } |
1313 | 1312 |
1314 bool HttpStreamFactoryImpl::Job::IsSpdyAlternative() const { | 1313 bool HttpStreamFactoryImpl::Job::IsSpdyAlternative() const { |
1315 return alternative_service_.protocol == NPN_HTTP_2; | 1314 return alternative_service_.protocol == kProtoHTTP2; |
1316 } | 1315 } |
1317 | 1316 |
1318 bool HttpStreamFactoryImpl::Job::IsQuicAlternative() const { | 1317 bool HttpStreamFactoryImpl::Job::IsQuicAlternative() const { |
1319 return alternative_service_.protocol == QUIC; | 1318 return alternative_service_.protocol == kProtoQUIC; |
1320 } | 1319 } |
1321 | 1320 |
1322 void HttpStreamFactoryImpl::Job::InitSSLConfig(SSLConfig* ssl_config, | 1321 void HttpStreamFactoryImpl::Job::InitSSLConfig(SSLConfig* ssl_config, |
1323 bool is_proxy) const { | 1322 bool is_proxy) const { |
1324 if (!is_proxy) { | 1323 if (!is_proxy) { |
1325 // Prior to HTTP/2 and SPDY, some servers use TLS renegotiation to request | 1324 // Prior to HTTP/2 and SPDY, some servers use TLS renegotiation to request |
1326 // TLS client authentication after the HTTP request was sent. Allow | 1325 // TLS client authentication after the HTTP request was sent. Allow |
1327 // renegotiation for only those connections. | 1326 // renegotiation for only those connections. |
1328 // | 1327 // |
1329 // Note that this does NOT implement the provision in | 1328 // Note that this does NOT implement the provision in |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 | 1500 |
1502 ConnectionAttempts socket_attempts = connection_->connection_attempts(); | 1501 ConnectionAttempts socket_attempts = connection_->connection_attempts(); |
1503 if (connection_->socket()) { | 1502 if (connection_->socket()) { |
1504 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1503 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
1505 } | 1504 } |
1506 | 1505 |
1507 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); | 1506 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); |
1508 } | 1507 } |
1509 | 1508 |
1510 } // namespace net | 1509 } // namespace net |
OLD | NEW |