OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "net/base/connection_type_histograms.h" | 12 #include "net/base/connection_type_histograms.h" |
13 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
15 #include "net/base/ssl_cert_request_info.h" | 15 #include "net/base/ssl_cert_request_info.h" |
16 #include "net/http/http_basic_stream.h" | 16 #include "net/http/http_basic_stream.h" |
17 #include "net/http/http_network_session.h" | 17 #include "net/http/http_network_session.h" |
18 #include "net/http/http_proxy_client_socket.h" | 18 #include "net/http/http_proxy_client_socket.h" |
19 #include "net/http/http_proxy_client_socket_pool.h" | 19 #include "net/http/http_proxy_client_socket_pool.h" |
20 #include "net/http/http_request_info.h" | 20 #include "net/http/http_request_info.h" |
21 #include "net/http/http_stream_factory_impl_request.h" | 21 #include "net/http/http_stream_factory_impl_request.h" |
22 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
23 #include "net/socket/client_socket_pool.h" | 23 #include "net/socket/client_socket_pool.h" |
24 #include "net/socket/sctp_support.h" | |
24 #include "net/socket/socks_client_socket_pool.h" | 25 #include "net/socket/socks_client_socket_pool.h" |
25 #include "net/socket/ssl_client_socket.h" | 26 #include "net/socket/ssl_client_socket.h" |
26 #include "net/socket/ssl_client_socket_pool.h" | 27 #include "net/socket/ssl_client_socket_pool.h" |
27 #include "net/socket/tcp_client_socket_pool.h" | 28 #include "net/socket/tcp_client_socket_pool.h" |
28 #include "net/spdy/spdy_http_stream.h" | 29 #include "net/spdy/spdy_http_stream.h" |
29 #include "net/spdy/spdy_session.h" | 30 #include "net/spdy/spdy_session.h" |
30 #include "net/spdy/spdy_session_pool.h" | 31 #include "net/spdy/spdy_session_pool.h" |
31 | 32 |
32 namespace net { | 33 namespace net { |
33 | 34 |
(...skipping 23 matching lines...) Expand all Loading... | |
57 using_spdy_(false), | 58 using_spdy_(false), |
58 force_spdy_always_(HttpStreamFactory::force_spdy_always()), | 59 force_spdy_always_(HttpStreamFactory::force_spdy_always()), |
59 force_spdy_over_ssl_(HttpStreamFactory::force_spdy_over_ssl()), | 60 force_spdy_over_ssl_(HttpStreamFactory::force_spdy_over_ssl()), |
60 spdy_certificate_error_(OK), | 61 spdy_certificate_error_(OK), |
61 establishing_tunnel_(false), | 62 establishing_tunnel_(false), |
62 was_npn_negotiated_(false), | 63 was_npn_negotiated_(false), |
63 num_streams_(0), | 64 num_streams_(0), |
64 spdy_session_direct_(false), | 65 spdy_session_direct_(false), |
65 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 66 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
66 DCHECK(stream_factory); | 67 DCHECK(stream_factory); |
67 DCHECK(session); | 68 CHECK(session); |
Mike Belshe
2011/04/06 18:32:53
nit: accidental?
| |
68 } | 69 } |
69 | 70 |
70 HttpStreamFactoryImpl::Job::~Job() { | 71 HttpStreamFactoryImpl::Job::~Job() { |
71 net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_JOB, NULL); | 72 net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_JOB, NULL); |
72 | 73 |
73 // When we're in a partially constructed state, waiting for the user to | 74 // When we're in a partially constructed state, waiting for the user to |
74 // provide certificate handling information or authentication, we can't reuse | 75 // provide certificate handling information or authentication, we can't reuse |
75 // this stream at all. | 76 // this stream at all. |
76 if (next_state_ == STATE_WAITING_USER_ACTION) { | 77 if (next_state_ == STATE_WAITING_USER_ACTION) { |
77 connection_->socket()->Disconnect(); | 78 connection_->socket()->Disconnect(); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 next_state_ = STATE_INIT_CONNECTION; | 521 next_state_ = STATE_INIT_CONNECTION; |
521 return OK; | 522 return OK; |
522 } | 523 } |
523 | 524 |
524 int HttpStreamFactoryImpl::Job::DoInitConnection() { | 525 int HttpStreamFactoryImpl::Job::DoInitConnection() { |
525 DCHECK(!blocking_job_); | 526 DCHECK(!blocking_job_); |
526 DCHECK(!connection_->is_initialized()); | 527 DCHECK(!connection_->is_initialized()); |
527 DCHECK(proxy_info_.proxy_server().is_valid()); | 528 DCHECK(proxy_info_.proxy_server().is_valid()); |
528 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 529 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
529 | 530 |
530 using_ssl_ = request_info_.url.SchemeIs("https") || ShouldForceSpdySSL(); | 531 if (sctp_enabled()) |
532 using_ssl_ = false; | |
533 else | |
534 using_ssl_ = request_info_.url.SchemeIs("https") || ShouldForceSpdySSL(); | |
531 using_spdy_ = false; | 535 using_spdy_ = false; |
532 | 536 |
533 // Check first if we have a spdy session for this group. If so, then go | 537 // Check first if we have a spdy session for this group. If so, then go |
534 // straight to using that. | 538 // straight to using that. |
535 HostPortProxyPair spdy_session_key; | 539 HostPortProxyPair spdy_session_key; |
536 if (IsHttpsProxyAndHttpUrl()) { | 540 if (IsHttpsProxyAndHttpUrl()) { |
537 spdy_session_key = | 541 spdy_session_key = |
538 HostPortProxyPair(proxy_info_.proxy_server().host_port_pair(), | 542 HostPortProxyPair(proxy_info_.proxy_server().host_port_pair(), |
539 ProxyServer::Direct()); | 543 ProxyServer::Direct()); |
540 } else { | 544 } else { |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 bool HttpStreamFactoryImpl::Job::IsPreconnecting() const { | 1035 bool HttpStreamFactoryImpl::Job::IsPreconnecting() const { |
1032 DCHECK_GE(num_streams_, 0); | 1036 DCHECK_GE(num_streams_, 0); |
1033 return num_streams_ > 0; | 1037 return num_streams_ > 0; |
1034 } | 1038 } |
1035 | 1039 |
1036 bool HttpStreamFactoryImpl::Job::IsOrphaned() const { | 1040 bool HttpStreamFactoryImpl::Job::IsOrphaned() const { |
1037 return !IsPreconnecting() && !request_; | 1041 return !IsPreconnecting() && !request_; |
1038 } | 1042 } |
1039 | 1043 |
1040 } // namespace net | 1044 } // namespace net |
OLD | NEW |