Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / socket / ssl_client_socket_pool.cc
bloba80df57d0be4a8d084e62c5d09f1040ee458c962
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/socket/ssl_client_socket_pool.h"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/sparse_histogram.h"
12 #include "base/profiler/scoped_tracker.h"
13 #include "base/values.h"
14 #include "net/base/host_port_pair.h"
15 #include "net/base/net_errors.h"
16 #include "net/http/http_proxy_client_socket.h"
17 #include "net/http/http_proxy_client_socket_pool.h"
18 #include "net/socket/client_socket_factory.h"
19 #include "net/socket/client_socket_handle.h"
20 #include "net/socket/socks_client_socket_pool.h"
21 #include "net/socket/ssl_client_socket.h"
22 #include "net/socket/transport_client_socket_pool.h"
23 #include "net/ssl/ssl_cert_request_info.h"
24 #include "net/ssl/ssl_connection_status_flags.h"
25 #include "net/ssl/ssl_info.h"
27 namespace net {
29 SSLSocketParams::SSLSocketParams(
30 const scoped_refptr<TransportSocketParams>& direct_params,
31 const scoped_refptr<SOCKSSocketParams>& socks_proxy_params,
32 const scoped_refptr<HttpProxySocketParams>& http_proxy_params,
33 const HostPortPair& host_and_port,
34 const SSLConfig& ssl_config,
35 PrivacyMode privacy_mode,
36 int load_flags,
37 bool expect_spdy)
38 : direct_params_(direct_params),
39 socks_proxy_params_(socks_proxy_params),
40 http_proxy_params_(http_proxy_params),
41 host_and_port_(host_and_port),
42 ssl_config_(ssl_config),
43 privacy_mode_(privacy_mode),
44 load_flags_(load_flags),
45 expect_spdy_(expect_spdy),
46 ignore_limits_(false) {
47 if (direct_params_.get()) {
48 DCHECK(!socks_proxy_params_.get());
49 DCHECK(!http_proxy_params_.get());
50 ignore_limits_ = direct_params_->ignore_limits();
51 } else if (socks_proxy_params_.get()) {
52 DCHECK(!http_proxy_params_.get());
53 ignore_limits_ = socks_proxy_params_->ignore_limits();
54 } else {
55 DCHECK(http_proxy_params_.get());
56 ignore_limits_ = http_proxy_params_->ignore_limits();
60 SSLSocketParams::~SSLSocketParams() {}
62 SSLSocketParams::ConnectionType SSLSocketParams::GetConnectionType() const {
63 if (direct_params_.get()) {
64 DCHECK(!socks_proxy_params_.get());
65 DCHECK(!http_proxy_params_.get());
66 return DIRECT;
69 if (socks_proxy_params_.get()) {
70 DCHECK(!http_proxy_params_.get());
71 return SOCKS_PROXY;
74 DCHECK(http_proxy_params_.get());
75 return HTTP_PROXY;
78 const scoped_refptr<TransportSocketParams>&
79 SSLSocketParams::GetDirectConnectionParams() const {
80 DCHECK_EQ(GetConnectionType(), DIRECT);
81 return direct_params_;
84 const scoped_refptr<SOCKSSocketParams>&
85 SSLSocketParams::GetSocksProxyConnectionParams() const {
86 DCHECK_EQ(GetConnectionType(), SOCKS_PROXY);
87 return socks_proxy_params_;
90 const scoped_refptr<HttpProxySocketParams>&
91 SSLSocketParams::GetHttpProxyConnectionParams() const {
92 DCHECK_EQ(GetConnectionType(), HTTP_PROXY);
93 return http_proxy_params_;
96 // Timeout for the SSL handshake portion of the connect.
97 static const int kSSLHandshakeTimeoutInSeconds = 30;
99 SSLConnectJob::SSLConnectJob(const std::string& group_name,
100 RequestPriority priority,
101 const scoped_refptr<SSLSocketParams>& params,
102 const base::TimeDelta& timeout_duration,
103 TransportClientSocketPool* transport_pool,
104 SOCKSClientSocketPool* socks_pool,
105 HttpProxyClientSocketPool* http_proxy_pool,
106 ClientSocketFactory* client_socket_factory,
107 const SSLClientSocketContext& context,
108 Delegate* delegate,
109 NetLog* net_log)
110 : ConnectJob(group_name,
111 timeout_duration,
112 priority,
113 delegate,
114 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
115 params_(params),
116 transport_pool_(transport_pool),
117 socks_pool_(socks_pool),
118 http_proxy_pool_(http_proxy_pool),
119 client_socket_factory_(client_socket_factory),
120 context_(context.cert_verifier,
121 context.channel_id_service,
122 context.transport_security_state,
123 context.cert_transparency_verifier,
124 context.cert_policy_enforcer,
125 (params->privacy_mode() == PRIVACY_MODE_ENABLED
126 ? "pm/" + context.ssl_session_cache_shard
127 : context.ssl_session_cache_shard)),
128 callback_(
129 base::Bind(&SSLConnectJob::OnIOComplete, base::Unretained(this))) {
132 SSLConnectJob::~SSLConnectJob() {
135 LoadState SSLConnectJob::GetLoadState() const {
136 switch (next_state_) {
137 case STATE_TUNNEL_CONNECT_COMPLETE:
138 if (transport_socket_handle_->socket())
139 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL;
140 // else, fall through.
141 case STATE_TRANSPORT_CONNECT:
142 case STATE_TRANSPORT_CONNECT_COMPLETE:
143 case STATE_SOCKS_CONNECT:
144 case STATE_SOCKS_CONNECT_COMPLETE:
145 case STATE_TUNNEL_CONNECT:
146 return transport_socket_handle_->GetLoadState();
147 case STATE_SSL_CONNECT:
148 case STATE_SSL_CONNECT_COMPLETE:
149 return LOAD_STATE_SSL_HANDSHAKE;
150 default:
151 NOTREACHED();
152 return LOAD_STATE_IDLE;
156 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) {
157 // Headers in |error_response_info_| indicate a proxy tunnel setup
158 // problem. See DoTunnelConnectComplete.
159 if (error_response_info_.headers.get()) {
160 handle->set_pending_http_proxy_connection(
161 transport_socket_handle_.release());
163 handle->set_ssl_error_response_info(error_response_info_);
164 if (!connect_timing_.ssl_start.is_null())
165 handle->set_is_ssl_error(true);
166 if (ssl_socket_)
167 handle->set_ssl_failure_state(ssl_socket_->GetSSLFailureState());
169 handle->set_connection_attempts(connection_attempts_);
172 void SSLConnectJob::OnIOComplete(int result) {
173 int rv = DoLoop(result);
174 if (rv != ERR_IO_PENDING)
175 NotifyDelegateOfCompletion(rv); // Deletes |this|.
178 int SSLConnectJob::DoLoop(int result) {
179 DCHECK_NE(next_state_, STATE_NONE);
181 int rv = result;
182 do {
183 State state = next_state_;
184 next_state_ = STATE_NONE;
185 switch (state) {
186 case STATE_TRANSPORT_CONNECT:
187 DCHECK_EQ(OK, rv);
188 rv = DoTransportConnect();
189 break;
190 case STATE_TRANSPORT_CONNECT_COMPLETE:
191 rv = DoTransportConnectComplete(rv);
192 break;
193 case STATE_SOCKS_CONNECT:
194 DCHECK_EQ(OK, rv);
195 rv = DoSOCKSConnect();
196 break;
197 case STATE_SOCKS_CONNECT_COMPLETE:
198 rv = DoSOCKSConnectComplete(rv);
199 break;
200 case STATE_TUNNEL_CONNECT:
201 DCHECK_EQ(OK, rv);
202 rv = DoTunnelConnect();
203 break;
204 case STATE_TUNNEL_CONNECT_COMPLETE:
205 rv = DoTunnelConnectComplete(rv);
206 break;
207 case STATE_SSL_CONNECT:
208 DCHECK_EQ(OK, rv);
209 rv = DoSSLConnect();
210 break;
211 case STATE_SSL_CONNECT_COMPLETE:
212 rv = DoSSLConnectComplete(rv);
213 break;
214 default:
215 NOTREACHED() << "bad state";
216 rv = ERR_FAILED;
217 break;
219 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
221 return rv;
224 int SSLConnectJob::DoTransportConnect() {
225 DCHECK(transport_pool_);
227 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE;
228 transport_socket_handle_.reset(new ClientSocketHandle());
229 scoped_refptr<TransportSocketParams> direct_params =
230 params_->GetDirectConnectionParams();
231 return transport_socket_handle_->Init(group_name(), direct_params, priority(),
232 callback_, transport_pool_, net_log());
235 int SSLConnectJob::DoTransportConnectComplete(int result) {
236 connection_attempts_ = transport_socket_handle_->connection_attempts();
237 if (result == OK) {
238 next_state_ = STATE_SSL_CONNECT;
239 transport_socket_handle_->socket()->GetPeerAddress(&server_address_);
242 return result;
245 int SSLConnectJob::DoSOCKSConnect() {
246 DCHECK(socks_pool_);
247 next_state_ = STATE_SOCKS_CONNECT_COMPLETE;
248 transport_socket_handle_.reset(new ClientSocketHandle());
249 scoped_refptr<SOCKSSocketParams> socks_proxy_params =
250 params_->GetSocksProxyConnectionParams();
251 return transport_socket_handle_->Init(group_name(), socks_proxy_params,
252 priority(), callback_, socks_pool_,
253 net_log());
256 int SSLConnectJob::DoSOCKSConnectComplete(int result) {
257 if (result == OK)
258 next_state_ = STATE_SSL_CONNECT;
260 return result;
263 int SSLConnectJob::DoTunnelConnect() {
264 DCHECK(http_proxy_pool_);
265 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE;
267 transport_socket_handle_.reset(new ClientSocketHandle());
268 scoped_refptr<HttpProxySocketParams> http_proxy_params =
269 params_->GetHttpProxyConnectionParams();
270 return transport_socket_handle_->Init(group_name(), http_proxy_params,
271 priority(), callback_, http_proxy_pool_,
272 net_log());
275 int SSLConnectJob::DoTunnelConnectComplete(int result) {
276 // Extract the information needed to prompt for appropriate proxy
277 // authentication so that when ClientSocketPoolBaseHelper calls
278 // |GetAdditionalErrorState|, we can easily set the state.
279 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
280 error_response_info_ = transport_socket_handle_->ssl_error_response_info();
281 } else if (result == ERR_PROXY_AUTH_REQUESTED ||
282 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
283 StreamSocket* socket = transport_socket_handle_->socket();
284 ProxyClientSocket* tunnel_socket = static_cast<ProxyClientSocket*>(socket);
285 error_response_info_ = *tunnel_socket->GetConnectResponseInfo();
287 if (result < 0)
288 return result;
290 next_state_ = STATE_SSL_CONNECT;
291 return result;
294 int SSLConnectJob::DoSSLConnect() {
295 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed.
296 tracked_objects::ScopedTracker tracking_profile(
297 FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect"));
299 next_state_ = STATE_SSL_CONNECT_COMPLETE;
301 // Reset the timeout to just the time allowed for the SSL handshake.
302 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds));
304 // If the handle has a fresh socket, get its connect start and DNS times.
305 // This should always be the case.
306 const LoadTimingInfo::ConnectTiming& socket_connect_timing =
307 transport_socket_handle_->connect_timing();
308 if (!transport_socket_handle_->is_reused() &&
309 !socket_connect_timing.connect_start.is_null()) {
310 // Overwriting |connect_start| serves two purposes - it adjusts timing so
311 // |connect_start| doesn't include dns times, and it adjusts the time so
312 // as not to include time spent waiting for an idle socket.
313 connect_timing_.connect_start = socket_connect_timing.connect_start;
314 connect_timing_.dns_start = socket_connect_timing.dns_start;
315 connect_timing_.dns_end = socket_connect_timing.dns_end;
318 connect_timing_.ssl_start = base::TimeTicks::Now();
320 ssl_socket_ = client_socket_factory_->CreateSSLClientSocket(
321 transport_socket_handle_.Pass(),
322 params_->host_and_port(),
323 params_->ssl_config(),
324 context_);
325 return ssl_socket_->Connect(callback_);
328 int SSLConnectJob::DoSSLConnectComplete(int result) {
329 // TODO(rvargas): Remove ScopedTracker below once crbug.com/462784 is fixed.
330 tracked_objects::ScopedTracker tracking_profile(
331 FROM_HERE_WITH_EXPLICIT_FUNCTION(
332 "462784 SSLConnectJob::DoSSLConnectComplete"));
334 connect_timing_.ssl_end = base::TimeTicks::Now();
336 if (result != OK && !server_address_.address().empty()) {
337 connection_attempts_.push_back(ConnectionAttempt(server_address_, result));
338 server_address_ = IPEndPoint();
341 // If we want SPDY over ALPN/NPN, make sure it succeeded.
342 if (params_->expect_spdy() &&
343 !NextProtoIsSPDY(ssl_socket_->GetNegotiatedProtocol())) {
344 return ERR_NPN_NEGOTIATION_FAILED;
347 if (result == OK ||
348 ssl_socket_->IgnoreCertError(result, params_->load_flags())) {
349 DCHECK(!connect_timing_.ssl_start.is_null());
350 base::TimeDelta connect_duration =
351 connect_timing_.ssl_end - connect_timing_.ssl_start;
352 if (params_->expect_spdy()) {
353 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SpdyConnectionLatency_2",
354 connect_duration,
355 base::TimeDelta::FromMilliseconds(1),
356 base::TimeDelta::FromMinutes(1),
357 100);
360 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_2",
361 connect_duration,
362 base::TimeDelta::FromMilliseconds(1),
363 base::TimeDelta::FromMinutes(1),
364 100);
366 SSLInfo ssl_info;
367 bool has_ssl_info = ssl_socket_->GetSSLInfo(&ssl_info);
368 DCHECK(has_ssl_info);
370 UMA_HISTOGRAM_ENUMERATION("Net.SSLVersion", SSLConnectionStatusToVersion(
371 ssl_info.connection_status),
372 SSL_CONNECTION_VERSION_MAX);
374 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_CipherSuite",
375 SSLConnectionStatusToCipherSuite(
376 ssl_info.connection_status));
378 if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_RESUME) {
379 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Resume_Handshake",
380 connect_duration,
381 base::TimeDelta::FromMilliseconds(1),
382 base::TimeDelta::FromMinutes(1),
383 100);
384 } else if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_FULL) {
385 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Full_Handshake",
386 connect_duration,
387 base::TimeDelta::FromMilliseconds(1),
388 base::TimeDelta::FromMinutes(1),
389 100);
392 const std::string& host = params_->host_and_port().host();
393 bool is_google =
394 host == "google.com" ||
395 (host.size() > 11 && host.rfind(".google.com") == host.size() - 11);
396 if (is_google) {
397 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google2",
398 connect_duration,
399 base::TimeDelta::FromMilliseconds(1),
400 base::TimeDelta::FromMinutes(1),
401 100);
402 if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_RESUME) {
403 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google_"
404 "Resume_Handshake",
405 connect_duration,
406 base::TimeDelta::FromMilliseconds(1),
407 base::TimeDelta::FromMinutes(1),
408 100);
409 } else if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_FULL) {
410 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google_"
411 "Full_Handshake",
412 connect_duration,
413 base::TimeDelta::FromMilliseconds(1),
414 base::TimeDelta::FromMinutes(1),
415 100);
420 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(result));
422 if (result == OK || IsCertificateError(result)) {
423 SetSocket(ssl_socket_.Pass());
424 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
425 error_response_info_.cert_request_info = new SSLCertRequestInfo;
426 ssl_socket_->GetSSLCertRequestInfo(
427 error_response_info_.cert_request_info.get());
430 return result;
433 SSLConnectJob::State SSLConnectJob::GetInitialState(
434 SSLSocketParams::ConnectionType connection_type) {
435 switch (connection_type) {
436 case SSLSocketParams::DIRECT:
437 return STATE_TRANSPORT_CONNECT;
438 case SSLSocketParams::HTTP_PROXY:
439 return STATE_TUNNEL_CONNECT;
440 case SSLSocketParams::SOCKS_PROXY:
441 return STATE_SOCKS_CONNECT;
443 NOTREACHED();
444 return STATE_NONE;
447 int SSLConnectJob::ConnectInternal() {
448 next_state_ = GetInitialState(params_->GetConnectionType());
449 return DoLoop(OK);
452 SSLClientSocketPool::SSLConnectJobFactory::SSLConnectJobFactory(
453 TransportClientSocketPool* transport_pool,
454 SOCKSClientSocketPool* socks_pool,
455 HttpProxyClientSocketPool* http_proxy_pool,
456 ClientSocketFactory* client_socket_factory,
457 const SSLClientSocketContext& context,
458 NetLog* net_log)
459 : transport_pool_(transport_pool),
460 socks_pool_(socks_pool),
461 http_proxy_pool_(http_proxy_pool),
462 client_socket_factory_(client_socket_factory),
463 context_(context),
464 net_log_(net_log) {
465 base::TimeDelta max_transport_timeout = base::TimeDelta();
466 base::TimeDelta pool_timeout;
467 if (transport_pool_)
468 max_transport_timeout = transport_pool_->ConnectionTimeout();
469 if (socks_pool_) {
470 pool_timeout = socks_pool_->ConnectionTimeout();
471 if (pool_timeout > max_transport_timeout)
472 max_transport_timeout = pool_timeout;
474 if (http_proxy_pool_) {
475 pool_timeout = http_proxy_pool_->ConnectionTimeout();
476 if (pool_timeout > max_transport_timeout)
477 max_transport_timeout = pool_timeout;
479 timeout_ = max_transport_timeout +
480 base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds);
483 SSLClientSocketPool::SSLConnectJobFactory::~SSLConnectJobFactory() {
486 SSLClientSocketPool::SSLClientSocketPool(
487 int max_sockets,
488 int max_sockets_per_group,
489 CertVerifier* cert_verifier,
490 ChannelIDService* channel_id_service,
491 TransportSecurityState* transport_security_state,
492 CTVerifier* cert_transparency_verifier,
493 CertPolicyEnforcer* cert_policy_enforcer,
494 const std::string& ssl_session_cache_shard,
495 ClientSocketFactory* client_socket_factory,
496 TransportClientSocketPool* transport_pool,
497 SOCKSClientSocketPool* socks_pool,
498 HttpProxyClientSocketPool* http_proxy_pool,
499 SSLConfigService* ssl_config_service,
500 NetLog* net_log)
501 : transport_pool_(transport_pool),
502 socks_pool_(socks_pool),
503 http_proxy_pool_(http_proxy_pool),
504 base_(this,
505 max_sockets,
506 max_sockets_per_group,
507 ClientSocketPool::unused_idle_socket_timeout(),
508 ClientSocketPool::used_idle_socket_timeout(),
509 new SSLConnectJobFactory(
510 transport_pool,
511 socks_pool,
512 http_proxy_pool,
513 client_socket_factory,
514 SSLClientSocketContext(cert_verifier,
515 channel_id_service,
516 transport_security_state,
517 cert_transparency_verifier,
518 cert_policy_enforcer,
519 ssl_session_cache_shard),
520 net_log)),
521 ssl_config_service_(ssl_config_service) {
522 if (ssl_config_service_.get())
523 ssl_config_service_->AddObserver(this);
524 if (transport_pool_)
525 base_.AddLowerLayeredPool(transport_pool_);
526 if (socks_pool_)
527 base_.AddLowerLayeredPool(socks_pool_);
528 if (http_proxy_pool_)
529 base_.AddLowerLayeredPool(http_proxy_pool_);
532 SSLClientSocketPool::~SSLClientSocketPool() {
533 if (ssl_config_service_.get())
534 ssl_config_service_->RemoveObserver(this);
537 scoped_ptr<ConnectJob> SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob(
538 const std::string& group_name,
539 const PoolBase::Request& request,
540 ConnectJob::Delegate* delegate) const {
541 return scoped_ptr<ConnectJob>(new SSLConnectJob(group_name,
542 request.priority(),
543 request.params(),
544 ConnectionTimeout(),
545 transport_pool_,
546 socks_pool_,
547 http_proxy_pool_,
548 client_socket_factory_,
549 context_,
550 delegate,
551 net_log_));
554 base::TimeDelta SSLClientSocketPool::SSLConnectJobFactory::ConnectionTimeout()
555 const {
556 return timeout_;
559 int SSLClientSocketPool::RequestSocket(const std::string& group_name,
560 const void* socket_params,
561 RequestPriority priority,
562 ClientSocketHandle* handle,
563 const CompletionCallback& callback,
564 const BoundNetLog& net_log) {
565 const scoped_refptr<SSLSocketParams>* casted_socket_params =
566 static_cast<const scoped_refptr<SSLSocketParams>*>(socket_params);
568 return base_.RequestSocket(group_name, *casted_socket_params, priority,
569 handle, callback, net_log);
572 void SSLClientSocketPool::RequestSockets(
573 const std::string& group_name,
574 const void* params,
575 int num_sockets,
576 const BoundNetLog& net_log) {
577 const scoped_refptr<SSLSocketParams>* casted_params =
578 static_cast<const scoped_refptr<SSLSocketParams>*>(params);
580 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log);
583 void SSLClientSocketPool::CancelRequest(const std::string& group_name,
584 ClientSocketHandle* handle) {
585 base_.CancelRequest(group_name, handle);
588 void SSLClientSocketPool::ReleaseSocket(const std::string& group_name,
589 scoped_ptr<StreamSocket> socket,
590 int id) {
591 base_.ReleaseSocket(group_name, socket.Pass(), id);
594 void SSLClientSocketPool::FlushWithError(int error) {
595 base_.FlushWithError(error);
598 void SSLClientSocketPool::CloseIdleSockets() {
599 base_.CloseIdleSockets();
602 int SSLClientSocketPool::IdleSocketCount() const {
603 return base_.idle_socket_count();
606 int SSLClientSocketPool::IdleSocketCountInGroup(
607 const std::string& group_name) const {
608 return base_.IdleSocketCountInGroup(group_name);
611 LoadState SSLClientSocketPool::GetLoadState(
612 const std::string& group_name, const ClientSocketHandle* handle) const {
613 return base_.GetLoadState(group_name, handle);
616 scoped_ptr<base::DictionaryValue> SSLClientSocketPool::GetInfoAsValue(
617 const std::string& name,
618 const std::string& type,
619 bool include_nested_pools) const {
620 scoped_ptr<base::DictionaryValue> dict(base_.GetInfoAsValue(name, type));
621 if (include_nested_pools) {
622 base::ListValue* list = new base::ListValue();
623 if (transport_pool_) {
624 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool",
625 "transport_socket_pool",
626 false));
628 if (socks_pool_) {
629 list->Append(socks_pool_->GetInfoAsValue("socks_pool",
630 "socks_pool",
631 true));
633 if (http_proxy_pool_) {
634 list->Append(http_proxy_pool_->GetInfoAsValue("http_proxy_pool",
635 "http_proxy_pool",
636 true));
638 dict->Set("nested_pools", list);
640 return dict.Pass();
643 base::TimeDelta SSLClientSocketPool::ConnectionTimeout() const {
644 return base_.ConnectionTimeout();
647 bool SSLClientSocketPool::IsStalled() const {
648 return base_.IsStalled();
651 void SSLClientSocketPool::AddHigherLayeredPool(HigherLayeredPool* higher_pool) {
652 base_.AddHigherLayeredPool(higher_pool);
655 void SSLClientSocketPool::RemoveHigherLayeredPool(
656 HigherLayeredPool* higher_pool) {
657 base_.RemoveHigherLayeredPool(higher_pool);
660 bool SSLClientSocketPool::CloseOneIdleConnection() {
661 if (base_.CloseOneIdleSocket())
662 return true;
663 return base_.CloseOneIdleConnectionInHigherLayeredPool();
666 void SSLClientSocketPool::OnSSLConfigChanged() {
667 FlushWithError(ERR_NETWORK_CHANGED);
670 } // namespace net