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 // TODO(ukai): code is similar with http_network_transaction.cc. We should | 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should |
6 // think about ways to share code, if possible. | 6 // think about ways to share code, if possible. |
7 | 7 |
8 #include "net/socket_stream/socket_stream.h" | 8 #include "net/socket_stream/socket_stream.h" |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 SocketStream::ResponseHeaders::~ResponseHeaders() { data_ = NULL; } | 52 SocketStream::ResponseHeaders::~ResponseHeaders() { data_ = NULL; } |
53 | 53 |
54 SocketStream::SocketStream(const GURL& url, Delegate* delegate) | 54 SocketStream::SocketStream(const GURL& url, Delegate* delegate) |
55 : delegate_(delegate), | 55 : delegate_(delegate), |
56 url_(url), | 56 url_(url), |
57 max_pending_send_allowed_(kMaxPendingSendAllowed), | 57 max_pending_send_allowed_(kMaxPendingSendAllowed), |
58 next_state_(STATE_NONE), | 58 next_state_(STATE_NONE), |
59 host_resolver_(NULL), | 59 host_resolver_(NULL), |
60 cert_verifier_(NULL), | 60 cert_verifier_(NULL), |
61 origin_bound_cert_service_(NULL), | 61 server_bound_cert_service_(NULL), |
62 http_auth_handler_factory_(NULL), | 62 http_auth_handler_factory_(NULL), |
63 factory_(ClientSocketFactory::GetDefaultFactory()), | 63 factory_(ClientSocketFactory::GetDefaultFactory()), |
64 proxy_mode_(kDirectConnection), | 64 proxy_mode_(kDirectConnection), |
65 proxy_url_(url), | 65 proxy_url_(url), |
66 pac_request_(NULL), | 66 pac_request_(NULL), |
67 // Unretained() is required; without it, Bind() creates a circular | 67 // Unretained() is required; without it, Bind() creates a circular |
68 // dependency and the SocketStream object will not be freed. | 68 // dependency and the SocketStream object will not be freed. |
69 ALLOW_THIS_IN_INITIALIZER_LIST( | 69 ALLOW_THIS_IN_INITIALIZER_LIST( |
70 io_callback_(base::Bind(&SocketStream::OnIOCompleted, | 70 io_callback_(base::Bind(&SocketStream::OnIOCompleted, |
71 base::Unretained(this)))), | 71 base::Unretained(this)))), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 context->net_log(), | 119 context->net_log(), |
120 NetLog::SOURCE_SOCKET_STREAM); | 120 NetLog::SOURCE_SOCKET_STREAM); |
121 | 121 |
122 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE, NULL); | 122 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE, NULL); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 if (context_) { | 126 if (context_) { |
127 host_resolver_ = context_->host_resolver(); | 127 host_resolver_ = context_->host_resolver(); |
128 cert_verifier_ = context_->cert_verifier(); | 128 cert_verifier_ = context_->cert_verifier(); |
129 origin_bound_cert_service_ = context_->origin_bound_cert_service(); | 129 server_bound_cert_service_ = context_->server_bound_cert_service(); |
130 http_auth_handler_factory_ = context_->http_auth_handler_factory(); | 130 http_auth_handler_factory_ = context_->http_auth_handler_factory(); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 void SocketStream::Connect() { | 134 void SocketStream::Connect() { |
135 DCHECK(MessageLoop::current()) << | 135 DCHECK(MessageLoop::current()) << |
136 "The current MessageLoop must exist"; | 136 "The current MessageLoop must exist"; |
137 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << | 137 DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << |
138 "The current MessageLoop must be TYPE_IO"; | 138 "The current MessageLoop must be TYPE_IO"; |
139 if (context_) { | 139 if (context_) { |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 } else { | 916 } else { |
917 next_state_ = STATE_CLOSE; | 917 next_state_ = STATE_CLOSE; |
918 } | 918 } |
919 return result; | 919 return result; |
920 } | 920 } |
921 | 921 |
922 int SocketStream::DoSecureProxyConnect() { | 922 int SocketStream::DoSecureProxyConnect() { |
923 DCHECK(factory_); | 923 DCHECK(factory_); |
924 SSLClientSocketContext ssl_context; | 924 SSLClientSocketContext ssl_context; |
925 ssl_context.cert_verifier = cert_verifier_; | 925 ssl_context.cert_verifier = cert_verifier_; |
926 ssl_context.origin_bound_cert_service = origin_bound_cert_service_; | 926 ssl_context.server_bound_cert_service = server_bound_cert_service_; |
927 // TODO(agl): look into plumbing SSLHostInfo here. | 927 // TODO(agl): look into plumbing SSLHostInfo here. |
928 socket_.reset(factory_->CreateSSLClientSocket( | 928 socket_.reset(factory_->CreateSSLClientSocket( |
929 socket_.release(), | 929 socket_.release(), |
930 proxy_info_.proxy_server().host_port_pair(), | 930 proxy_info_.proxy_server().host_port_pair(), |
931 proxy_ssl_config_, | 931 proxy_ssl_config_, |
932 NULL /* ssl_host_info */, | 932 NULL /* ssl_host_info */, |
933 ssl_context)); | 933 ssl_context)); |
934 next_state_ = STATE_SECURE_PROXY_CONNECT_COMPLETE; | 934 next_state_ = STATE_SECURE_PROXY_CONNECT_COMPLETE; |
935 metrics_->OnCountConnectionType(SocketStreamMetrics::SECURE_PROXY_CONNECTION); | 935 metrics_->OnCountConnectionType(SocketStreamMetrics::SECURE_PROXY_CONNECTION); |
936 return socket_->Connect(io_callback_); | 936 return socket_->Connect(io_callback_); |
(...skipping 10 matching lines...) Expand all Loading... |
947 next_state_ = STATE_WRITE_TUNNEL_HEADERS; | 947 next_state_ = STATE_WRITE_TUNNEL_HEADERS; |
948 else | 948 else |
949 next_state_ = STATE_CLOSE; | 949 next_state_ = STATE_CLOSE; |
950 return result; | 950 return result; |
951 } | 951 } |
952 | 952 |
953 int SocketStream::DoSSLConnect() { | 953 int SocketStream::DoSSLConnect() { |
954 DCHECK(factory_); | 954 DCHECK(factory_); |
955 SSLClientSocketContext ssl_context; | 955 SSLClientSocketContext ssl_context; |
956 ssl_context.cert_verifier = cert_verifier_; | 956 ssl_context.cert_verifier = cert_verifier_; |
957 ssl_context.origin_bound_cert_service = origin_bound_cert_service_; | 957 ssl_context.server_bound_cert_service = server_bound_cert_service_; |
958 // TODO(agl): look into plumbing SSLHostInfo here. | 958 // TODO(agl): look into plumbing SSLHostInfo here. |
959 socket_.reset(factory_->CreateSSLClientSocket(socket_.release(), | 959 socket_.reset(factory_->CreateSSLClientSocket(socket_.release(), |
960 HostPortPair::FromURL(url_), | 960 HostPortPair::FromURL(url_), |
961 server_ssl_config_, | 961 server_ssl_config_, |
962 NULL /* ssl_host_info */, | 962 NULL /* ssl_host_info */, |
963 ssl_context)); | 963 ssl_context)); |
964 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 964 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
965 metrics_->OnCountConnectionType(SocketStreamMetrics::SSL_CONNECTION); | 965 metrics_->OnCountConnectionType(SocketStreamMetrics::SSL_CONNECTION); |
966 return socket_->Connect(io_callback_); | 966 return socket_->Connect(io_callback_); |
967 } | 967 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 | 1207 |
1208 SSLConfigService* SocketStream::ssl_config_service() const { | 1208 SSLConfigService* SocketStream::ssl_config_service() const { |
1209 return context_->ssl_config_service(); | 1209 return context_->ssl_config_service(); |
1210 } | 1210 } |
1211 | 1211 |
1212 ProxyService* SocketStream::proxy_service() const { | 1212 ProxyService* SocketStream::proxy_service() const { |
1213 return context_->proxy_service(); | 1213 return context_->proxy_service(); |
1214 } | 1214 } |
1215 | 1215 |
1216 } // namespace net | 1216 } // namespace net |
OLD | NEW |