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/socket/ssl_client_socket_pool.h" | 5 #include "net/socket/ssl_client_socket_pool.h" |
6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
7 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
8 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
9 #include "base/values.h" | 11 #include "base/values.h" |
10 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
11 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
12 #include "net/base/ssl_cert_request_info.h" | 14 #include "net/base/ssl_cert_request_info.h" |
13 #include "net/http/http_proxy_client_socket.h" | 15 #include "net/http/http_proxy_client_socket.h" |
14 #include "net/http/http_proxy_client_socket_pool.h" | 16 #include "net/http/http_proxy_client_socket_pool.h" |
15 #include "net/socket/client_socket_factory.h" | 17 #include "net/socket/client_socket_factory.h" |
16 #include "net/socket/client_socket_handle.h" | 18 #include "net/socket/client_socket_handle.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), | 90 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), |
89 params_(params), | 91 params_(params), |
90 transport_pool_(transport_pool), | 92 transport_pool_(transport_pool), |
91 socks_pool_(socks_pool), | 93 socks_pool_(socks_pool), |
92 http_proxy_pool_(http_proxy_pool), | 94 http_proxy_pool_(http_proxy_pool), |
93 client_socket_factory_(client_socket_factory), | 95 client_socket_factory_(client_socket_factory), |
94 host_resolver_(host_resolver), | 96 host_resolver_(host_resolver), |
95 context_(context), | 97 context_(context), |
96 ALLOW_THIS_IN_INITIALIZER_LIST( | 98 ALLOW_THIS_IN_INITIALIZER_LIST( |
97 callback_(base::Bind(&SSLConnectJob::OnIOComplete, | 99 callback_(base::Bind(&SSLConnectJob::OnIOComplete, |
98 base::Unretained(this)))), | 100 base::Unretained(this)))) {} |
99 ALLOW_THIS_IN_INITIALIZER_LIST( | |
100 callback_old_(this, &SSLConnectJob::OnIOComplete)) {} | |
101 | 101 |
102 SSLConnectJob::~SSLConnectJob() {} | 102 SSLConnectJob::~SSLConnectJob() {} |
103 | 103 |
104 LoadState SSLConnectJob::GetLoadState() const { | 104 LoadState SSLConnectJob::GetLoadState() const { |
105 switch (next_state_) { | 105 switch (next_state_) { |
106 case STATE_TUNNEL_CONNECT_COMPLETE: | 106 case STATE_TUNNEL_CONNECT_COMPLETE: |
107 if (transport_socket_handle_->socket()) | 107 if (transport_socket_handle_->socket()) |
108 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL; | 108 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL; |
109 // else, fall through. | 109 // else, fall through. |
110 case STATE_TRANSPORT_CONNECT: | 110 case STATE_TRANSPORT_CONNECT: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // This starts fetching the SSL host info from the disk cache for early | 200 // This starts fetching the SSL host info from the disk cache for early |
201 // certificate verification and the TLS cached information extension. | 201 // certificate verification and the TLS cached information extension. |
202 ssl_host_info_->Start(); | 202 ssl_host_info_->Start(); |
203 } | 203 } |
204 | 204 |
205 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; | 205 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; |
206 transport_socket_handle_.reset(new ClientSocketHandle()); | 206 transport_socket_handle_.reset(new ClientSocketHandle()); |
207 scoped_refptr<TransportSocketParams> transport_params = | 207 scoped_refptr<TransportSocketParams> transport_params = |
208 params_->transport_params(); | 208 params_->transport_params(); |
209 return transport_socket_handle_->Init( | 209 return transport_socket_handle_->Init( |
210 group_name(), | 210 group_name(), transport_params, |
211 transport_params, | 211 transport_params->destination().priority(), callback_, transport_pool_, |
212 transport_params->destination().priority(), | 212 net_log()); |
213 &callback_old_, transport_pool_, net_log()); | |
214 } | 213 } |
215 | 214 |
216 int SSLConnectJob::DoTransportConnectComplete(int result) { | 215 int SSLConnectJob::DoTransportConnectComplete(int result) { |
217 if (result == OK) | 216 if (result == OK) |
218 next_state_ = STATE_SSL_CONNECT; | 217 next_state_ = STATE_SSL_CONNECT; |
219 | 218 |
220 return result; | 219 return result; |
221 } | 220 } |
222 | 221 |
223 int SSLConnectJob::DoSOCKSConnect() { | 222 int SSLConnectJob::DoSOCKSConnect() { |
224 DCHECK(socks_pool_); | 223 DCHECK(socks_pool_); |
225 next_state_ = STATE_SOCKS_CONNECT_COMPLETE; | 224 next_state_ = STATE_SOCKS_CONNECT_COMPLETE; |
226 transport_socket_handle_.reset(new ClientSocketHandle()); | 225 transport_socket_handle_.reset(new ClientSocketHandle()); |
227 scoped_refptr<SOCKSSocketParams> socks_params = params_->socks_params(); | 226 scoped_refptr<SOCKSSocketParams> socks_params = params_->socks_params(); |
228 return transport_socket_handle_->Init(group_name(), socks_params, | 227 return transport_socket_handle_->Init( |
229 socks_params->destination().priority(), | 228 group_name(), socks_params, socks_params->destination().priority(), |
230 &callback_old_, socks_pool_, net_log()); | 229 callback_, socks_pool_, net_log()); |
231 } | 230 } |
232 | 231 |
233 int SSLConnectJob::DoSOCKSConnectComplete(int result) { | 232 int SSLConnectJob::DoSOCKSConnectComplete(int result) { |
234 if (result == OK) | 233 if (result == OK) |
235 next_state_ = STATE_SSL_CONNECT; | 234 next_state_ = STATE_SSL_CONNECT; |
236 | 235 |
237 return result; | 236 return result; |
238 } | 237 } |
239 | 238 |
240 int SSLConnectJob::DoTunnelConnect() { | 239 int SSLConnectJob::DoTunnelConnect() { |
241 DCHECK(http_proxy_pool_); | 240 DCHECK(http_proxy_pool_); |
242 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE; | 241 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE; |
243 | 242 |
244 transport_socket_handle_.reset(new ClientSocketHandle()); | 243 transport_socket_handle_.reset(new ClientSocketHandle()); |
245 scoped_refptr<HttpProxySocketParams> http_proxy_params = | 244 scoped_refptr<HttpProxySocketParams> http_proxy_params = |
246 params_->http_proxy_params(); | 245 params_->http_proxy_params(); |
247 return transport_socket_handle_->Init( | 246 return transport_socket_handle_->Init( |
248 group_name(), http_proxy_params, | 247 group_name(), http_proxy_params, |
249 http_proxy_params->destination().priority(), &callback_old_, | 248 http_proxy_params->destination().priority(), callback_, http_proxy_pool_, |
250 http_proxy_pool_, net_log()); | 249 net_log()); |
251 } | 250 } |
252 | 251 |
253 int SSLConnectJob::DoTunnelConnectComplete(int result) { | 252 int SSLConnectJob::DoTunnelConnectComplete(int result) { |
254 // Extract the information needed to prompt for appropriate proxy | 253 // Extract the information needed to prompt for appropriate proxy |
255 // authentication so that when ClientSocketPoolBaseHelper calls | 254 // authentication so that when ClientSocketPoolBaseHelper calls |
256 // |GetAdditionalErrorState|, we can easily set the state. | 255 // |GetAdditionalErrorState|, we can easily set the state. |
257 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { | 256 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { |
258 error_response_info_ = transport_socket_handle_->ssl_error_response_info(); | 257 error_response_info_ = transport_socket_handle_->ssl_error_response_info(); |
259 } else if (result == ERR_PROXY_AUTH_REQUESTED || | 258 } else if (result == ERR_PROXY_AUTH_REQUESTED || |
260 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { | 259 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 Flush(); | 619 Flush(); |
621 } | 620 } |
622 | 621 |
623 bool SSLClientSocketPool::CloseOneIdleConnection() { | 622 bool SSLClientSocketPool::CloseOneIdleConnection() { |
624 if (base_.CloseOneIdleSocket()) | 623 if (base_.CloseOneIdleSocket()) |
625 return true; | 624 return true; |
626 return base_.CloseOneIdleConnectionInLayeredPool(); | 625 return base_.CloseOneIdleConnectionInLayeredPool(); |
627 } | 626 } |
628 | 627 |
629 } // namespace net | 628 } // namespace net |
OLD | NEW |