blob: 6643ef4e3af0ac5e00c9c0b27f31b37e278abd1d [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,
[email protected]feb79bcd2011-07-21 16:55:17180 const SSLClientSocketContext& context,
[email protected]cffd7f92014-08-21 21:30:50181 const GetMessengerCallback& get_messenger_callback,
[email protected]feb79bcd2011-07-21 16:55:17182 Delegate* delegate,
183 NetLog* net_log)
[email protected]5e5021a2013-07-17 05:23:36184 : ConnectJob(group_name,
185 timeout_duration,
[email protected]3f6007ab2013-08-22 19:45:39186 priority,
[email protected]5e5021a2013-07-17 05:23:36187 delegate,
[email protected]e60e47a2010-07-14 03:37:18188 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
189 params_(params),
[email protected]ab739042011-04-07 15:22:28190 transport_pool_(transport_pool),
[email protected]e60e47a2010-07-14 03:37:18191 socks_pool_(socks_pool),
[email protected]2431756e2010-09-29 20:26:13192 http_proxy_pool_(http_proxy_pool),
[email protected]e60e47a2010-07-14 03:37:18193 client_socket_factory_(client_socket_factory),
[email protected]5e5021a2013-07-17 05:23:36194 context_(context.cert_verifier,
[email protected]6b8a3c742014-07-25 00:25:35195 context.channel_id_service,
[email protected]5e5021a2013-07-17 05:23:36196 context.transport_security_state,
[email protected]284303b62013-11-28 15:11:54197 context.cert_transparency_verifier,
eranm6571b2b2014-12-03 15:53:23198 context.cert_policy_enforcer,
[email protected]314b03992014-04-01 01:28:53199 (params->privacy_mode() == PRIVACY_MODE_ENABLED
[email protected]5e5021a2013-07-17 05:23:36200 ? "pm/" + context.ssl_session_cache_shard
201 : context.ssl_session_cache_shard)),
[email protected]8e458552014-08-05 00:02:15202 io_callback_(
203 base::Bind(&SSLConnectJob::OnIOComplete, base::Unretained(this))),
[email protected]cffd7f92014-08-21 21:30:50204 messenger_(NULL),
205 get_messenger_callback_(get_messenger_callback),
[email protected]8e458552014-08-05 00:02:15206 weak_factory_(this) {
207}
[email protected]e60e47a2010-07-14 03:37:18208
[email protected]8e458552014-08-05 00:02:15209SSLConnectJob::~SSLConnectJob() {
210 if (ssl_socket_.get() && messenger_)
211 messenger_->RemovePendingSocket(ssl_socket_.get());
212}
[email protected]e60e47a2010-07-14 03:37:18213
214LoadState SSLConnectJob::GetLoadState() const {
215 switch (next_state_) {
[email protected]135e2262010-07-17 00:32:04216 case STATE_TUNNEL_CONNECT_COMPLETE:
217 if (transport_socket_handle_->socket())
218 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL;
219 // else, fall through.
[email protected]ab739042011-04-07 15:22:28220 case STATE_TRANSPORT_CONNECT:
221 case STATE_TRANSPORT_CONNECT_COMPLETE:
[email protected]e60e47a2010-07-14 03:37:18222 case STATE_SOCKS_CONNECT:
223 case STATE_SOCKS_CONNECT_COMPLETE:
224 case STATE_TUNNEL_CONNECT:
[email protected]e60e47a2010-07-14 03:37:18225 return transport_socket_handle_->GetLoadState();
[email protected]8e458552014-08-05 00:02:15226 case STATE_CREATE_SSL_SOCKET:
227 case STATE_CHECK_FOR_RESUME:
[email protected]e60e47a2010-07-14 03:37:18228 case STATE_SSL_CONNECT:
229 case STATE_SSL_CONNECT_COMPLETE:
230 return LOAD_STATE_SSL_HANDSHAKE;
231 default:
232 NOTREACHED();
233 return LOAD_STATE_IDLE;
234 }
235}
236
[email protected]83039bb2011-12-09 18:43:55237void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) {
[email protected]ad74a592011-01-21 18:40:55238 // Headers in |error_response_info_| indicate a proxy tunnel setup
239 // problem. See DoTunnelConnectComplete.
[email protected]90499482013-06-01 00:39:50240 if (error_response_info_.headers.get()) {
[email protected]ad74a592011-01-21 18:40:55241 handle->set_pending_http_proxy_connection(
242 transport_socket_handle_.release());
[email protected]e60e47a2010-07-14 03:37:18243 }
[email protected]ad74a592011-01-21 18:40:55244 handle->set_ssl_error_response_info(error_response_info_);
[email protected]034df0f32013-01-07 23:17:48245 if (!connect_timing_.ssl_start.is_null())
[email protected]ad74a592011-01-21 18:40:55246 handle->set_is_ssl_error(true);
[email protected]e60e47a2010-07-14 03:37:18247}
248
249void SSLConnectJob::OnIOComplete(int result) {
[email protected]e60e47a2010-07-14 03:37:18250 int rv = DoLoop(result);
251 if (rv != ERR_IO_PENDING)
252 NotifyDelegateOfCompletion(rv); // Deletes |this|.
253}
254
255int SSLConnectJob::DoLoop(int result) {
256 DCHECK_NE(next_state_, STATE_NONE);
257
258 int rv = result;
259 do {
260 State state = next_state_;
261 next_state_ = STATE_NONE;
262 switch (state) {
[email protected]ab739042011-04-07 15:22:28263 case STATE_TRANSPORT_CONNECT:
[email protected]e60e47a2010-07-14 03:37:18264 DCHECK_EQ(OK, rv);
[email protected]ab739042011-04-07 15:22:28265 rv = DoTransportConnect();
[email protected]e60e47a2010-07-14 03:37:18266 break;
[email protected]ab739042011-04-07 15:22:28267 case STATE_TRANSPORT_CONNECT_COMPLETE:
268 rv = DoTransportConnectComplete(rv);
[email protected]e60e47a2010-07-14 03:37:18269 break;
270 case STATE_SOCKS_CONNECT:
271 DCHECK_EQ(OK, rv);
272 rv = DoSOCKSConnect();
273 break;
274 case STATE_SOCKS_CONNECT_COMPLETE:
275 rv = DoSOCKSConnectComplete(rv);
276 break;
277 case STATE_TUNNEL_CONNECT:
278 DCHECK_EQ(OK, rv);
279 rv = DoTunnelConnect();
280 break;
281 case STATE_TUNNEL_CONNECT_COMPLETE:
282 rv = DoTunnelConnectComplete(rv);
283 break;
[email protected]8e458552014-08-05 00:02:15284 case STATE_CREATE_SSL_SOCKET:
285 rv = DoCreateSSLSocket();
286 break;
287 case STATE_CHECK_FOR_RESUME:
288 rv = DoCheckForResume();
289 break;
[email protected]e60e47a2010-07-14 03:37:18290 case STATE_SSL_CONNECT:
291 DCHECK_EQ(OK, rv);
292 rv = DoSSLConnect();
293 break;
294 case STATE_SSL_CONNECT_COMPLETE:
295 rv = DoSSLConnectComplete(rv);
296 break;
297 default:
298 NOTREACHED() << "bad state";
299 rv = ERR_FAILED;
300 break;
301 }
302 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
303
304 return rv;
305}
306
[email protected]ab739042011-04-07 15:22:28307int SSLConnectJob::DoTransportConnect() {
[email protected]ab739042011-04-07 15:22:28308 DCHECK(transport_pool_);
[email protected]899c3e92010-08-28 15:53:50309
[email protected]ab739042011-04-07 15:22:28310 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE;
[email protected]e60e47a2010-07-14 03:37:18311 transport_socket_handle_.reset(new ClientSocketHandle());
[email protected]ea79ba92013-08-15 21:56:20312 scoped_refptr<TransportSocketParams> direct_params =
313 params_->GetDirectConnectionParams();
[email protected]5109c1952013-08-20 18:44:10314 return transport_socket_handle_->Init(group_name(),
315 direct_params,
[email protected]3f6007ab2013-08-22 19:45:39316 priority(),
[email protected]8e458552014-08-05 00:02:15317 io_callback_,
[email protected]5109c1952013-08-20 18:44:10318 transport_pool_,
319 net_log());
[email protected]e60e47a2010-07-14 03:37:18320}
321
[email protected]ab739042011-04-07 15:22:28322int SSLConnectJob::DoTransportConnectComplete(int result) {
[email protected]e60e47a2010-07-14 03:37:18323 if (result == OK)
[email protected]8e458552014-08-05 00:02:15324 next_state_ = STATE_CREATE_SSL_SOCKET;
[email protected]e60e47a2010-07-14 03:37:18325
326 return result;
327}
328
329int SSLConnectJob::DoSOCKSConnect() {
[email protected]2431756e2010-09-29 20:26:13330 DCHECK(socks_pool_);
[email protected]e60e47a2010-07-14 03:37:18331 next_state_ = STATE_SOCKS_CONNECT_COMPLETE;
332 transport_socket_handle_.reset(new ClientSocketHandle());
[email protected]ea79ba92013-08-15 21:56:20333 scoped_refptr<SOCKSSocketParams> socks_proxy_params =
334 params_->GetSocksProxyConnectionParams();
[email protected]5109c1952013-08-20 18:44:10335 return transport_socket_handle_->Init(group_name(),
336 socks_proxy_params,
[email protected]3f6007ab2013-08-22 19:45:39337 priority(),
[email protected]8e458552014-08-05 00:02:15338 io_callback_,
[email protected]5109c1952013-08-20 18:44:10339 socks_pool_,
340 net_log());
[email protected]e60e47a2010-07-14 03:37:18341}
342
343int SSLConnectJob::DoSOCKSConnectComplete(int result) {
344 if (result == OK)
[email protected]8e458552014-08-05 00:02:15345 next_state_ = STATE_CREATE_SSL_SOCKET;
[email protected]e60e47a2010-07-14 03:37:18346
347 return result;
348}
349
350int SSLConnectJob::DoTunnelConnect() {
[email protected]2431756e2010-09-29 20:26:13351 DCHECK(http_proxy_pool_);
[email protected]e60e47a2010-07-14 03:37:18352 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE;
[email protected]394816e92010-08-03 07:38:59353
[email protected]e60e47a2010-07-14 03:37:18354 transport_socket_handle_.reset(new ClientSocketHandle());
355 scoped_refptr<HttpProxySocketParams> http_proxy_params =
[email protected]ea79ba92013-08-15 21:56:20356 params_->GetHttpProxyConnectionParams();
[email protected]5109c1952013-08-20 18:44:10357 return transport_socket_handle_->Init(group_name(),
358 http_proxy_params,
[email protected]3f6007ab2013-08-22 19:45:39359 priority(),
[email protected]8e458552014-08-05 00:02:15360 io_callback_,
[email protected]5109c1952013-08-20 18:44:10361 http_proxy_pool_,
362 net_log());
[email protected]e60e47a2010-07-14 03:37:18363}
364
365int SSLConnectJob::DoTunnelConnectComplete(int result) {
[email protected]4f4de7e62010-11-12 19:55:27366 // Extract the information needed to prompt for appropriate proxy
367 // authentication so that when ClientSocketPoolBaseHelper calls
368 // |GetAdditionalErrorState|, we can easily set the state.
369 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
370 error_response_info_ = transport_socket_handle_->ssl_error_response_info();
[email protected]511f6f52010-12-17 03:58:29371 } else if (result == ERR_PROXY_AUTH_REQUESTED ||
372 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
[email protected]3268023f2011-05-05 00:08:10373 StreamSocket* socket = transport_socket_handle_->socket();
pcc684f44b2015-01-30 18:59:23374 ProxyClientSocket* tunnel_socket = static_cast<ProxyClientSocket*>(socket);
[email protected]511f6f52010-12-17 03:58:29375 error_response_info_ = *tunnel_socket->GetConnectResponseInfo();
[email protected]4f4de7e62010-11-12 19:55:27376 }
[email protected]e60e47a2010-07-14 03:37:18377 if (result < 0)
378 return result;
[email protected]8e458552014-08-05 00:02:15379 next_state_ = STATE_CREATE_SSL_SOCKET;
[email protected]e60e47a2010-07-14 03:37:18380 return result;
381}
382
[email protected]8e458552014-08-05 00:02:15383int SSLConnectJob::DoCreateSSLSocket() {
pkasting93ba27f62015-02-28 02:53:46384 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed.
pkasting58e029b2015-02-21 05:17:28385 tracked_objects::ScopedTracker tracking_profile(
386 FROM_HERE_WITH_EXPLICIT_FUNCTION(
pkasting93ba27f62015-02-28 02:53:46387 "462815 SSLConnectJob::DoCreateSSLSocket"));
[email protected]8e458552014-08-05 00:02:15388 next_state_ = STATE_CHECK_FOR_RESUME;
389
[email protected]e60e47a2010-07-14 03:37:18390 // Reset the timeout to just the time allowed for the SSL handshake.
391 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds));
[email protected]034df0f32013-01-07 23:17:48392
393 // If the handle has a fresh socket, get its connect start and DNS times.
394 // This should always be the case.
395 const LoadTimingInfo::ConnectTiming& socket_connect_timing =
396 transport_socket_handle_->connect_timing();
397 if (!transport_socket_handle_->is_reused() &&
398 !socket_connect_timing.connect_start.is_null()) {
399 // Overwriting |connect_start| serves two purposes - it adjusts timing so
400 // |connect_start| doesn't include dns times, and it adjusts the time so
401 // as not to include time spent waiting for an idle socket.
402 connect_timing_.connect_start = socket_connect_timing.connect_start;
403 connect_timing_.dns_start = socket_connect_timing.dns_start;
404 connect_timing_.dns_end = socket_connect_timing.dns_end;
405 }
406
[email protected]18ccfdb2013-08-15 00:13:44407 ssl_socket_ = client_socket_factory_->CreateSSLClientSocket(
408 transport_socket_handle_.Pass(),
[email protected]5e5021a2013-07-17 05:23:36409 params_->host_and_port(),
410 params_->ssl_config(),
[email protected]18ccfdb2013-08-15 00:13:44411 context_);
[email protected]cffd7f92014-08-21 21:30:50412
413 if (!ssl_socket_->InSessionCache())
414 messenger_ = get_messenger_callback_.Run(ssl_socket_->GetSessionCacheKey());
415
[email protected]8e458552014-08-05 00:02:15416 return OK;
417}
418
419int SSLConnectJob::DoCheckForResume() {
[email protected]8e458552014-08-05 00:02:15420 next_state_ = STATE_SSL_CONNECT;
[email protected]cffd7f92014-08-21 21:30:50421
[email protected]8e458552014-08-05 00:02:15422 if (!messenger_)
423 return OK;
424
[email protected]8e458552014-08-05 00:02:15425 if (messenger_->CanProceed(ssl_socket_.get())) {
[email protected]cffd7f92014-08-21 21:30:50426 messenger_->MonitorConnectionResult(ssl_socket_.get());
427 // The SSLConnectJob no longer needs access to the messenger after this
428 // point.
429 messenger_ = NULL;
[email protected]8e458552014-08-05 00:02:15430 return OK;
431 }
[email protected]cffd7f92014-08-21 21:30:50432
[email protected]8e458552014-08-05 00:02:15433 messenger_->AddPendingSocket(ssl_socket_.get(),
434 base::Bind(&SSLConnectJob::ResumeSSLConnection,
435 weak_factory_.GetWeakPtr()));
[email protected]cffd7f92014-08-21 21:30:50436
[email protected]8e458552014-08-05 00:02:15437 return ERR_IO_PENDING;
438}
439
440int SSLConnectJob::DoSSLConnect() {
pkasting93ba27f62015-02-28 02:53:46441 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462813 is fixed.
pkasting58e029b2015-02-21 05:17:28442 tracked_objects::ScopedTracker tracking_profile(
pkasting93ba27f62015-02-28 02:53:46443 FROM_HERE_WITH_EXPLICIT_FUNCTION("462813 SSLConnectJob::DoSSLConnect"));
[email protected]8e458552014-08-05 00:02:15444 next_state_ = STATE_SSL_CONNECT_COMPLETE;
445
446 connect_timing_.ssl_start = base::TimeTicks::Now();
447
448 return ssl_socket_->Connect(io_callback_);
[email protected]e60e47a2010-07-14 03:37:18449}
450
451int SSLConnectJob::DoSSLConnectComplete(int result) {
[email protected]034df0f32013-01-07 23:17:48452 connect_timing_.ssl_end = base::TimeTicks::Now();
453
[email protected]e60e47a2010-07-14 03:37:18454 SSLClientSocket::NextProtoStatus status =
455 SSLClientSocket::kNextProtoUnsupported;
456 std::string proto;
457 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket
458 // that hasn't had SSL_ImportFD called on it. If we get a certificate error
459 // here, then we know that we called SSL_ImportFD.
bnc0d28ea52014-10-13 15:15:38460 if (result == OK || IsCertificateError(result)) {
[email protected]abc44b752014-07-30 03:52:15461 status = ssl_socket_->GetNextProto(&proto);
bnc0d28ea52014-10-13 15:15:38462 ssl_socket_->RecordNegotiationExtension();
463 }
[email protected]e60e47a2010-07-14 03:37:18464
[email protected]9e9e842e2010-07-23 23:09:15465 // If we want spdy over npn, make sure it succeeded.
[email protected]e60e47a2010-07-14 03:37:18466 if (status == SSLClientSocket::kNextProtoNegotiated) {
[email protected]d7c9f422010-08-27 22:54:53467 ssl_socket_->set_was_npn_negotiated(true);
[email protected]8e3c78cb2012-03-31 03:58:46468 NextProto protocol_negotiated =
[email protected]bace48c2010-08-03 20:52:02469 SSLClientSocket::NextProtoFromString(proto);
[email protected]c30bcce2011-12-20 17:50:51470 ssl_socket_->set_protocol_negotiated(protocol_negotiated);
[email protected]63bf9662013-03-05 20:46:01471 // If we negotiated a SPDY version, it must have been present in
472 // SSLConfig::next_protos.
473 // TODO(mbelshe): Verify this.
474 if (protocol_negotiated >= kProtoSPDYMinimumVersion &&
475 protocol_negotiated <= kProtoSPDYMaximumVersion) {
[email protected]d7c9f422010-08-27 22:54:53476 ssl_socket_->set_was_spdy_negotiated(true);
[email protected]e60e47a2010-07-14 03:37:18477 }
478 }
[email protected]d7c9f422010-08-27 22:54:53479 if (params_->want_spdy_over_npn() && !ssl_socket_->was_spdy_negotiated())
[email protected]e60e47a2010-07-14 03:37:18480 return ERR_NPN_NEGOTIATION_FAILED;
481
[email protected]9e9e842e2010-07-23 23:09:15482 // Spdy might be turned on by default, or it might be over npn.
483 bool using_spdy = params_->force_spdy_over_ssl() ||
484 params_->want_spdy_over_npn();
485
[email protected]e60e47a2010-07-14 03:37:18486 if (result == OK ||
487 ssl_socket_->IgnoreCertError(result, params_->load_flags())) {
[email protected]034df0f32013-01-07 23:17:48488 DCHECK(!connect_timing_.ssl_start.is_null());
[email protected]e60e47a2010-07-14 03:37:18489 base::TimeDelta connect_duration =
[email protected]034df0f32013-01-07 23:17:48490 connect_timing_.ssl_end - connect_timing_.ssl_start;
[email protected]835d7c82010-10-14 04:38:38491 if (using_spdy) {
[email protected]847276962013-03-08 23:53:17492 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SpdyConnectionLatency_2",
[email protected]e60e47a2010-07-14 03:37:18493 connect_duration,
494 base::TimeDelta::FromMilliseconds(1),
[email protected]847276962013-03-08 23:53:17495 base::TimeDelta::FromMinutes(1),
[email protected]e60e47a2010-07-14 03:37:18496 100);
[email protected]f906bfe2011-06-09 16:35:24497 }
[email protected]f906bfe2011-06-09 16:35:24498
[email protected]847276962013-03-08 23:53:17499 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_2",
[email protected]f906bfe2011-06-09 16:35:24500 connect_duration,
501 base::TimeDelta::FromMilliseconds(1),
[email protected]847276962013-03-08 23:53:17502 base::TimeDelta::FromMinutes(1),
[email protected]f906bfe2011-06-09 16:35:24503 100);
504
[email protected]b076d6c2011-06-29 14:47:51505 SSLInfo ssl_info;
davidbend3f15152015-02-20 23:43:09506 bool has_ssl_info = ssl_socket_->GetSSLInfo(&ssl_info);
507 DCHECK(has_ssl_info);
[email protected]b076d6c2011-06-29 14:47:51508
davidben9ff250e02015-02-19 23:06:51509 UMA_HISTOGRAM_ENUMERATION("Net.SSLVersion", SSLConnectionStatusToVersion(
510 ssl_info.connection_status),
511 SSL_CONNECTION_VERSION_MAX);
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
jeremyim8d44fadd2015-02-10 19:18:15564 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(result));
565 if (params_->ssl_config().fastradio_padding_eligible) {
566 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error_FastRadioPadding",
567 std::abs(result));
568 }
569
[email protected]8b498692010-07-16 17:11:43570 if (result == OK || IsCertificateError(result)) {
dchenge3d1ddc2014-10-15 19:30:51571 SetSocket(ssl_socket_.Pass());
[email protected]8b498692010-07-16 17:11:43572 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
573 error_response_info_.cert_request_info = new SSLCertRequestInfo;
[email protected]90499482013-06-01 00:39:50574 ssl_socket_->GetSSLCertRequestInfo(
575 error_response_info_.cert_request_info.get());
[email protected]8b498692010-07-16 17:11:43576 }
[email protected]e60e47a2010-07-14 03:37:18577
578 return result;
579}
580
[email protected]8e458552014-08-05 00:02:15581void SSLConnectJob::ResumeSSLConnection() {
582 DCHECK_EQ(next_state_, STATE_SSL_CONNECT);
[email protected]cffd7f92014-08-21 21:30:50583 messenger_ = NULL;
[email protected]8e458552014-08-05 00:02:15584 OnIOComplete(OK);
585}
586
[email protected]ea79ba92013-08-15 21:56:20587SSLConnectJob::State SSLConnectJob::GetInitialState(
588 SSLSocketParams::ConnectionType connection_type) {
589 switch (connection_type) {
590 case SSLSocketParams::DIRECT:
591 return STATE_TRANSPORT_CONNECT;
592 case SSLSocketParams::HTTP_PROXY:
593 return STATE_TUNNEL_CONNECT;
594 case SSLSocketParams::SOCKS_PROXY:
595 return STATE_SOCKS_CONNECT;
[email protected]ad74a592011-01-21 18:40:55596 }
[email protected]ea79ba92013-08-15 21:56:20597 NOTREACHED();
598 return STATE_NONE;
599}
600
601int SSLConnectJob::ConnectInternal() {
602 next_state_ = GetInitialState(params_->GetConnectionType());
[email protected]ad74a592011-01-21 18:40:55603 return DoLoop(OK);
[email protected]e60e47a2010-07-14 03:37:18604}
605
606SSLClientSocketPool::SSLConnectJobFactory::SSLConnectJobFactory(
[email protected]ab739042011-04-07 15:22:28607 TransportClientSocketPool* transport_pool,
[email protected]2431756e2010-09-29 20:26:13608 SOCKSClientSocketPool* socks_pool,
609 HttpProxyClientSocketPool* http_proxy_pool,
[email protected]e60e47a2010-07-14 03:37:18610 ClientSocketFactory* client_socket_factory,
[email protected]feb79bcd2011-07-21 16:55:17611 const SSLClientSocketContext& context,
[email protected]cffd7f92014-08-21 21:30:50612 const SSLConnectJob::GetMessengerCallback& get_messenger_callback,
[email protected]e60e47a2010-07-14 03:37:18613 NetLog* net_log)
[email protected]ab739042011-04-07 15:22:28614 : transport_pool_(transport_pool),
[email protected]e60e47a2010-07-14 03:37:18615 socks_pool_(socks_pool),
[email protected]2431756e2010-09-29 20:26:13616 http_proxy_pool_(http_proxy_pool),
[email protected]e60e47a2010-07-14 03:37:18617 client_socket_factory_(client_socket_factory),
[email protected]feb79bcd2011-07-21 16:55:17618 context_(context),
[email protected]cffd7f92014-08-21 21:30:50619 get_messenger_callback_(get_messenger_callback),
620 net_log_(net_log) {
[email protected]e60e47a2010-07-14 03:37:18621 base::TimeDelta max_transport_timeout = base::TimeDelta();
622 base::TimeDelta pool_timeout;
[email protected]ab739042011-04-07 15:22:28623 if (transport_pool_)
624 max_transport_timeout = transport_pool_->ConnectionTimeout();
[email protected]e60e47a2010-07-14 03:37:18625 if (socks_pool_) {
626 pool_timeout = socks_pool_->ConnectionTimeout();
627 if (pool_timeout > max_transport_timeout)
628 max_transport_timeout = pool_timeout;
629 }
630 if (http_proxy_pool_) {
631 pool_timeout = http_proxy_pool_->ConnectionTimeout();
632 if (pool_timeout > max_transport_timeout)
633 max_transport_timeout = pool_timeout;
634 }
635 timeout_ = max_transport_timeout +
636 base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds);
637}
638
[email protected]8e458552014-08-05 00:02:15639SSLClientSocketPool::SSLConnectJobFactory::~SSLConnectJobFactory() {
[email protected]8e458552014-08-05 00:02:15640}
641
[email protected]e60e47a2010-07-14 03:37:18642SSLClientSocketPool::SSLClientSocketPool(
643 int max_sockets,
644 int max_sockets_per_group,
[email protected]2431756e2010-09-29 20:26:13645 ClientSocketPoolHistograms* histograms,
[email protected]822581d2010-12-16 17:27:15646 CertVerifier* cert_verifier,
[email protected]6b8a3c742014-07-25 00:25:35647 ChannelIDService* channel_id_service,
[email protected]a2a41972011-12-07 17:47:27648 TransportSecurityState* transport_security_state,
[email protected]284303b62013-11-28 15:11:54649 CTVerifier* cert_transparency_verifier,
eranm6571b2b2014-12-03 15:53:23650 CertPolicyEnforcer* cert_policy_enforcer,
[email protected]c3456bb2011-12-12 22:22:19651 const std::string& ssl_session_cache_shard,
[email protected]e60e47a2010-07-14 03:37:18652 ClientSocketFactory* client_socket_factory,
[email protected]ab739042011-04-07 15:22:28653 TransportClientSocketPool* transport_pool,
[email protected]2431756e2010-09-29 20:26:13654 SOCKSClientSocketPool* socks_pool,
655 HttpProxyClientSocketPool* http_proxy_pool,
[email protected]7abf7d22010-09-04 01:41:59656 SSLConfigService* ssl_config_service,
[email protected]8e458552014-08-05 00:02:15657 bool enable_ssl_connect_job_waiting,
[email protected]e60e47a2010-07-14 03:37:18658 NetLog* net_log)
[email protected]ab739042011-04-07 15:22:28659 : transport_pool_(transport_pool),
[email protected]ba00b492010-09-08 14:53:38660 socks_pool_(socks_pool),
[email protected]2431756e2010-09-29 20:26:13661 http_proxy_pool_(http_proxy_pool),
[email protected]8e458552014-08-05 00:02:15662 base_(this,
663 max_sockets,
664 max_sockets_per_group,
665 histograms,
[email protected]82b8c962011-10-12 09:17:30666 ClientSocketPool::unused_idle_socket_timeout(),
667 ClientSocketPool::used_idle_socket_timeout(),
[email protected]8e458552014-08-05 00:02:15668 new SSLConnectJobFactory(
669 transport_pool,
670 socks_pool,
671 http_proxy_pool,
672 client_socket_factory,
[email protected]8e458552014-08-05 00:02:15673 SSLClientSocketContext(cert_verifier,
674 channel_id_service,
675 transport_security_state,
676 cert_transparency_verifier,
eranm6571b2b2014-12-03 15:53:23677 cert_policy_enforcer,
[email protected]8e458552014-08-05 00:02:15678 ssl_session_cache_shard),
[email protected]cffd7f92014-08-21 21:30:50679 base::Bind(
680 &SSLClientSocketPool::GetOrCreateSSLConnectJobMessenger,
681 base::Unretained(this)),
[email protected]8e458552014-08-05 00:02:15682 net_log)),
[email protected]cffd7f92014-08-21 21:30:50683 ssl_config_service_(ssl_config_service),
684 enable_ssl_connect_job_waiting_(enable_ssl_connect_job_waiting) {
[email protected]90499482013-06-01 00:39:50685 if (ssl_config_service_.get())
[email protected]7abf7d22010-09-04 01:41:59686 ssl_config_service_->AddObserver(this);
[email protected]51fdc7c2012-04-10 19:19:48687 if (transport_pool_)
[email protected]043b68c82013-08-22 23:41:52688 base_.AddLowerLayeredPool(transport_pool_);
[email protected]51fdc7c2012-04-10 19:19:48689 if (socks_pool_)
[email protected]043b68c82013-08-22 23:41:52690 base_.AddLowerLayeredPool(socks_pool_);
[email protected]51fdc7c2012-04-10 19:19:48691 if (http_proxy_pool_)
[email protected]043b68c82013-08-22 23:41:52692 base_.AddLowerLayeredPool(http_proxy_pool_);
[email protected]7abf7d22010-09-04 01:41:59693}
[email protected]e60e47a2010-07-14 03:37:18694
[email protected]7abf7d22010-09-04 01:41:59695SSLClientSocketPool::~SSLClientSocketPool() {
[email protected]cffd7f92014-08-21 21:30:50696 STLDeleteContainerPairSecondPointers(messenger_map_.begin(),
697 messenger_map_.end());
[email protected]90499482013-06-01 00:39:50698 if (ssl_config_service_.get())
[email protected]7abf7d22010-09-04 01:41:59699 ssl_config_service_->RemoveObserver(this);
700}
[email protected]e60e47a2010-07-14 03:37:18701
[email protected]cffd7f92014-08-21 21:30:50702scoped_ptr<ConnectJob> SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob(
[email protected]ad74a592011-01-21 18:40:55703 const std::string& group_name,
704 const PoolBase::Request& request,
705 ConnectJob::Delegate* delegate) const {
[email protected]8e458552014-08-05 00:02:15706 return scoped_ptr<ConnectJob>(new SSLConnectJob(group_name,
707 request.priority(),
708 request.params(),
709 ConnectionTimeout(),
710 transport_pool_,
711 socks_pool_,
712 http_proxy_pool_,
713 client_socket_factory_,
[email protected]8e458552014-08-05 00:02:15714 context_,
[email protected]cffd7f92014-08-21 21:30:50715 get_messenger_callback_,
[email protected]8e458552014-08-05 00:02:15716 delegate,
717 net_log_));
[email protected]ad74a592011-01-21 18:40:55718}
719
[email protected]cffd7f92014-08-21 21:30:50720base::TimeDelta SSLClientSocketPool::SSLConnectJobFactory::ConnectionTimeout()
721 const {
[email protected]2a848e0e2012-08-09 22:27:31722 return timeout_;
723}
724
[email protected]e60e47a2010-07-14 03:37:18725int SSLClientSocketPool::RequestSocket(const std::string& group_name,
726 const void* socket_params,
727 RequestPriority priority,
728 ClientSocketHandle* handle,
[email protected]49639fa2011-12-20 23:22:41729 const CompletionCallback& callback,
[email protected]e60e47a2010-07-14 03:37:18730 const BoundNetLog& net_log) {
731 const scoped_refptr<SSLSocketParams>* casted_socket_params =
732 static_cast<const scoped_refptr<SSLSocketParams>*>(socket_params);
733
734 return base_.RequestSocket(group_name, *casted_socket_params, priority,
735 handle, callback, net_log);
736}
737
[email protected]2c2bef152010-10-13 00:55:03738void SSLClientSocketPool::RequestSockets(
739 const std::string& group_name,
740 const void* params,
741 int num_sockets,
742 const BoundNetLog& net_log) {
743 const scoped_refptr<SSLSocketParams>* casted_params =
744 static_cast<const scoped_refptr<SSLSocketParams>*>(params);
745
746 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log);
747}
748
[email protected]e60e47a2010-07-14 03:37:18749void SSLClientSocketPool::CancelRequest(const std::string& group_name,
[email protected]05ea9ff2010-07-15 19:08:21750 ClientSocketHandle* handle) {
[email protected]e60e47a2010-07-14 03:37:18751 base_.CancelRequest(group_name, handle);
752}
753
754void SSLClientSocketPool::ReleaseSocket(const std::string& group_name,
[email protected]18ccfdb2013-08-15 00:13:44755 scoped_ptr<StreamSocket> socket,
756 int id) {
757 base_.ReleaseSocket(group_name, socket.Pass(), id);
[email protected]e60e47a2010-07-14 03:37:18758}
759
[email protected]7af985a2012-12-14 22:40:42760void SSLClientSocketPool::FlushWithError(int error) {
761 base_.FlushWithError(error);
[email protected]e60e47a2010-07-14 03:37:18762}
763
764void SSLClientSocketPool::CloseIdleSockets() {
765 base_.CloseIdleSockets();
766}
767
[email protected]ddb1e5a2010-12-13 20:10:45768int SSLClientSocketPool::IdleSocketCount() const {
769 return base_.idle_socket_count();
770}
771
[email protected]e60e47a2010-07-14 03:37:18772int SSLClientSocketPool::IdleSocketCountInGroup(
773 const std::string& group_name) const {
774 return base_.IdleSocketCountInGroup(group_name);
775}
776
777LoadState SSLClientSocketPool::GetLoadState(
778 const std::string& group_name, const ClientSocketHandle* handle) const {
779 return base_.GetLoadState(group_name, handle);
780}
781
[email protected]ea5ef4c2013-06-13 22:50:27782base::DictionaryValue* SSLClientSocketPool::GetInfoAsValue(
[email protected]ba00b492010-09-08 14:53:38783 const std::string& name,
784 const std::string& type,
785 bool include_nested_pools) const {
[email protected]ea5ef4c2013-06-13 22:50:27786 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type);
[email protected]ba00b492010-09-08 14:53:38787 if (include_nested_pools) {
[email protected]ea5ef4c2013-06-13 22:50:27788 base::ListValue* list = new base::ListValue();
[email protected]ab739042011-04-07 15:22:28789 if (transport_pool_) {
790 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool",
791 "transport_socket_pool",
792 false));
[email protected]ba00b492010-09-08 14:53:38793 }
[email protected]2431756e2010-09-29 20:26:13794 if (socks_pool_) {
[email protected]ba00b492010-09-08 14:53:38795 list->Append(socks_pool_->GetInfoAsValue("socks_pool",
796 "socks_pool",
797 true));
798 }
[email protected]2431756e2010-09-29 20:26:13799 if (http_proxy_pool_) {
800 list->Append(http_proxy_pool_->GetInfoAsValue("http_proxy_pool",
801 "http_proxy_pool",
802 true));
803 }
[email protected]ba00b492010-09-08 14:53:38804 dict->Set("nested_pools", list);
805 }
806 return dict;
807}
808
[email protected]ddb1e5a2010-12-13 20:10:45809base::TimeDelta SSLClientSocketPool::ConnectionTimeout() const {
810 return base_.ConnectionTimeout();
811}
812
813ClientSocketPoolHistograms* SSLClientSocketPool::histograms() const {
814 return base_.histograms();
815}
816
[email protected]043b68c82013-08-22 23:41:52817bool SSLClientSocketPool::IsStalled() const {
818 return base_.IsStalled();
819}
820
821void SSLClientSocketPool::AddHigherLayeredPool(HigherLayeredPool* higher_pool) {
822 base_.AddHigherLayeredPool(higher_pool);
823}
824
825void SSLClientSocketPool::RemoveHigherLayeredPool(
826 HigherLayeredPool* higher_pool) {
827 base_.RemoveHigherLayeredPool(higher_pool);
[email protected]ad74a592011-01-21 18:40:55828}
829
[email protected]51fdc7c2012-04-10 19:19:48830bool SSLClientSocketPool::CloseOneIdleConnection() {
831 if (base_.CloseOneIdleSocket())
832 return true;
[email protected]043b68c82013-08-22 23:41:52833 return base_.CloseOneIdleConnectionInHigherLayeredPool();
834}
835
[email protected]cffd7f92014-08-21 21:30:50836SSLConnectJobMessenger* SSLClientSocketPool::GetOrCreateSSLConnectJobMessenger(
837 const std::string& cache_key) {
838 if (!enable_ssl_connect_job_waiting_)
839 return NULL;
840 MessengerMap::const_iterator it = messenger_map_.find(cache_key);
841 if (it == messenger_map_.end()) {
842 std::pair<MessengerMap::iterator, bool> iter =
843 messenger_map_.insert(MessengerMap::value_type(
844 cache_key,
845 new SSLConnectJobMessenger(
846 base::Bind(&SSLClientSocketPool::DeleteSSLConnectJobMessenger,
847 base::Unretained(this),
848 cache_key))));
849 it = iter.first;
850 }
851 return it->second;
852}
853
854void SSLClientSocketPool::DeleteSSLConnectJobMessenger(
855 const std::string& cache_key) {
856 MessengerMap::iterator it = messenger_map_.find(cache_key);
857 CHECK(it != messenger_map_.end());
858 delete it->second;
859 messenger_map_.erase(it);
860}
861
[email protected]043b68c82013-08-22 23:41:52862void SSLClientSocketPool::OnSSLConfigChanged() {
863 FlushWithError(ERR_NETWORK_CHANGED);
[email protected]51fdc7c2012-04-10 19:19:48864}
865
[email protected]e60e47a2010-07-14 03:37:18866} // namespace net