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