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