Show Pages in chrome://md-settings
[chromium-blink-merge.git] / net / socket / ssl_client_socket_pool.cc
blob342e5ea8825d66b4968eb112cd4381191e51a815
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.h"
11 #include "base/metrics/sparse_histogram.h"
12 #include "base/values.h"
13 #include "net/base/host_port_pair.h"
14 #include "net/base/net_errors.h"
15 #include "net/http/http_proxy_client_socket.h"
16 #include "net/http/http_proxy_client_socket_pool.h"
17 #include "net/socket/client_socket_factory.h"
18 #include "net/socket/client_socket_handle.h"
19 #include "net/socket/socks_client_socket_pool.h"
20 #include "net/socket/ssl_client_socket.h"
21 #include "net/socket/transport_client_socket_pool.h"
22 #include "net/ssl/ssl_cert_request_info.h"
23 #include "net/ssl/ssl_connection_status_flags.h"
24 #include "net/ssl/ssl_info.h"
26 namespace net {
28 SSLSocketParams::SSLSocketParams(
29 const scoped_refptr<TransportSocketParams>& direct_params,
30 const scoped_refptr<SOCKSSocketParams>& socks_proxy_params,
31 const scoped_refptr<HttpProxySocketParams>& http_proxy_params,
32 const HostPortPair& host_and_port,
33 const SSLConfig& ssl_config,
34 PrivacyMode privacy_mode,
35 int load_flags,
36 bool force_spdy_over_ssl,
37 bool want_spdy_over_npn)
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 force_spdy_over_ssl_(force_spdy_over_ssl),
46 want_spdy_over_npn_(want_spdy_over_npn),
47 ignore_limits_(false) {
48 if (direct_params_.get()) {
49 DCHECK(!socks_proxy_params_.get());
50 DCHECK(!http_proxy_params_.get());
51 ignore_limits_ = direct_params_->ignore_limits();
52 } else if (socks_proxy_params_.get()) {
53 DCHECK(!http_proxy_params_.get());
54 ignore_limits_ = socks_proxy_params_->ignore_limits();
55 } else {
56 DCHECK(http_proxy_params_.get());
57 ignore_limits_ = http_proxy_params_->ignore_limits();
61 SSLSocketParams::~SSLSocketParams() {}
63 SSLSocketParams::ConnectionType SSLSocketParams::GetConnectionType() const {
64 if (direct_params_.get()) {
65 DCHECK(!socks_proxy_params_.get());
66 DCHECK(!http_proxy_params_.get());
67 return DIRECT;
70 if (socks_proxy_params_.get()) {
71 DCHECK(!http_proxy_params_.get());
72 return SOCKS_PROXY;
75 DCHECK(http_proxy_params_.get());
76 return HTTP_PROXY;
79 const scoped_refptr<TransportSocketParams>&
80 SSLSocketParams::GetDirectConnectionParams() const {
81 DCHECK_EQ(GetConnectionType(), DIRECT);
82 return direct_params_;
85 const scoped_refptr<SOCKSSocketParams>&
86 SSLSocketParams::GetSocksProxyConnectionParams() const {
87 DCHECK_EQ(GetConnectionType(), SOCKS_PROXY);
88 return socks_proxy_params_;
91 const scoped_refptr<HttpProxySocketParams>&
92 SSLSocketParams::GetHttpProxyConnectionParams() const {
93 DCHECK_EQ(GetConnectionType(), HTTP_PROXY);
94 return http_proxy_params_;
97 // Timeout for the SSL handshake portion of the connect.
98 static const int kSSLHandshakeTimeoutInSeconds = 30;
100 SSLConnectJob::SSLConnectJob(const std::string& group_name,
101 RequestPriority priority,
102 const scoped_refptr<SSLSocketParams>& params,
103 const base::TimeDelta& timeout_duration,
104 TransportClientSocketPool* transport_pool,
105 SOCKSClientSocketPool* socks_pool,
106 HttpProxyClientSocketPool* http_proxy_pool,
107 ClientSocketFactory* client_socket_factory,
108 const SSLClientSocketContext& context,
109 Delegate* delegate,
110 NetLog* net_log)
111 : ConnectJob(group_name,
112 timeout_duration,
113 priority,
114 delegate,
115 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
116 params_(params),
117 transport_pool_(transport_pool),
118 socks_pool_(socks_pool),
119 http_proxy_pool_(http_proxy_pool),
120 client_socket_factory_(client_socket_factory),
121 context_(context.cert_verifier,
122 context.channel_id_service,
123 context.transport_security_state,
124 context.cert_transparency_verifier,
125 context.cert_policy_enforcer,
126 (params->privacy_mode() == PRIVACY_MODE_ENABLED
127 ? "pm/" + context.ssl_session_cache_shard
128 : context.ssl_session_cache_shard)),
129 callback_(
130 base::Bind(&SSLConnectJob::OnIOComplete, base::Unretained(this))) {
133 SSLConnectJob::~SSLConnectJob() {
136 LoadState SSLConnectJob::GetLoadState() const {
137 switch (next_state_) {
138 case STATE_TUNNEL_CONNECT_COMPLETE:
139 if (transport_socket_handle_->socket())
140 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL;
141 // else, fall through.
142 case STATE_TRANSPORT_CONNECT:
143 case STATE_TRANSPORT_CONNECT_COMPLETE:
144 case STATE_SOCKS_CONNECT:
145 case STATE_SOCKS_CONNECT_COMPLETE:
146 case STATE_TUNNEL_CONNECT:
147 return transport_socket_handle_->GetLoadState();
148 case STATE_SSL_CONNECT:
149 case STATE_SSL_CONNECT_COMPLETE:
150 return LOAD_STATE_SSL_HANDSHAKE;
151 default:
152 NOTREACHED();
153 return LOAD_STATE_IDLE;
157 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) {
158 // Headers in |error_response_info_| indicate a proxy tunnel setup
159 // problem. See DoTunnelConnectComplete.
160 if (error_response_info_.headers.get()) {
161 handle->set_pending_http_proxy_connection(
162 transport_socket_handle_.release());
164 handle->set_ssl_error_response_info(error_response_info_);
165 if (!connect_timing_.ssl_start.is_null())
166 handle->set_is_ssl_error(true);
169 void SSLConnectJob::OnIOComplete(int result) {
170 int rv = DoLoop(result);
171 if (rv != ERR_IO_PENDING)
172 NotifyDelegateOfCompletion(rv); // Deletes |this|.
175 int SSLConnectJob::DoLoop(int result) {
176 DCHECK_NE(next_state_, STATE_NONE);
178 int rv = result;
179 do {
180 State state = next_state_;
181 next_state_ = STATE_NONE;
182 switch (state) {
183 case STATE_TRANSPORT_CONNECT:
184 DCHECK_EQ(OK, rv);
185 rv = DoTransportConnect();
186 break;
187 case STATE_TRANSPORT_CONNECT_COMPLETE:
188 rv = DoTransportConnectComplete(rv);
189 break;
190 case STATE_SOCKS_CONNECT:
191 DCHECK_EQ(OK, rv);
192 rv = DoSOCKSConnect();
193 break;
194 case STATE_SOCKS_CONNECT_COMPLETE:
195 rv = DoSOCKSConnectComplete(rv);
196 break;
197 case STATE_TUNNEL_CONNECT:
198 DCHECK_EQ(OK, rv);
199 rv = DoTunnelConnect();
200 break;
201 case STATE_TUNNEL_CONNECT_COMPLETE:
202 rv = DoTunnelConnectComplete(rv);
203 break;
204 case STATE_SSL_CONNECT:
205 DCHECK_EQ(OK, rv);
206 rv = DoSSLConnect();
207 break;
208 case STATE_SSL_CONNECT_COMPLETE:
209 rv = DoSSLConnectComplete(rv);
210 break;
211 default:
212 NOTREACHED() << "bad state";
213 rv = ERR_FAILED;
214 break;
216 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
218 return rv;
221 int SSLConnectJob::DoTransportConnect() {
222 DCHECK(transport_pool_);
224 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE;
225 transport_socket_handle_.reset(new ClientSocketHandle());
226 scoped_refptr<TransportSocketParams> direct_params =
227 params_->GetDirectConnectionParams();
228 return transport_socket_handle_->Init(group_name(), direct_params, priority(),
229 callback_, transport_pool_, net_log());
232 int SSLConnectJob::DoTransportConnectComplete(int result) {
233 if (result == OK)
234 next_state_ = STATE_SSL_CONNECT;
236 return result;
239 int SSLConnectJob::DoSOCKSConnect() {
240 DCHECK(socks_pool_);
241 next_state_ = STATE_SOCKS_CONNECT_COMPLETE;
242 transport_socket_handle_.reset(new ClientSocketHandle());
243 scoped_refptr<SOCKSSocketParams> socks_proxy_params =
244 params_->GetSocksProxyConnectionParams();
245 return transport_socket_handle_->Init(group_name(), socks_proxy_params,
246 priority(), callback_, socks_pool_,
247 net_log());
250 int SSLConnectJob::DoSOCKSConnectComplete(int result) {
251 if (result == OK)
252 next_state_ = STATE_SSL_CONNECT;
254 return result;
257 int SSLConnectJob::DoTunnelConnect() {
258 DCHECK(http_proxy_pool_);
259 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE;
261 transport_socket_handle_.reset(new ClientSocketHandle());
262 scoped_refptr<HttpProxySocketParams> http_proxy_params =
263 params_->GetHttpProxyConnectionParams();
264 return transport_socket_handle_->Init(group_name(), http_proxy_params,
265 priority(), callback_, http_proxy_pool_,
266 net_log());
269 int SSLConnectJob::DoTunnelConnectComplete(int result) {
270 // Extract the information needed to prompt for appropriate proxy
271 // authentication so that when ClientSocketPoolBaseHelper calls
272 // |GetAdditionalErrorState|, we can easily set the state.
273 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
274 error_response_info_ = transport_socket_handle_->ssl_error_response_info();
275 } else if (result == ERR_PROXY_AUTH_REQUESTED ||
276 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
277 StreamSocket* socket = transport_socket_handle_->socket();
278 ProxyClientSocket* tunnel_socket = static_cast<ProxyClientSocket*>(socket);
279 error_response_info_ = *tunnel_socket->GetConnectResponseInfo();
281 if (result < 0)
282 return result;
284 next_state_ = STATE_SSL_CONNECT;
285 return result;
288 int SSLConnectJob::DoSSLConnect() {
289 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed.
290 tracked_objects::ScopedTracker tracking_profile(
291 FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect"));
293 next_state_ = STATE_SSL_CONNECT_COMPLETE;
295 // Reset the timeout to just the time allowed for the SSL handshake.
296 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds));
298 // If the handle has a fresh socket, get its connect start and DNS times.
299 // This should always be the case.
300 const LoadTimingInfo::ConnectTiming& socket_connect_timing =
301 transport_socket_handle_->connect_timing();
302 if (!transport_socket_handle_->is_reused() &&
303 !socket_connect_timing.connect_start.is_null()) {
304 // Overwriting |connect_start| serves two purposes - it adjusts timing so
305 // |connect_start| doesn't include dns times, and it adjusts the time so
306 // as not to include time spent waiting for an idle socket.
307 connect_timing_.connect_start = socket_connect_timing.connect_start;
308 connect_timing_.dns_start = socket_connect_timing.dns_start;
309 connect_timing_.dns_end = socket_connect_timing.dns_end;
312 connect_timing_.ssl_start = base::TimeTicks::Now();
314 ssl_socket_ = client_socket_factory_->CreateSSLClientSocket(
315 transport_socket_handle_.Pass(),
316 params_->host_and_port(),
317 params_->ssl_config(),
318 context_);
319 return ssl_socket_->Connect(callback_);
322 int SSLConnectJob::DoSSLConnectComplete(int result) {
323 connect_timing_.ssl_end = base::TimeTicks::Now();
325 SSLClientSocket::NextProtoStatus status =
326 SSLClientSocket::kNextProtoUnsupported;
327 std::string proto;
328 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket
329 // that hasn't had SSL_ImportFD called on it. If we get a certificate error
330 // here, then we know that we called SSL_ImportFD.
331 if (result == OK || IsCertificateError(result)) {
332 status = ssl_socket_->GetNextProto(&proto);
333 ssl_socket_->RecordNegotiationExtension();
336 // If we want spdy over npn, make sure it succeeded.
337 if (status == SSLClientSocket::kNextProtoNegotiated) {
338 ssl_socket_->set_was_npn_negotiated(true);
339 NextProto protocol_negotiated =
340 SSLClientSocket::NextProtoFromString(proto);
341 ssl_socket_->set_protocol_negotiated(protocol_negotiated);
342 // If we negotiated a SPDY version, it must have been present in
343 // SSLConfig::next_protos.
344 // TODO(mbelshe): Verify this.
345 if (protocol_negotiated >= kProtoSPDYMinimumVersion &&
346 protocol_negotiated <= kProtoSPDYMaximumVersion) {
347 ssl_socket_->set_was_spdy_negotiated(true);
350 if (params_->want_spdy_over_npn() && !ssl_socket_->was_spdy_negotiated())
351 return ERR_NPN_NEGOTIATION_FAILED;
353 // Spdy might be turned on by default, or it might be over npn.
354 bool using_spdy = params_->force_spdy_over_ssl() ||
355 params_->want_spdy_over_npn();
357 if (result == OK ||
358 ssl_socket_->IgnoreCertError(result, params_->load_flags())) {
359 DCHECK(!connect_timing_.ssl_start.is_null());
360 base::TimeDelta connect_duration =
361 connect_timing_.ssl_end - connect_timing_.ssl_start;
362 if (using_spdy) {
363 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SpdyConnectionLatency_2",
364 connect_duration,
365 base::TimeDelta::FromMilliseconds(1),
366 base::TimeDelta::FromMinutes(1),
367 100);
370 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_2",
371 connect_duration,
372 base::TimeDelta::FromMilliseconds(1),
373 base::TimeDelta::FromMinutes(1),
374 100);
376 SSLInfo ssl_info;
377 bool has_ssl_info = ssl_socket_->GetSSLInfo(&ssl_info);
378 DCHECK(has_ssl_info);
380 UMA_HISTOGRAM_ENUMERATION("Net.SSLVersion", SSLConnectionStatusToVersion(
381 ssl_info.connection_status),
382 SSL_CONNECTION_VERSION_MAX);
384 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_CipherSuite",
385 SSLConnectionStatusToCipherSuite(
386 ssl_info.connection_status));
388 UMA_HISTOGRAM_BOOLEAN(
389 "Net.RenegotiationExtensionSupported",
390 (ssl_info.connection_status &
391 SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) == 0);
393 if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_RESUME) {
394 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Resume_Handshake",
395 connect_duration,
396 base::TimeDelta::FromMilliseconds(1),
397 base::TimeDelta::FromMinutes(1),
398 100);
399 } else if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_FULL) {
400 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Full_Handshake",
401 connect_duration,
402 base::TimeDelta::FromMilliseconds(1),
403 base::TimeDelta::FromMinutes(1),
404 100);
407 const std::string& host = params_->host_and_port().host();
408 bool is_google =
409 host == "google.com" ||
410 (host.size() > 11 && host.rfind(".google.com") == host.size() - 11);
411 if (is_google) {
412 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google2",
413 connect_duration,
414 base::TimeDelta::FromMilliseconds(1),
415 base::TimeDelta::FromMinutes(1),
416 100);
417 if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_RESUME) {
418 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google_"
419 "Resume_Handshake",
420 connect_duration,
421 base::TimeDelta::FromMilliseconds(1),
422 base::TimeDelta::FromMinutes(1),
423 100);
424 } else if (ssl_info.handshake_type == SSLInfo::HANDSHAKE_FULL) {
425 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SSL_Connection_Latency_Google_"
426 "Full_Handshake",
427 connect_duration,
428 base::TimeDelta::FromMilliseconds(1),
429 base::TimeDelta::FromMinutes(1),
430 100);
435 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(result));
436 if (params_->ssl_config().fastradio_padding_eligible) {
437 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error_FastRadioPadding",
438 std::abs(result));
441 if (result == OK || IsCertificateError(result)) {
442 SetSocket(ssl_socket_.Pass());
443 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
444 error_response_info_.cert_request_info = new SSLCertRequestInfo;
445 ssl_socket_->GetSSLCertRequestInfo(
446 error_response_info_.cert_request_info.get());
449 return result;
452 SSLConnectJob::State SSLConnectJob::GetInitialState(
453 SSLSocketParams::ConnectionType connection_type) {
454 switch (connection_type) {
455 case SSLSocketParams::DIRECT:
456 return STATE_TRANSPORT_CONNECT;
457 case SSLSocketParams::HTTP_PROXY:
458 return STATE_TUNNEL_CONNECT;
459 case SSLSocketParams::SOCKS_PROXY:
460 return STATE_SOCKS_CONNECT;
462 NOTREACHED();
463 return STATE_NONE;
466 int SSLConnectJob::ConnectInternal() {
467 next_state_ = GetInitialState(params_->GetConnectionType());
468 return DoLoop(OK);
471 SSLClientSocketPool::SSLConnectJobFactory::SSLConnectJobFactory(
472 TransportClientSocketPool* transport_pool,
473 SOCKSClientSocketPool* socks_pool,
474 HttpProxyClientSocketPool* http_proxy_pool,
475 ClientSocketFactory* client_socket_factory,
476 const SSLClientSocketContext& context,
477 NetLog* net_log)
478 : transport_pool_(transport_pool),
479 socks_pool_(socks_pool),
480 http_proxy_pool_(http_proxy_pool),
481 client_socket_factory_(client_socket_factory),
482 context_(context),
483 net_log_(net_log) {
484 base::TimeDelta max_transport_timeout = base::TimeDelta();
485 base::TimeDelta pool_timeout;
486 if (transport_pool_)
487 max_transport_timeout = transport_pool_->ConnectionTimeout();
488 if (socks_pool_) {
489 pool_timeout = socks_pool_->ConnectionTimeout();
490 if (pool_timeout > max_transport_timeout)
491 max_transport_timeout = pool_timeout;
493 if (http_proxy_pool_) {
494 pool_timeout = http_proxy_pool_->ConnectionTimeout();
495 if (pool_timeout > max_transport_timeout)
496 max_transport_timeout = pool_timeout;
498 timeout_ = max_transport_timeout +
499 base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds);
502 SSLClientSocketPool::SSLConnectJobFactory::~SSLConnectJobFactory() {
505 SSLClientSocketPool::SSLClientSocketPool(
506 int max_sockets,
507 int max_sockets_per_group,
508 ClientSocketPoolHistograms* histograms,
509 CertVerifier* cert_verifier,
510 ChannelIDService* channel_id_service,
511 TransportSecurityState* transport_security_state,
512 CTVerifier* cert_transparency_verifier,
513 CertPolicyEnforcer* cert_policy_enforcer,
514 const std::string& ssl_session_cache_shard,
515 ClientSocketFactory* client_socket_factory,
516 TransportClientSocketPool* transport_pool,
517 SOCKSClientSocketPool* socks_pool,
518 HttpProxyClientSocketPool* http_proxy_pool,
519 SSLConfigService* ssl_config_service,
520 NetLog* net_log)
521 : transport_pool_(transport_pool),
522 socks_pool_(socks_pool),
523 http_proxy_pool_(http_proxy_pool),
524 base_(this,
525 max_sockets,
526 max_sockets_per_group,
527 histograms,
528 ClientSocketPool::unused_idle_socket_timeout(),
529 ClientSocketPool::used_idle_socket_timeout(),
530 new SSLConnectJobFactory(
531 transport_pool,
532 socks_pool,
533 http_proxy_pool,
534 client_socket_factory,
535 SSLClientSocketContext(cert_verifier,
536 channel_id_service,
537 transport_security_state,
538 cert_transparency_verifier,
539 cert_policy_enforcer,
540 ssl_session_cache_shard),
541 net_log)),
542 ssl_config_service_(ssl_config_service) {
543 if (ssl_config_service_.get())
544 ssl_config_service_->AddObserver(this);
545 if (transport_pool_)
546 base_.AddLowerLayeredPool(transport_pool_);
547 if (socks_pool_)
548 base_.AddLowerLayeredPool(socks_pool_);
549 if (http_proxy_pool_)
550 base_.AddLowerLayeredPool(http_proxy_pool_);
553 SSLClientSocketPool::~SSLClientSocketPool() {
554 if (ssl_config_service_.get())
555 ssl_config_service_->RemoveObserver(this);
558 scoped_ptr<ConnectJob> SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob(
559 const std::string& group_name,
560 const PoolBase::Request& request,
561 ConnectJob::Delegate* delegate) const {
562 return scoped_ptr<ConnectJob>(new SSLConnectJob(group_name,
563 request.priority(),
564 request.params(),
565 ConnectionTimeout(),
566 transport_pool_,
567 socks_pool_,
568 http_proxy_pool_,
569 client_socket_factory_,
570 context_,
571 delegate,
572 net_log_));
575 base::TimeDelta SSLClientSocketPool::SSLConnectJobFactory::ConnectionTimeout()
576 const {
577 return timeout_;
580 int SSLClientSocketPool::RequestSocket(const std::string& group_name,
581 const void* socket_params,
582 RequestPriority priority,
583 ClientSocketHandle* handle,
584 const CompletionCallback& callback,
585 const BoundNetLog& net_log) {
586 const scoped_refptr<SSLSocketParams>* casted_socket_params =
587 static_cast<const scoped_refptr<SSLSocketParams>*>(socket_params);
589 return base_.RequestSocket(group_name, *casted_socket_params, priority,
590 handle, callback, net_log);
593 void SSLClientSocketPool::RequestSockets(
594 const std::string& group_name,
595 const void* params,
596 int num_sockets,
597 const BoundNetLog& net_log) {
598 const scoped_refptr<SSLSocketParams>* casted_params =
599 static_cast<const scoped_refptr<SSLSocketParams>*>(params);
601 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log);
604 void SSLClientSocketPool::CancelRequest(const std::string& group_name,
605 ClientSocketHandle* handle) {
606 base_.CancelRequest(group_name, handle);
609 void SSLClientSocketPool::ReleaseSocket(const std::string& group_name,
610 scoped_ptr<StreamSocket> socket,
611 int id) {
612 base_.ReleaseSocket(group_name, socket.Pass(), id);
615 void SSLClientSocketPool::FlushWithError(int error) {
616 base_.FlushWithError(error);
619 void SSLClientSocketPool::CloseIdleSockets() {
620 base_.CloseIdleSockets();
623 int SSLClientSocketPool::IdleSocketCount() const {
624 return base_.idle_socket_count();
627 int SSLClientSocketPool::IdleSocketCountInGroup(
628 const std::string& group_name) const {
629 return base_.IdleSocketCountInGroup(group_name);
632 LoadState SSLClientSocketPool::GetLoadState(
633 const std::string& group_name, const ClientSocketHandle* handle) const {
634 return base_.GetLoadState(group_name, handle);
637 base::DictionaryValue* SSLClientSocketPool::GetInfoAsValue(
638 const std::string& name,
639 const std::string& type,
640 bool include_nested_pools) const {
641 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type);
642 if (include_nested_pools) {
643 base::ListValue* list = new base::ListValue();
644 if (transport_pool_) {
645 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool",
646 "transport_socket_pool",
647 false));
649 if (socks_pool_) {
650 list->Append(socks_pool_->GetInfoAsValue("socks_pool",
651 "socks_pool",
652 true));
654 if (http_proxy_pool_) {
655 list->Append(http_proxy_pool_->GetInfoAsValue("http_proxy_pool",
656 "http_proxy_pool",
657 true));
659 dict->Set("nested_pools", list);
661 return dict;
664 base::TimeDelta SSLClientSocketPool::ConnectionTimeout() const {
665 return base_.ConnectionTimeout();
668 ClientSocketPoolHistograms* SSLClientSocketPool::histograms() const {
669 return base_.histograms();
672 bool SSLClientSocketPool::IsStalled() const {
673 return base_.IsStalled();
676 void SSLClientSocketPool::AddHigherLayeredPool(HigherLayeredPool* higher_pool) {
677 base_.AddHigherLayeredPool(higher_pool);
680 void SSLClientSocketPool::RemoveHigherLayeredPool(
681 HigherLayeredPool* higher_pool) {
682 base_.RemoveHigherLayeredPool(higher_pool);
685 bool SSLClientSocketPool::CloseOneIdleConnection() {
686 if (base_.CloseOneIdleSocket())
687 return true;
688 return base_.CloseOneIdleConnectionInHigherLayeredPool();
691 void SSLClientSocketPool::OnSSLConfigChanged() {
692 FlushWithError(ERR_NETWORK_CHANGED);
695 } // namespace net