blob: 388e3fe97a0ef3217dbd0369f4c4a11f1c404295 [file] [log] [blame]
[email protected]e34400c32012-01-24 02:49:331// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]e60e47a2010-07-14 03:37:182// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "net/socket/ssl_client_socket_pool.h"
6
[email protected]6ecf2b92011-12-15 01:14:527#include "base/bind.h"
8#include "base/bind_helpers.h"
[email protected]c63248d42011-02-18 17:54:399#include "base/metrics/field_trial.h"
[email protected]835d7c82010-10-14 04:38:3810#include "base/metrics/histogram.h"
[email protected]92a31242013-06-28 18:08:0811#include "base/metrics/sparse_histogram.h"
[email protected]8e458552014-08-05 00:02:1512#include "base/stl_util.h"
[email protected]ba00b492010-09-08 14:53:3813#include "base/values.h"
[email protected]4f4de7e62010-11-12 19:55:2714#include "net/base/host_port_pair.h"
[email protected]536fd0b2013-03-14 17:41:5715#include "net/base/net_errors.h"
[email protected]33b511c2010-08-11 00:04:4316#include "net/http/http_proxy_client_socket.h"
17#include "net/http/http_proxy_client_socket_pool.h"
[email protected]e60e47a2010-07-14 03:37:1818#include "net/socket/client_socket_factory.h"
19#include "net/socket/client_socket_handle.h"
[email protected]33b511c2010-08-11 00:04:4320#include "net/socket/socks_client_socket_pool.h"
21#include "net/socket/ssl_client_socket.h"
[email protected]ab739042011-04-07 15:22:2822#include "net/socket/transport_client_socket_pool.h"
[email protected]536fd0b2013-03-14 17:41:5723#include "net/ssl/ssl_cert_request_info.h"
[email protected]92a31242013-06-28 18:08:0824#include "net/ssl/ssl_connection_status_flags.h"
25#include "net/ssl/ssl_info.h"
[email protected]e60e47a2010-07-14 03:37:1826
27namespace net {
28
29SSLSocketParams::SSLSocketParams(
[email protected]ea79ba92013-08-15 21:56:2030 const scoped_refptr<TransportSocketParams>& direct_params,
31 const scoped_refptr<SOCKSSocketParams>& socks_proxy_params,
[email protected]2431756e2010-09-29 20:26:1332 const scoped_refptr<HttpProxySocketParams>& http_proxy_params,
[email protected]4f4de7e62010-11-12 19:55:2733 const HostPortPair& host_and_port,
[email protected]e60e47a2010-07-14 03:37:1834 const SSLConfig& ssl_config,
[email protected]5e5021a2013-07-17 05:23:3635 PrivacyMode privacy_mode,
[email protected]e60e47a2010-07-14 03:37:1836 int load_flags,
[email protected]9e9e842e2010-07-23 23:09:1537 bool force_spdy_over_ssl,
38 bool want_spdy_over_npn)
[email protected]ea79ba92013-08-15 21:56:2039 : direct_params_(direct_params),
40 socks_proxy_params_(socks_proxy_params),
[email protected]e60e47a2010-07-14 03:37:1841 http_proxy_params_(http_proxy_params),
[email protected]4f4de7e62010-11-12 19:55:2742 host_and_port_(host_and_port),
[email protected]e60e47a2010-07-14 03:37:1843 ssl_config_(ssl_config),
[email protected]5e5021a2013-07-17 05:23:3644 privacy_mode_(privacy_mode),
[email protected]e60e47a2010-07-14 03:37:1845 load_flags_(load_flags),
[email protected]9e9e842e2010-07-23 23:09:1546 force_spdy_over_ssl_(force_spdy_over_ssl),
[email protected]0e14e87d2011-06-21 21:24:1947 want_spdy_over_npn_(want_spdy_over_npn),
48 ignore_limits_(false) {
dcheng707f8602014-09-04 00:13:5249 if (direct_params_.get()) {
50 DCHECK(!socks_proxy_params_.get());
51 DCHECK(!http_proxy_params_.get());
[email protected]ea79ba92013-08-15 21:56:2052 ignore_limits_ = direct_params_->ignore_limits();
dcheng707f8602014-09-04 00:13:5253 } else if (socks_proxy_params_.get()) {
54 DCHECK(!http_proxy_params_.get());
[email protected]ea79ba92013-08-15 21:56:2055 ignore_limits_ = socks_proxy_params_->ignore_limits();
56 } else {
dcheng707f8602014-09-04 00:13:5257 DCHECK(http_proxy_params_.get());
[email protected]ea79ba92013-08-15 21:56:2058 ignore_limits_ = http_proxy_params_->ignore_limits();
[email protected]e60e47a2010-07-14 03:37:1859 }
60}
61
62SSLSocketParams::~SSLSocketParams() {}
63
[email protected]ea79ba92013-08-15 21:56:2064SSLSocketParams::ConnectionType SSLSocketParams::GetConnectionType() const {
dcheng707f8602014-09-04 00:13:5265 if (direct_params_.get()) {
66 DCHECK(!socks_proxy_params_.get());
67 DCHECK(!http_proxy_params_.get());
[email protected]ea79ba92013-08-15 21:56:2068 return DIRECT;
69 }
70
dcheng707f8602014-09-04 00:13:5271 if (socks_proxy_params_.get()) {
72 DCHECK(!http_proxy_params_.get());
[email protected]ea79ba92013-08-15 21:56:2073 return SOCKS_PROXY;
74 }
75
dcheng707f8602014-09-04 00:13:5276 DCHECK(http_proxy_params_.get());
[email protected]ea79ba92013-08-15 21:56:2077 return HTTP_PROXY;
78}
79
80const scoped_refptr<TransportSocketParams>&
81SSLSocketParams::GetDirectConnectionParams() const {
82 DCHECK_EQ(GetConnectionType(), DIRECT);
83 return direct_params_;
84}
85
86const scoped_refptr<SOCKSSocketParams>&
87SSLSocketParams::GetSocksProxyConnectionParams() const {
88 DCHECK_EQ(GetConnectionType(), SOCKS_PROXY);
89 return socks_proxy_params_;
90}
91
92const scoped_refptr<HttpProxySocketParams>&
93SSLSocketParams::GetHttpProxyConnectionParams() const {
94 DCHECK_EQ(GetConnectionType(), HTTP_PROXY);
95 return http_proxy_params_;
96}
97
[email protected]8e458552014-08-05 00:02:1598SSLConnectJobMessenger::SocketAndCallback::SocketAndCallback(
99 SSLClientSocket* ssl_socket,
100 const base::Closure& job_resumption_callback)
101 : socket(ssl_socket), callback(job_resumption_callback) {
102}
103
104SSLConnectJobMessenger::SocketAndCallback::~SocketAndCallback() {
105}
106
[email protected]cffd7f92014-08-21 21:30:50107SSLConnectJobMessenger::SSLConnectJobMessenger(
108 const base::Closure& messenger_finished_callback)
109 : messenger_finished_callback_(messenger_finished_callback),
110 weak_factory_(this) {
[email protected]8e458552014-08-05 00:02:15111}
112
113SSLConnectJobMessenger::~SSLConnectJobMessenger() {
114}
115
116void SSLConnectJobMessenger::RemovePendingSocket(SSLClientSocket* ssl_socket) {
117 // Sockets do not need to be removed from connecting_sockets_ because
118 // OnSSLHandshakeCompleted will do this.
119 for (SSLPendingSocketsAndCallbacks::iterator it =
120 pending_sockets_and_callbacks_.begin();
121 it != pending_sockets_and_callbacks_.end();
122 ++it) {
123 if (it->socket == ssl_socket) {
124 pending_sockets_and_callbacks_.erase(it);
125 return;
126 }
127 }
128}
129
130bool SSLConnectJobMessenger::CanProceed(SSLClientSocket* ssl_socket) {
[email protected]cffd7f92014-08-21 21:30:50131 // If there are no connecting sockets, allow the connection to proceed.
132 return connecting_sockets_.empty();
[email protected]8e458552014-08-05 00:02:15133}
134
135void SSLConnectJobMessenger::MonitorConnectionResult(
136 SSLClientSocket* ssl_socket) {
137 connecting_sockets_.push_back(ssl_socket);
138 ssl_socket->SetHandshakeCompletionCallback(
139 base::Bind(&SSLConnectJobMessenger::OnSSLHandshakeCompleted,
140 weak_factory_.GetWeakPtr()));
141}
142
143void SSLConnectJobMessenger::AddPendingSocket(SSLClientSocket* ssl_socket,
144 const base::Closure& callback) {
145 DCHECK(!connecting_sockets_.empty());
146 pending_sockets_and_callbacks_.push_back(
147 SocketAndCallback(ssl_socket, callback));
148}
149
150void SSLConnectJobMessenger::OnSSLHandshakeCompleted() {
151 connecting_sockets_.clear();
152 SSLPendingSocketsAndCallbacks temp_list;
153 temp_list.swap(pending_sockets_and_callbacks_);
[email protected]cffd7f92014-08-21 21:30:50154 base::Closure messenger_finished_callback = messenger_finished_callback_;
155 messenger_finished_callback.Run();
[email protected]8e458552014-08-05 00:02:15156 RunAllCallbacks(temp_list);
157}
158
159void SSLConnectJobMessenger::RunAllCallbacks(
160 const SSLPendingSocketsAndCallbacks& pending_sockets_and_callbacks) {
161 for (std::vector<SocketAndCallback>::const_iterator it =
162 pending_sockets_and_callbacks.begin();
163 it != pending_sockets_and_callbacks.end();
164 ++it) {
165 it->callback.Run();
166 }
167}
168
[email protected]e60e47a2010-07-14 03:37:18169// Timeout for the SSL handshake portion of the connect.
170static const int kSSLHandshakeTimeoutInSeconds = 30;
171
[email protected]feb79bcd2011-07-21 16:55:17172SSLConnectJob::SSLConnectJob(const std::string& group_name,
[email protected]3f6007ab2013-08-22 19:45:39173 RequestPriority priority,
[email protected]feb79bcd2011-07-21 16:55:17174 const scoped_refptr<SSLSocketParams>& params,
175 const base::TimeDelta& timeout_duration,
176 TransportClientSocketPool* transport_pool,
177 SOCKSClientSocketPool* socks_pool,
178 HttpProxyClientSocketPool* http_proxy_pool,
179 ClientSocketFactory* client_socket_factory,
180 HostResolver* host_resolver,
181 const SSLClientSocketContext& context,
[email protected]cffd7f92014-08-21 21:30:50182 const GetMessengerCallback& get_messenger_callback,
[email protected]feb79bcd2011-07-21 16:55:17183 Delegate* delegate,
184 NetLog* net_log)
[email protected]5e5021a2013-07-17 05:23:36185 : ConnectJob(group_name,
186 timeout_duration,
[email protected]3f6007ab2013-08-22 19:45:39187 priority,
[email protected]5e5021a2013-07-17 05:23:36188 delegate,
[email protected]e60e47a2010-07-14 03:37:18189 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
190 params_(params),
[email protected]ab739042011-04-07 15:22:28191 transport_pool_(transport_pool),
[email protected]e60e47a2010-07-14 03:37:18192 socks_pool_(socks_pool),
[email protected]2431756e2010-09-29 20:26:13193 http_proxy_pool_(http_proxy_pool),
[email protected]e60e47a2010-07-14 03:37:18194 client_socket_factory_(client_socket_factory),
[email protected]822581d2010-12-16 17:27:15195 host_resolver_(host_resolver),
[email protected]5e5021a2013-07-17 05:23:36196 context_(context.cert_verifier,
[email protected]6b8a3c742014-07-25 00:25:35197 context.channel_id_service,
[email protected]5e5021a2013-07-17 05:23:36198 context.transport_security_state,
[email protected]284303b62013-11-28 15:11:54199 context.cert_transparency_verifier,
[email protected]314b03992014-04-01 01:28:53200 (params->privacy_mode() == PRIVACY_MODE_ENABLED
[email protected]5e5021a2013-07-17 05:23:36201 ? "pm/" + context.ssl_session_cache_shard
202 : context.ssl_session_cache_shard)),
[email protected]8e458552014-08-05 00:02:15203 io_callback_(
204 base::Bind(&SSLConnectJob::OnIOComplete, base::Unretained(this))),
[email protected]cffd7f92014-08-21 21:30:50205 messenger_(NULL),
206 get_messenger_callback_(get_messenger_callback),
[email protected]8e458552014-08-05 00:02:15207 weak_factory_(this) {
208}
[email protected]e60e47a2010-07-14 03:37:18209
[email protected]8e458552014-08-05 00:02:15210SSLConnectJob::~SSLConnectJob() {
211 if (ssl_socket_.get() && messenger_)
212 messenger_->RemovePendingSocket(ssl_socket_.get());
213}
[email protected]e60e47a2010-07-14 03:37:18214
215LoadState SSLConnectJob::GetLoadState() const {
216 switch (next_state_) {
[email protected]135e2262010-07-17 00:32:04217 case STATE_TUNNEL_CONNECT_COMPLETE:
218 if (transport_socket_handle_->socket())
219 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL;
220 // else, fall through.
[email protected]ab739042011-04-07 15:22:28221 case STATE_TRANSPORT_CONNECT:
222 case STATE_TRANSPORT_CONNECT_COMPLETE:
[email protected]e60e47a2010-07-14 03:37:18223 case STATE_SOCKS_CONNECT:
224 case STATE_SOCKS_CONNECT_COMPLETE:
225 case STATE_TUNNEL_CONNECT:
[email protected]e60e47a2010-07-14 03:37:18226 return transport_socket_handle_->GetLoadState();
[email protected]8e458552014-08-05 00:02:15227 case STATE_CREATE_SSL_SOCKET:
228 case STATE_CHECK_FOR_RESUME:
[email protected]e60e47a2010-07-14 03:37:18229 case STATE_SSL_CONNECT:
230 case STATE_SSL_CONNECT_COMPLETE:
231 return LOAD_STATE_SSL_HANDSHAKE;
232 default:
233 NOTREACHED();
234 return LOAD_STATE_IDLE;
235 }
236}
237
[email protected]83039bb2011-12-09 18:43:55238void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) {
[email protected]ad74a592011-01-21 18:40:55239 // Headers in |error_response_info_| indicate a proxy tunnel setup
240 // problem. See DoTunnelConnectComplete.
[email protected]90499482013-06-01 00:39:50241 if (error_response_info_.headers.get()) {
[email protected]ad74a592011-01-21 18:40:55242 handle->set_pending_http_proxy_connection(
243 transport_socket_handle_.release());
[email protected]e60e47a2010-07-14 03:37:18244 }
[email protected]ad74a592011-01-21 18:40:55245 handle->set_ssl_error_response_info(error_response_info_);
[email protected]034df0f32013-01-07 23:17:48246 if (!connect_timing_.ssl_start.is_null())
[email protected]ad74a592011-01-21 18:40:55247 handle->set_is_ssl_error(true);
[email protected]e60e47a2010-07-14 03:37:18248}
249
250void SSLConnectJob::OnIOComplete(int result) {
251 int rv = DoLoop(result);
252 if (rv != ERR_IO_PENDING)
253 NotifyDelegateOfCompletion(rv); // Deletes |this|.
254}
255
256int SSLConnectJob::DoLoop(int result) {
257 DCHECK_NE(next_state_, STATE_NONE);
258
259 int rv = result;
260 do {
261 State state = next_state_;
262 next_state_ = STATE_NONE;
263 switch (state) {
[email protected]ab739042011-04-07 15:22:28264 case STATE_TRANSPORT_CONNECT:
[email protected]e60e47a2010-07-14 03:37:18265 DCHECK_EQ(OK, rv);
[email protected]ab739042011-04-07 15:22:28266 rv = DoTransportConnect();
[email protected]e60e47a2010-07-14 03:37:18267 break;
[email protected]ab739042011-04-07 15:22:28268 case STATE_TRANSPORT_CONNECT_COMPLETE:
269 rv = DoTransportConnectComplete(rv);
[email protected]e60e47a2010-07-14 03:37:18270 break;
271 case STATE_SOCKS_CONNECT:
272 DCHECK_EQ(OK, rv);
273 rv = DoSOCKSConnect();
274 break;
275 case STATE_SOCKS_CONNECT_COMPLETE:
276 rv = DoSOCKSConnectComplete(rv);
277 break;
278 case STATE_TUNNEL_CONNECT:
279 DCHECK_EQ(OK, rv);
280 rv = DoTunnelConnect();
281 break;
282 case STATE_TUNNEL_CONNECT_COMPLETE:
283 rv = DoTunnelConnectComplete(rv);
284 break;
[email protected]8e458552014-08-05 00:02:15285 case STATE_CREATE_SSL_SOCKET:
286 rv = DoCreateSSLSocket();
287 break;
288 case STATE_CHECK_FOR_RESUME:
289 rv = DoCheckForResume();
290 break;
[email protected]e60e47a2010-07-14 03:37:18291 case STATE_SSL_CONNECT:
292 DCHECK_EQ(OK, rv);
293 rv = DoSSLConnect();
294 break;
295 case STATE_SSL_CONNECT_COMPLETE:
296 rv = DoSSLConnectComplete(rv);
297 break;
298 default:
299 NOTREACHED() << "bad state";
300 rv = ERR_FAILED;
301 break;
302 }
303 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
304
305 return rv;
306}
307
[email protected]ab739042011-04-07 15:22:28308int SSLConnectJob::DoTransportConnect() {
309 DCHECK(transport_pool_);
[email protected]899c3e92010-08-28 15:53:50310
[email protected]ab739042011-04-07 15:22:28311 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE;
[email protected]e60e47a2010-07-14 03:37:18312 transport_socket_handle_.reset(new ClientSocketHandle());
[email protected]ea79ba92013-08-15 21:56:20313 scoped_refptr<TransportSocketParams> direct_params =
314 params_->GetDirectConnectionParams();
[email protected]5109c1952013-08-20 18:44:10315 return transport_socket_handle_->Init(group_name(),
316 direct_params,
[email protected]3f6007ab2013-08-22 19:45:39317 priority(),
[email protected]8e458552014-08-05 00:02:15318 io_callback_,
[email protected]5109c1952013-08-20 18:44:10319 transport_pool_,
320 net_log());
[email protected]e60e47a2010-07-14 03:37:18321}
322
[email protected]ab739042011-04-07 15:22:28323int SSLConnectJob::DoTransportConnectComplete(int result) {
[email protected]e60e47a2010-07-14 03:37:18324 if (result == OK)
[email protected]8e458552014-08-05 00:02:15325 next_state_ = STATE_CREATE_SSL_SOCKET;
[email protected]e60e47a2010-07-14 03:37:18326
327 return result;
328}
329
330int SSLConnectJob::DoSOCKSConnect() {
[email protected]2431756e2010-09-29 20:26:13331 DCHECK(socks_pool_);
[email protected]e60e47a2010-07-14 03:37:18332 next_state_ = STATE_SOCKS_CONNECT_COMPLETE;
333 transport_socket_handle_.reset(new ClientSocketHandle());
[email protected]ea79ba92013-08-15 21:56:20334 scoped_refptr<SOCKSSocketParams> socks_proxy_params =
335 params_->GetSocksProxyConnectionParams();
[email protected]5109c1952013-08-20 18:44:10336 return transport_socket_handle_->Init(group_name(),
337 socks_proxy_params,
[email protected]3f6007ab2013-08-22 19:45:39338 priority(),
[email protected]8e458552014-08-05 00:02:15339 io_callback_,
[email protected]5109c1952013-08-20 18:44:10340 socks_pool_,
341 net_log());
[email protected]e60e47a2010-07-14 03:37:18342}
343
344int SSLConnectJob::DoSOCKSConnectComplete(int result) {
345 if (result == OK)
[email protected]8e458552014-08-05 00:02:15346 next_state_ = STATE_CREATE_SSL_SOCKET;
[email protected]e60e47a2010-07-14 03:37:18347
348 return result;
349}
350
351int SSLConnectJob::DoTunnelConnect() {
[email protected]2431756e2010-09-29 20:26:13352 DCHECK(http_proxy_pool_);
[email protected]e60e47a2010-07-14 03:37:18353 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE;
[email protected]394816e92010-08-03 07:38:59354
[email protected]e60e47a2010-07-14 03:37:18355 transport_socket_handle_.reset(new ClientSocketHandle());
356 scoped_refptr<HttpProxySocketParams> http_proxy_params =
[email protected]ea79ba92013-08-15 21:56:20357 params_->GetHttpProxyConnectionParams();
[email protected]5109c1952013-08-20 18:44:10358 return transport_socket_handle_->Init(group_name(),
359 http_proxy_params,
[email protected]3f6007ab2013-08-22 19:45:39360 priority(),
[email protected]8e458552014-08-05 00:02:15361 io_callback_,
[email protected]5109c1952013-08-20 18:44:10362 http_proxy_pool_,
363 net_log());
[email protected]e60e47a2010-07-14 03:37:18364}
365
366int SSLConnectJob::DoTunnelConnectComplete(int result) {
[email protected]4f4de7e62010-11-12 19:55:27367 // Extract the information needed to prompt for appropriate proxy
368 // authentication so that when ClientSocketPoolBaseHelper calls
369 // |GetAdditionalErrorState|, we can easily set the state.
370 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
371 error_response_info_ = transport_socket_handle_->ssl_error_response_info();
[email protected]511f6f52010-12-17 03:58:29372 } else if (result == ERR_PROXY_AUTH_REQUESTED ||
373 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
[email protected]3268023f2011-05-05 00:08:10374 StreamSocket* socket = transport_socket_handle_->socket();
[email protected]fe3b7dc2012-02-03 19:52:09375 HttpProxyClientSocket* tunnel_socket =
376 static_cast<HttpProxyClientSocket*>(socket);
[email protected]511f6f52010-12-17 03:58:29377 error_response_info_ = *tunnel_socket->GetConnectResponseInfo();
[email protected]4f4de7e62010-11-12 19:55:27378 }
[email protected]e60e47a2010-07-14 03:37:18379 if (result < 0)
380 return result;
[email protected]8e458552014-08-05 00:02:15381 next_state_ = STATE_CREATE_SSL_SOCKET;
[email protected]e60e47a2010-07-14 03:37:18382 return result;
383}
384
[email protected]8e458552014-08-05 00:02:15385int SSLConnectJob::DoCreateSSLSocket() {
386 next_state_ = STATE_CHECK_FOR_RESUME;
387
[email protected]e60e47a2010-07-14 03:37:18388 // Reset the timeout to just the time allowed for the SSL handshake.
389 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds));
[email protected]034df0f32013-01-07 23:17:48390
391 // If the handle has a fresh socket, get its connect start and DNS times.
392 // This should always be the case.
393 const LoadTimingInfo::ConnectTiming& socket_connect_timing =
394 transport_socket_handle_->connect_timing();
395 if (!transport_socket_handle_->is_reused() &&
396 !socket_connect_timing.connect_start.is_null()) {
397 // Overwriting |connect_start| serves two purposes - it adjusts timing so
398 // |connect_start| doesn't include dns times, and it adjusts the time so
399 // as not to include time spent waiting for an idle socket.
400 connect_timing_.connect_start = socket_connect_timing.connect_start;
401 connect_timing_.dns_start = socket_connect_timing.dns_start;
402 connect_timing_.dns_end = socket_connect_timing.dns_end;
403 }
404
[email protected]18ccfdb2013-08-15 00:13:44405 ssl_socket_ = client_socket_factory_->CreateSSLClientSocket(
406 transport_socket_handle_.Pass(),
[email protected]5e5021a2013-07-17 05:23:36407 params_->host_and_port(),
408 params_->ssl_config(),
[email protected]18ccfdb2013-08-15 00:13:44409 context_);
[email protected]cffd7f92014-08-21 21:30:50410
411 if (!ssl_socket_->InSessionCache())
412 messenger_ = get_messenger_callback_.Run(ssl_socket_->GetSessionCacheKey());
413
[email protected]8e458552014-08-05 00:02:15414 return OK;
415}
416
417int SSLConnectJob::DoCheckForResume() {
418 next_state_ = STATE_SSL_CONNECT;
[email protected]cffd7f92014-08-21 21:30:50419
[email protected]8e458552014-08-05 00:02:15420 if (!messenger_)
421 return OK;
422
[email protected]8e458552014-08-05 00:02:15423 if (messenger_->CanProceed(ssl_socket_.get())) {
[email protected]cffd7f92014-08-21 21:30:50424 messenger_->MonitorConnectionResult(ssl_socket_.get());
425 // The SSLConnectJob no longer needs access to the messenger after this
426 // point.
427 messenger_ = NULL;
[email protected]8e458552014-08-05 00:02:15428 return OK;
429 }
[email protected]cffd7f92014-08-21 21:30:50430
[email protected]8e458552014-08-05 00:02:15431 messenger_->AddPendingSocket(ssl_socket_.get(),
432 base::Bind(&SSLConnectJob::ResumeSSLConnection,
433 weak_factory_.GetWeakPtr()));
[email protected]cffd7f92014-08-21 21:30:50434
[email protected]8e458552014-08-05 00:02:15435 return ERR_IO_PENDING;
436}
437
438int SSLConnectJob::DoSSLConnect() {
439 next_state_ = STATE_SSL_CONNECT_COMPLETE;
440
441 connect_timing_.ssl_start = base::TimeTicks::Now();
442
443 return ssl_socket_->Connect(io_callback_);
[email protected]e60e47a2010-07-14 03:37:18444}
445
446int SSLConnectJob::DoSSLConnectComplete(int result) {
[email protected]034df0f32013-01-07 23:17:48447 connect_timing_.ssl_end = base::TimeTicks::Now();
448
[email protected]e60e47a2010-07-14 03:37:18449 SSLClientSocket::NextProtoStatus status =
450 SSLClientSocket::kNextProtoUnsupported;
451 std::string proto;
452 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket
453 // that hasn't had SSL_ImportFD called on it. If we get a certificate error
454 // here, then we know that we called SSL_ImportFD.
455 if (result == OK || IsCertificateError(result))
[email protected]abc44b752014-07-30 03:52:15456 status = ssl_socket_->GetNextProto(&proto);
[email protected]e60e47a2010-07-14 03:37:18457
[email protected]9e9e842e2010-07-23 23:09:15458 // If we want spdy over npn, make sure it succeeded.
[email protected]e60e47a2010-07-14 03:37:18459 if (status == SSLClientSocket::kNextProtoNegotiated) {
[email protected]d7c9f422010-08-27 22:54:53460 ssl_socket_->set_was_npn_negotiated(true);
[email protected]8e3c78cb2012-03-31 03:58:46461 NextProto protocol_negotiated =
[email protected]bace48c2010-08-03 20:52:02462 SSLClientSocket::NextProtoFromString(proto);
[email protected]c30bcce2011-12-20 17:50:51463 ssl_socket_->set_protocol_negotiated(protocol_negotiated);
[email protected]63bf9662013-03-05 20:46:01464 // If we negotiated a SPDY version, it must have been present in
465 // SSLConfig::next_protos.
466 // TODO(mbelshe): Verify this.
467 if (protocol_negotiated >= kProtoSPDYMinimumVersion &&
468 protocol_negotiated <= kProtoSPDYMaximumVersion) {
[email protected]d7c9f422010-08-27 22:54:53469 ssl_socket_->set_was_spdy_negotiated(true);
[email protected]e60e47a2010-07-14 03:37:18470 }
471 }
[email protected]d7c9f422010-08-27 22:54:53472 if (params_->want_spdy_over_npn() && !ssl_socket_->was_spdy_negotiated())
[email protected]e60e47a2010-07-14 03:37:18473 return ERR_NPN_NEGOTIATION_FAILED;
474
[email protected]9e9e842e2010-07-23 23:09:15475 // Spdy might be turned on by default, or it might be over npn.
476 bool using_spdy = params_->force_spdy_over_ssl() ||
477 params_->want_spdy_over_npn();
478
[email protected]e60e47a2010-07-14 03:37:18479 if (result == OK ||
480 ssl_socket_->IgnoreCertError(result, params_->load_flags())) {
[email protected]034df0f32013-01-07 23:17:48481 DCHECK(!connect_timing_.ssl_start.is_null());
[email protected]e60e47a2010-07-14 03:37:18482 base::TimeDelta connect_duration =
[email protected]034df0f32013-01-07 23:17:48483 connect_timing_.ssl_end - connect_timing_.ssl_start;
[email protected]835d7c82010-10-14 04:38:38484 if (using_spdy) {
[email protected]847276962013-03-08 23:53:17485 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SpdyConnectionLatency_2",
[email protected]e60e47a2010-07-14 03:37:18486 connect_duration,
487 base::TimeDelta::FromMilliseconds(1),
[email protected]847276962013-03-08 23:53:17488 base::TimeDelta::FromMinutes(1),
[email protected]e60e47a2010-07-14 03:37:18489 100);
[email protected]f906bfe2011-06-09 16:35:24490 }
[email protected]17ed3b82013-07-12 19:21:26491#if defined(SPDY_PROXY_AUTH_ORIGIN)
492 bool using_data_reduction_proxy = params_->host_and_port().Equals(
493 HostPortPair::FromURL(GURL(SPDY_PROXY_AUTH_ORIGIN)));
494 if (using_data_reduction_proxy) {
495 UMA_HISTOGRAM_CUSTOM_TIMES(
496 "Net.SSL_Connection_Latency_DataReductionProxy",
497 connect_duration,
498 base::TimeDelta::FromMilliseconds(1),
499 base::TimeDelta::FromMinutes(1),
500 100);
501 }
502#endif
[email protected]f906bfe2011-06-09 16:35:24503
[email protected]847276962013-03-08 23:53:17504 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_2",
[email protected]f906bfe2011-06-09 16:35:24505 connect_duration,
506 base::TimeDelta::FromMilliseconds(1),
[email protected]847276962013-03-08 23:53:17507 base::TimeDelta::FromMinutes(1),
[email protected]f906bfe2011-06-09 16:35:24508 100);
509
[email protected]b076d6c2011-06-29 14:47:51510 SSLInfo ssl_info;
511 ssl_socket_->GetSSLInfo(&ssl_info);
512
[email protected]92a31242013-06-28 18:08:08513 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_CipherSuite",
514 SSLConnectionStatusToCipherSuite(
515 ssl_info.connection_status));
516
davidben09c3d072014-08-25 20:33:58517 UMA_HISTOGRAM_BOOLEAN(
518 "Net.RenegotiationExtensionSupported",
519 (ssl_info.connection_status &
520 SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) == 0);
521
[email protected]b076d6c2011-06-29 14:47:51522 if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_RESUME) {
523 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Resume_Handshake",
524 connect_duration,
525 base::TimeDelta::FromMilliseconds(1),
526 base::TimeDelta::FromMinutes(1),
527 100);
528 } else if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_FULL) {
529 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Full_Handshake",
530 connect_duration,
531 base::TimeDelta::FromMilliseconds(1),
532 base::TimeDelta::FromMinutes(1),
533 100);
534 }
535
[email protected]f906bfe2011-06-09 16:35:24536 const std::string& host = params_->host_and_port().host();
[email protected]8e458552014-08-05 00:02:15537 bool is_google =
538 host == "google.com" ||
539 (host.size() > 11 && host.rfind(".google.com") == host.size() - 11);
[email protected]f906bfe2011-06-09 16:35:24540 if (is_google) {
[email protected]847276962013-03-08 23:53:17541 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google2",
[email protected]e60e47a2010-07-14 03:37:18542 connect_duration,
543 base::TimeDelta::FromMilliseconds(1),
[email protected]847276962013-03-08 23:53:17544 base::TimeDelta::FromMinutes(1),
[email protected]e60e47a2010-07-14 03:37:18545 100);
[email protected]b076d6c2011-06-29 14:47:51546 if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_RESUME) {
547 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google_"
548 "Resume_Handshake",
549 connect_duration,
550 base::TimeDelta::FromMilliseconds(1),
551 base::TimeDelta::FromMinutes(1),
552 100);
553 } else if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_FULL) {
554 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google_"
555 "Full_Handshake",
556 connect_duration,
557 base::TimeDelta::FromMilliseconds(1),
558 base::TimeDelta::FromMinutes(1),
559 100);
560 }
[email protected]835d7c82010-10-14 04:38:38561 }
[email protected]e60e47a2010-07-14 03:37:18562 }
[email protected]8b498692010-07-16 17:11:43563
564 if (result == OK || IsCertificateError(result)) {
[email protected]18ccfdb2013-08-15 00:13:44565 SetSocket(ssl_socket_.PassAs<StreamSocket>());
[email protected]8b498692010-07-16 17:11:43566 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
567 error_response_info_.cert_request_info = new SSLCertRequestInfo;
[email protected]90499482013-06-01 00:39:50568 ssl_socket_->GetSSLCertRequestInfo(
569 error_response_info_.cert_request_info.get());
[email protected]8b498692010-07-16 17:11:43570 }
[email protected]e60e47a2010-07-14 03:37:18571
572 return result;
573}
574
[email protected]8e458552014-08-05 00:02:15575void SSLConnectJob::ResumeSSLConnection() {
576 DCHECK_EQ(next_state_, STATE_SSL_CONNECT);
[email protected]cffd7f92014-08-21 21:30:50577 messenger_ = NULL;
[email protected]8e458552014-08-05 00:02:15578 OnIOComplete(OK);
579}
580
[email protected]ea79ba92013-08-15 21:56:20581SSLConnectJob::State SSLConnectJob::GetInitialState(
582 SSLSocketParams::ConnectionType connection_type) {
583 switch (connection_type) {
584 case SSLSocketParams::DIRECT:
585 return STATE_TRANSPORT_CONNECT;
586 case SSLSocketParams::HTTP_PROXY:
587 return STATE_TUNNEL_CONNECT;
588 case SSLSocketParams::SOCKS_PROXY:
589 return STATE_SOCKS_CONNECT;
[email protected]ad74a592011-01-21 18:40:55590 }
[email protected]ea79ba92013-08-15 21:56:20591 NOTREACHED();
592 return STATE_NONE;
593}
594
595int SSLConnectJob::ConnectInternal() {
596 next_state_ = GetInitialState(params_->GetConnectionType());
[email protected]ad74a592011-01-21 18:40:55597 return DoLoop(OK);
[email protected]e60e47a2010-07-14 03:37:18598}
599
600SSLClientSocketPool::SSLConnectJobFactory::SSLConnectJobFactory(
[email protected]ab739042011-04-07 15:22:28601 TransportClientSocketPool* transport_pool,
[email protected]2431756e2010-09-29 20:26:13602 SOCKSClientSocketPool* socks_pool,
603 HttpProxyClientSocketPool* http_proxy_pool,
[email protected]e60e47a2010-07-14 03:37:18604 ClientSocketFactory* client_socket_factory,
605 HostResolver* host_resolver,
[email protected]feb79bcd2011-07-21 16:55:17606 const SSLClientSocketContext& context,
[email protected]cffd7f92014-08-21 21:30:50607 const SSLConnectJob::GetMessengerCallback& get_messenger_callback,
[email protected]e60e47a2010-07-14 03:37:18608 NetLog* net_log)
[email protected]ab739042011-04-07 15:22:28609 : transport_pool_(transport_pool),
[email protected]e60e47a2010-07-14 03:37:18610 socks_pool_(socks_pool),
[email protected]2431756e2010-09-29 20:26:13611 http_proxy_pool_(http_proxy_pool),
[email protected]e60e47a2010-07-14 03:37:18612 client_socket_factory_(client_socket_factory),
613 host_resolver_(host_resolver),
[email protected]feb79bcd2011-07-21 16:55:17614 context_(context),
[email protected]cffd7f92014-08-21 21:30:50615 get_messenger_callback_(get_messenger_callback),
616 net_log_(net_log) {
[email protected]e60e47a2010-07-14 03:37:18617 base::TimeDelta max_transport_timeout = base::TimeDelta();
618 base::TimeDelta pool_timeout;
[email protected]ab739042011-04-07 15:22:28619 if (transport_pool_)
620 max_transport_timeout = transport_pool_->ConnectionTimeout();
[email protected]e60e47a2010-07-14 03:37:18621 if (socks_pool_) {
622 pool_timeout = socks_pool_->ConnectionTimeout();
623 if (pool_timeout > max_transport_timeout)
624 max_transport_timeout = pool_timeout;
625 }
626 if (http_proxy_pool_) {
627 pool_timeout = http_proxy_pool_->ConnectionTimeout();
628 if (pool_timeout > max_transport_timeout)
629 max_transport_timeout = pool_timeout;
630 }
631 timeout_ = max_transport_timeout +
632 base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds);
633}
634
[email protected]8e458552014-08-05 00:02:15635SSLClientSocketPool::SSLConnectJobFactory::~SSLConnectJobFactory() {
[email protected]8e458552014-08-05 00:02:15636}
637
[email protected]e60e47a2010-07-14 03:37:18638SSLClientSocketPool::SSLClientSocketPool(
639 int max_sockets,
640 int max_sockets_per_group,
[email protected]2431756e2010-09-29 20:26:13641 ClientSocketPoolHistograms* histograms,
[email protected]73c45322010-10-01 23:57:54642 HostResolver* host_resolver,
[email protected]822581d2010-12-16 17:27:15643 CertVerifier* cert_verifier,
[email protected]6b8a3c742014-07-25 00:25:35644 ChannelIDService* channel_id_service,
[email protected]a2a41972011-12-07 17:47:27645 TransportSecurityState* transport_security_state,
[email protected]284303b62013-11-28 15:11:54646 CTVerifier* cert_transparency_verifier,
[email protected]c3456bb2011-12-12 22:22:19647 const std::string& ssl_session_cache_shard,
[email protected]e60e47a2010-07-14 03:37:18648 ClientSocketFactory* client_socket_factory,
[email protected]ab739042011-04-07 15:22:28649 TransportClientSocketPool* transport_pool,
[email protected]2431756e2010-09-29 20:26:13650 SOCKSClientSocketPool* socks_pool,
651 HttpProxyClientSocketPool* http_proxy_pool,
[email protected]7abf7d22010-09-04 01:41:59652 SSLConfigService* ssl_config_service,
[email protected]8e458552014-08-05 00:02:15653 bool enable_ssl_connect_job_waiting,
[email protected]e60e47a2010-07-14 03:37:18654 NetLog* net_log)
[email protected]ab739042011-04-07 15:22:28655 : transport_pool_(transport_pool),
[email protected]ba00b492010-09-08 14:53:38656 socks_pool_(socks_pool),
[email protected]2431756e2010-09-29 20:26:13657 http_proxy_pool_(http_proxy_pool),
[email protected]8e458552014-08-05 00:02:15658 base_(this,
659 max_sockets,
660 max_sockets_per_group,
661 histograms,
[email protected]82b8c962011-10-12 09:17:30662 ClientSocketPool::unused_idle_socket_timeout(),
663 ClientSocketPool::used_idle_socket_timeout(),
[email protected]8e458552014-08-05 00:02:15664 new SSLConnectJobFactory(
665 transport_pool,
666 socks_pool,
667 http_proxy_pool,
668 client_socket_factory,
669 host_resolver,
670 SSLClientSocketContext(cert_verifier,
671 channel_id_service,
672 transport_security_state,
673 cert_transparency_verifier,
674 ssl_session_cache_shard),
[email protected]cffd7f92014-08-21 21:30:50675 base::Bind(
676 &SSLClientSocketPool::GetOrCreateSSLConnectJobMessenger,
677 base::Unretained(this)),
[email protected]8e458552014-08-05 00:02:15678 net_log)),
[email protected]cffd7f92014-08-21 21:30:50679 ssl_config_service_(ssl_config_service),
680 enable_ssl_connect_job_waiting_(enable_ssl_connect_job_waiting) {
[email protected]90499482013-06-01 00:39:50681 if (ssl_config_service_.get())
[email protected]7abf7d22010-09-04 01:41:59682 ssl_config_service_->AddObserver(this);
[email protected]51fdc7c2012-04-10 19:19:48683 if (transport_pool_)
[email protected]043b68c82013-08-22 23:41:52684 base_.AddLowerLayeredPool(transport_pool_);
[email protected]51fdc7c2012-04-10 19:19:48685 if (socks_pool_)
[email protected]043b68c82013-08-22 23:41:52686 base_.AddLowerLayeredPool(socks_pool_);
[email protected]51fdc7c2012-04-10 19:19:48687 if (http_proxy_pool_)
[email protected]043b68c82013-08-22 23:41:52688 base_.AddLowerLayeredPool(http_proxy_pool_);
[email protected]7abf7d22010-09-04 01:41:59689}
[email protected]e60e47a2010-07-14 03:37:18690
[email protected]7abf7d22010-09-04 01:41:59691SSLClientSocketPool::~SSLClientSocketPool() {
[email protected]cffd7f92014-08-21 21:30:50692 STLDeleteContainerPairSecondPointers(messenger_map_.begin(),
693 messenger_map_.end());
[email protected]90499482013-06-01 00:39:50694 if (ssl_config_service_.get())
[email protected]7abf7d22010-09-04 01:41:59695 ssl_config_service_->RemoveObserver(this);
696}
[email protected]e60e47a2010-07-14 03:37:18697
[email protected]cffd7f92014-08-21 21:30:50698scoped_ptr<ConnectJob> SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob(
[email protected]ad74a592011-01-21 18:40:55699 const std::string& group_name,
700 const PoolBase::Request& request,
701 ConnectJob::Delegate* delegate) const {
[email protected]8e458552014-08-05 00:02:15702 return scoped_ptr<ConnectJob>(new SSLConnectJob(group_name,
703 request.priority(),
704 request.params(),
705 ConnectionTimeout(),
706 transport_pool_,
707 socks_pool_,
708 http_proxy_pool_,
709 client_socket_factory_,
710 host_resolver_,
711 context_,
[email protected]cffd7f92014-08-21 21:30:50712 get_messenger_callback_,
[email protected]8e458552014-08-05 00:02:15713 delegate,
714 net_log_));
[email protected]ad74a592011-01-21 18:40:55715}
716
[email protected]cffd7f92014-08-21 21:30:50717base::TimeDelta SSLClientSocketPool::SSLConnectJobFactory::ConnectionTimeout()
718 const {
[email protected]2a848e0e2012-08-09 22:27:31719 return timeout_;
720}
721
[email protected]e60e47a2010-07-14 03:37:18722int SSLClientSocketPool::RequestSocket(const std::string& group_name,
723 const void* socket_params,
724 RequestPriority priority,
725 ClientSocketHandle* handle,
[email protected]49639fa2011-12-20 23:22:41726 const CompletionCallback& callback,
[email protected]e60e47a2010-07-14 03:37:18727 const BoundNetLog& net_log) {
728 const scoped_refptr<SSLSocketParams>* casted_socket_params =
729 static_cast<const scoped_refptr<SSLSocketParams>*>(socket_params);
730
731 return base_.RequestSocket(group_name, *casted_socket_params, priority,
732 handle, callback, net_log);
733}
734
[email protected]2c2bef152010-10-13 00:55:03735void SSLClientSocketPool::RequestSockets(
736 const std::string& group_name,
737 const void* params,
738 int num_sockets,
739 const BoundNetLog& net_log) {
740 const scoped_refptr<SSLSocketParams>* casted_params =
741 static_cast<const scoped_refptr<SSLSocketParams>*>(params);
742
743 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log);
744}
745
[email protected]e60e47a2010-07-14 03:37:18746void SSLClientSocketPool::CancelRequest(const std::string& group_name,
[email protected]05ea9ff2010-07-15 19:08:21747 ClientSocketHandle* handle) {
[email protected]e60e47a2010-07-14 03:37:18748 base_.CancelRequest(group_name, handle);
749}
750
751void SSLClientSocketPool::ReleaseSocket(const std::string& group_name,
[email protected]18ccfdb2013-08-15 00:13:44752 scoped_ptr<StreamSocket> socket,
753 int id) {
754 base_.ReleaseSocket(group_name, socket.Pass(), id);
[email protected]e60e47a2010-07-14 03:37:18755}
756
[email protected]7af985a2012-12-14 22:40:42757void SSLClientSocketPool::FlushWithError(int error) {
758 base_.FlushWithError(error);
[email protected]e60e47a2010-07-14 03:37:18759}
760
761void SSLClientSocketPool::CloseIdleSockets() {
762 base_.CloseIdleSockets();
763}
764
[email protected]ddb1e5a2010-12-13 20:10:45765int SSLClientSocketPool::IdleSocketCount() const {
766 return base_.idle_socket_count();
767}
768
[email protected]e60e47a2010-07-14 03:37:18769int SSLClientSocketPool::IdleSocketCountInGroup(
770 const std::string& group_name) const {
771 return base_.IdleSocketCountInGroup(group_name);
772}
773
774LoadState SSLClientSocketPool::GetLoadState(
775 const std::string& group_name, const ClientSocketHandle* handle) const {
776 return base_.GetLoadState(group_name, handle);
777}
778
[email protected]ea5ef4c2013-06-13 22:50:27779base::DictionaryValue* SSLClientSocketPool::GetInfoAsValue(
[email protected]ba00b492010-09-08 14:53:38780 const std::string& name,
781 const std::string& type,
782 bool include_nested_pools) const {
[email protected]ea5ef4c2013-06-13 22:50:27783 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type);
[email protected]ba00b492010-09-08 14:53:38784 if (include_nested_pools) {
[email protected]ea5ef4c2013-06-13 22:50:27785 base::ListValue* list = new base::ListValue();
[email protected]ab739042011-04-07 15:22:28786 if (transport_pool_) {
787 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool",
788 "transport_socket_pool",
789 false));
[email protected]ba00b492010-09-08 14:53:38790 }
[email protected]2431756e2010-09-29 20:26:13791 if (socks_pool_) {
[email protected]ba00b492010-09-08 14:53:38792 list->Append(socks_pool_->GetInfoAsValue("socks_pool",
793 "socks_pool",
794 true));
795 }
[email protected]2431756e2010-09-29 20:26:13796 if (http_proxy_pool_) {
797 list->Append(http_proxy_pool_->GetInfoAsValue("http_proxy_pool",
798 "http_proxy_pool",
799 true));
800 }
[email protected]ba00b492010-09-08 14:53:38801 dict->Set("nested_pools", list);
802 }
803 return dict;
804}
805
[email protected]ddb1e5a2010-12-13 20:10:45806base::TimeDelta SSLClientSocketPool::ConnectionTimeout() const {
807 return base_.ConnectionTimeout();
808}
809
810ClientSocketPoolHistograms* SSLClientSocketPool::histograms() const {
811 return base_.histograms();
812}
813
[email protected]043b68c82013-08-22 23:41:52814bool SSLClientSocketPool::IsStalled() const {
815 return base_.IsStalled();
816}
817
818void SSLClientSocketPool::AddHigherLayeredPool(HigherLayeredPool* higher_pool) {
819 base_.AddHigherLayeredPool(higher_pool);
820}
821
822void SSLClientSocketPool::RemoveHigherLayeredPool(
823 HigherLayeredPool* higher_pool) {
824 base_.RemoveHigherLayeredPool(higher_pool);
[email protected]ad74a592011-01-21 18:40:55825}
826
[email protected]51fdc7c2012-04-10 19:19:48827bool SSLClientSocketPool::CloseOneIdleConnection() {
828 if (base_.CloseOneIdleSocket())
829 return true;
[email protected]043b68c82013-08-22 23:41:52830 return base_.CloseOneIdleConnectionInHigherLayeredPool();
831}
832
[email protected]cffd7f92014-08-21 21:30:50833SSLConnectJobMessenger* SSLClientSocketPool::GetOrCreateSSLConnectJobMessenger(
834 const std::string& cache_key) {
835 if (!enable_ssl_connect_job_waiting_)
836 return NULL;
837 MessengerMap::const_iterator it = messenger_map_.find(cache_key);
838 if (it == messenger_map_.end()) {
839 std::pair<MessengerMap::iterator, bool> iter =
840 messenger_map_.insert(MessengerMap::value_type(
841 cache_key,
842 new SSLConnectJobMessenger(
843 base::Bind(&SSLClientSocketPool::DeleteSSLConnectJobMessenger,
844 base::Unretained(this),
845 cache_key))));
846 it = iter.first;
847 }
848 return it->second;
849}
850
851void SSLClientSocketPool::DeleteSSLConnectJobMessenger(
852 const std::string& cache_key) {
853 MessengerMap::iterator it = messenger_map_.find(cache_key);
854 CHECK(it != messenger_map_.end());
855 delete it->second;
856 messenger_map_.erase(it);
857}
858
[email protected]043b68c82013-08-22 23:41:52859void SSLClientSocketPool::OnSSLConfigChanged() {
860 FlushWithError(ERR_NETWORK_CHANGED);
[email protected]51fdc7c2012-04-10 19:19:48861}
862
[email protected]e60e47a2010-07-14 03:37:18863} // namespace net