| Index: net/socket/ssl_client_socket_pool.cc
|
| diff --git a/net/socket/ssl_client_socket_pool.cc b/net/socket/ssl_client_socket_pool.cc
|
| index 6643ef4e3af0ac5e00c9c0b27f31b37e278abd1d..342e5ea8825d66b4968eb112cd4381191e51a815 100644
|
| --- a/net/socket/ssl_client_socket_pool.cc
|
| +++ b/net/socket/ssl_client_socket_pool.cc
|
| @@ -9,7 +9,6 @@
|
| #include "base/metrics/field_trial.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/metrics/sparse_histogram.h"
|
| -#include "base/stl_util.h"
|
| #include "base/values.h"
|
| #include "net/base/host_port_pair.h"
|
| #include "net/base/net_errors.h"
|
| @@ -95,77 +94,6 @@ SSLSocketParams::GetHttpProxyConnectionParams() const {
|
| return http_proxy_params_;
|
| }
|
|
|
| -SSLConnectJobMessenger::SocketAndCallback::SocketAndCallback(
|
| - SSLClientSocket* ssl_socket,
|
| - const base::Closure& job_resumption_callback)
|
| - : socket(ssl_socket), callback(job_resumption_callback) {
|
| -}
|
| -
|
| -SSLConnectJobMessenger::SocketAndCallback::~SocketAndCallback() {
|
| -}
|
| -
|
| -SSLConnectJobMessenger::SSLConnectJobMessenger(
|
| - const base::Closure& messenger_finished_callback)
|
| - : messenger_finished_callback_(messenger_finished_callback),
|
| - weak_factory_(this) {
|
| -}
|
| -
|
| -SSLConnectJobMessenger::~SSLConnectJobMessenger() {
|
| -}
|
| -
|
| -void SSLConnectJobMessenger::RemovePendingSocket(SSLClientSocket* ssl_socket) {
|
| - // Sockets do not need to be removed from connecting_sockets_ because
|
| - // OnSSLHandshakeCompleted will do this.
|
| - for (SSLPendingSocketsAndCallbacks::iterator it =
|
| - pending_sockets_and_callbacks_.begin();
|
| - it != pending_sockets_and_callbacks_.end();
|
| - ++it) {
|
| - if (it->socket == ssl_socket) {
|
| - pending_sockets_and_callbacks_.erase(it);
|
| - return;
|
| - }
|
| - }
|
| -}
|
| -
|
| -bool SSLConnectJobMessenger::CanProceed(SSLClientSocket* ssl_socket) {
|
| - // If there are no connecting sockets, allow the connection to proceed.
|
| - return connecting_sockets_.empty();
|
| -}
|
| -
|
| -void SSLConnectJobMessenger::MonitorConnectionResult(
|
| - SSLClientSocket* ssl_socket) {
|
| - connecting_sockets_.push_back(ssl_socket);
|
| - ssl_socket->SetHandshakeCompletionCallback(
|
| - base::Bind(&SSLConnectJobMessenger::OnSSLHandshakeCompleted,
|
| - weak_factory_.GetWeakPtr()));
|
| -}
|
| -
|
| -void SSLConnectJobMessenger::AddPendingSocket(SSLClientSocket* ssl_socket,
|
| - const base::Closure& callback) {
|
| - DCHECK(!connecting_sockets_.empty());
|
| - pending_sockets_and_callbacks_.push_back(
|
| - SocketAndCallback(ssl_socket, callback));
|
| -}
|
| -
|
| -void SSLConnectJobMessenger::OnSSLHandshakeCompleted() {
|
| - connecting_sockets_.clear();
|
| - SSLPendingSocketsAndCallbacks temp_list;
|
| - temp_list.swap(pending_sockets_and_callbacks_);
|
| - base::Closure messenger_finished_callback = messenger_finished_callback_;
|
| - messenger_finished_callback.Run();
|
| - RunAllCallbacks(temp_list);
|
| -}
|
| -
|
| -void SSLConnectJobMessenger::RunAllCallbacks(
|
| - const SSLPendingSocketsAndCallbacks& pending_sockets_and_callbacks) {
|
| - for (std::vector<SocketAndCallback>::const_iterator it =
|
| - pending_sockets_and_callbacks.begin();
|
| - it != pending_sockets_and_callbacks.end();
|
| - ++it) {
|
| - it->callback.Run();
|
| - }
|
| -}
|
| -
|
| // Timeout for the SSL handshake portion of the connect.
|
| static const int kSSLHandshakeTimeoutInSeconds = 30;
|
|
|
| @@ -178,7 +106,6 @@ SSLConnectJob::SSLConnectJob(const std::string& group_name,
|
| HttpProxyClientSocketPool* http_proxy_pool,
|
| ClientSocketFactory* client_socket_factory,
|
| const SSLClientSocketContext& context,
|
| - const GetMessengerCallback& get_messenger_callback,
|
| Delegate* delegate,
|
| NetLog* net_log)
|
| : ConnectJob(group_name,
|
| @@ -199,16 +126,11 @@ SSLConnectJob::SSLConnectJob(const std::string& group_name,
|
| (params->privacy_mode() == PRIVACY_MODE_ENABLED
|
| ? "pm/" + context.ssl_session_cache_shard
|
| : context.ssl_session_cache_shard)),
|
| - io_callback_(
|
| - base::Bind(&SSLConnectJob::OnIOComplete, base::Unretained(this))),
|
| - messenger_(NULL),
|
| - get_messenger_callback_(get_messenger_callback),
|
| - weak_factory_(this) {
|
| + callback_(
|
| + base::Bind(&SSLConnectJob::OnIOComplete, base::Unretained(this))) {
|
| }
|
|
|
| SSLConnectJob::~SSLConnectJob() {
|
| - if (ssl_socket_.get() && messenger_)
|
| - messenger_->RemovePendingSocket(ssl_socket_.get());
|
| }
|
|
|
| LoadState SSLConnectJob::GetLoadState() const {
|
| @@ -223,8 +145,6 @@ LoadState SSLConnectJob::GetLoadState() const {
|
| case STATE_SOCKS_CONNECT_COMPLETE:
|
| case STATE_TUNNEL_CONNECT:
|
| return transport_socket_handle_->GetLoadState();
|
| - case STATE_CREATE_SSL_SOCKET:
|
| - case STATE_CHECK_FOR_RESUME:
|
| case STATE_SSL_CONNECT:
|
| case STATE_SSL_CONNECT_COMPLETE:
|
| return LOAD_STATE_SSL_HANDSHAKE;
|
| @@ -281,12 +201,6 @@ int SSLConnectJob::DoLoop(int result) {
|
| case STATE_TUNNEL_CONNECT_COMPLETE:
|
| rv = DoTunnelConnectComplete(rv);
|
| break;
|
| - case STATE_CREATE_SSL_SOCKET:
|
| - rv = DoCreateSSLSocket();
|
| - break;
|
| - case STATE_CHECK_FOR_RESUME:
|
| - rv = DoCheckForResume();
|
| - break;
|
| case STATE_SSL_CONNECT:
|
| DCHECK_EQ(OK, rv);
|
| rv = DoSSLConnect();
|
| @@ -311,17 +225,13 @@ int SSLConnectJob::DoTransportConnect() {
|
| transport_socket_handle_.reset(new ClientSocketHandle());
|
| scoped_refptr<TransportSocketParams> direct_params =
|
| params_->GetDirectConnectionParams();
|
| - return transport_socket_handle_->Init(group_name(),
|
| - direct_params,
|
| - priority(),
|
| - io_callback_,
|
| - transport_pool_,
|
| - net_log());
|
| + return transport_socket_handle_->Init(group_name(), direct_params, priority(),
|
| + callback_, transport_pool_, net_log());
|
| }
|
|
|
| int SSLConnectJob::DoTransportConnectComplete(int result) {
|
| if (result == OK)
|
| - next_state_ = STATE_CREATE_SSL_SOCKET;
|
| + next_state_ = STATE_SSL_CONNECT;
|
|
|
| return result;
|
| }
|
| @@ -332,17 +242,14 @@ int SSLConnectJob::DoSOCKSConnect() {
|
| transport_socket_handle_.reset(new ClientSocketHandle());
|
| scoped_refptr<SOCKSSocketParams> socks_proxy_params =
|
| params_->GetSocksProxyConnectionParams();
|
| - return transport_socket_handle_->Init(group_name(),
|
| - socks_proxy_params,
|
| - priority(),
|
| - io_callback_,
|
| - socks_pool_,
|
| + return transport_socket_handle_->Init(group_name(), socks_proxy_params,
|
| + priority(), callback_, socks_pool_,
|
| net_log());
|
| }
|
|
|
| int SSLConnectJob::DoSOCKSConnectComplete(int result) {
|
| if (result == OK)
|
| - next_state_ = STATE_CREATE_SSL_SOCKET;
|
| + next_state_ = STATE_SSL_CONNECT;
|
|
|
| return result;
|
| }
|
| @@ -354,11 +261,8 @@ int SSLConnectJob::DoTunnelConnect() {
|
| transport_socket_handle_.reset(new ClientSocketHandle());
|
| scoped_refptr<HttpProxySocketParams> http_proxy_params =
|
| params_->GetHttpProxyConnectionParams();
|
| - return transport_socket_handle_->Init(group_name(),
|
| - http_proxy_params,
|
| - priority(),
|
| - io_callback_,
|
| - http_proxy_pool_,
|
| + return transport_socket_handle_->Init(group_name(), http_proxy_params,
|
| + priority(), callback_, http_proxy_pool_,
|
| net_log());
|
| }
|
|
|
| @@ -376,16 +280,17 @@ int SSLConnectJob::DoTunnelConnectComplete(int result) {
|
| }
|
| if (result < 0)
|
| return result;
|
| - next_state_ = STATE_CREATE_SSL_SOCKET;
|
| +
|
| + next_state_ = STATE_SSL_CONNECT;
|
| return result;
|
| }
|
|
|
| -int SSLConnectJob::DoCreateSSLSocket() {
|
| +int SSLConnectJob::DoSSLConnect() {
|
| // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed.
|
| tracked_objects::ScopedTracker tracking_profile(
|
| - FROM_HERE_WITH_EXPLICIT_FUNCTION(
|
| - "462815 SSLConnectJob::DoCreateSSLSocket"));
|
| - next_state_ = STATE_CHECK_FOR_RESUME;
|
| + FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect"));
|
| +
|
| + next_state_ = STATE_SSL_CONNECT_COMPLETE;
|
|
|
| // Reset the timeout to just the time allowed for the SSL handshake.
|
| ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds));
|
| @@ -404,48 +309,14 @@ int SSLConnectJob::DoCreateSSLSocket() {
|
| connect_timing_.dns_end = socket_connect_timing.dns_end;
|
| }
|
|
|
| + connect_timing_.ssl_start = base::TimeTicks::Now();
|
| +
|
| ssl_socket_ = client_socket_factory_->CreateSSLClientSocket(
|
| transport_socket_handle_.Pass(),
|
| params_->host_and_port(),
|
| params_->ssl_config(),
|
| context_);
|
| -
|
| - if (!ssl_socket_->InSessionCache())
|
| - messenger_ = get_messenger_callback_.Run(ssl_socket_->GetSessionCacheKey());
|
| -
|
| - return OK;
|
| -}
|
| -
|
| -int SSLConnectJob::DoCheckForResume() {
|
| - next_state_ = STATE_SSL_CONNECT;
|
| -
|
| - if (!messenger_)
|
| - return OK;
|
| -
|
| - if (messenger_->CanProceed(ssl_socket_.get())) {
|
| - messenger_->MonitorConnectionResult(ssl_socket_.get());
|
| - // The SSLConnectJob no longer needs access to the messenger after this
|
| - // point.
|
| - messenger_ = NULL;
|
| - return OK;
|
| - }
|
| -
|
| - messenger_->AddPendingSocket(ssl_socket_.get(),
|
| - base::Bind(&SSLConnectJob::ResumeSSLConnection,
|
| - weak_factory_.GetWeakPtr()));
|
| -
|
| - return ERR_IO_PENDING;
|
| -}
|
| -
|
| -int SSLConnectJob::DoSSLConnect() {
|
| - // TODO(pkasting): Remove ScopedTracker below once crbug.com/462813 is fixed.
|
| - tracked_objects::ScopedTracker tracking_profile(
|
| - FROM_HERE_WITH_EXPLICIT_FUNCTION("462813 SSLConnectJob::DoSSLConnect"));
|
| - next_state_ = STATE_SSL_CONNECT_COMPLETE;
|
| -
|
| - connect_timing_.ssl_start = base::TimeTicks::Now();
|
| -
|
| - return ssl_socket_->Connect(io_callback_);
|
| + return ssl_socket_->Connect(callback_);
|
| }
|
|
|
| int SSLConnectJob::DoSSLConnectComplete(int result) {
|
| @@ -578,12 +449,6 @@ int SSLConnectJob::DoSSLConnectComplete(int result) {
|
| return result;
|
| }
|
|
|
| -void SSLConnectJob::ResumeSSLConnection() {
|
| - DCHECK_EQ(next_state_, STATE_SSL_CONNECT);
|
| - messenger_ = NULL;
|
| - OnIOComplete(OK);
|
| -}
|
| -
|
| SSLConnectJob::State SSLConnectJob::GetInitialState(
|
| SSLSocketParams::ConnectionType connection_type) {
|
| switch (connection_type) {
|
| @@ -609,14 +474,12 @@ SSLClientSocketPool::SSLConnectJobFactory::SSLConnectJobFactory(
|
| HttpProxyClientSocketPool* http_proxy_pool,
|
| ClientSocketFactory* client_socket_factory,
|
| const SSLClientSocketContext& context,
|
| - const SSLConnectJob::GetMessengerCallback& get_messenger_callback,
|
| NetLog* net_log)
|
| : transport_pool_(transport_pool),
|
| socks_pool_(socks_pool),
|
| http_proxy_pool_(http_proxy_pool),
|
| client_socket_factory_(client_socket_factory),
|
| context_(context),
|
| - get_messenger_callback_(get_messenger_callback),
|
| net_log_(net_log) {
|
| base::TimeDelta max_transport_timeout = base::TimeDelta();
|
| base::TimeDelta pool_timeout;
|
| @@ -654,7 +517,6 @@ SSLClientSocketPool::SSLClientSocketPool(
|
| SOCKSClientSocketPool* socks_pool,
|
| HttpProxyClientSocketPool* http_proxy_pool,
|
| SSLConfigService* ssl_config_service,
|
| - bool enable_ssl_connect_job_waiting,
|
| NetLog* net_log)
|
| : transport_pool_(transport_pool),
|
| socks_pool_(socks_pool),
|
| @@ -676,12 +538,8 @@ SSLClientSocketPool::SSLClientSocketPool(
|
| cert_transparency_verifier,
|
| cert_policy_enforcer,
|
| ssl_session_cache_shard),
|
| - base::Bind(
|
| - &SSLClientSocketPool::GetOrCreateSSLConnectJobMessenger,
|
| - base::Unretained(this)),
|
| net_log)),
|
| - ssl_config_service_(ssl_config_service),
|
| - enable_ssl_connect_job_waiting_(enable_ssl_connect_job_waiting) {
|
| + ssl_config_service_(ssl_config_service) {
|
| if (ssl_config_service_.get())
|
| ssl_config_service_->AddObserver(this);
|
| if (transport_pool_)
|
| @@ -693,8 +551,6 @@ SSLClientSocketPool::SSLClientSocketPool(
|
| }
|
|
|
| SSLClientSocketPool::~SSLClientSocketPool() {
|
| - STLDeleteContainerPairSecondPointers(messenger_map_.begin(),
|
| - messenger_map_.end());
|
| if (ssl_config_service_.get())
|
| ssl_config_service_->RemoveObserver(this);
|
| }
|
| @@ -712,7 +568,6 @@ scoped_ptr<ConnectJob> SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob(
|
| http_proxy_pool_,
|
| client_socket_factory_,
|
| context_,
|
| - get_messenger_callback_,
|
| delegate,
|
| net_log_));
|
| }
|
| @@ -833,32 +688,6 @@ bool SSLClientSocketPool::CloseOneIdleConnection() {
|
| return base_.CloseOneIdleConnectionInHigherLayeredPool();
|
| }
|
|
|
| -SSLConnectJobMessenger* SSLClientSocketPool::GetOrCreateSSLConnectJobMessenger(
|
| - const std::string& cache_key) {
|
| - if (!enable_ssl_connect_job_waiting_)
|
| - return NULL;
|
| - MessengerMap::const_iterator it = messenger_map_.find(cache_key);
|
| - if (it == messenger_map_.end()) {
|
| - std::pair<MessengerMap::iterator, bool> iter =
|
| - messenger_map_.insert(MessengerMap::value_type(
|
| - cache_key,
|
| - new SSLConnectJobMessenger(
|
| - base::Bind(&SSLClientSocketPool::DeleteSSLConnectJobMessenger,
|
| - base::Unretained(this),
|
| - cache_key))));
|
| - it = iter.first;
|
| - }
|
| - return it->second;
|
| -}
|
| -
|
| -void SSLClientSocketPool::DeleteSSLConnectJobMessenger(
|
| - const std::string& cache_key) {
|
| - MessengerMap::iterator it = messenger_map_.find(cache_key);
|
| - CHECK(it != messenger_map_.end());
|
| - delete it->second;
|
| - messenger_map_.erase(it);
|
| -}
|
| -
|
| void SSLClientSocketPool::OnSSLConfigChanged() {
|
| FlushWithError(ERR_NETWORK_CHANGED);
|
| }
|
|
|