OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/ssl_client_socket_pool.h" | 5 #include "net/socket/ssl_client_socket_pool.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 const std::string& ssl_session_cache_shard, | 473 const std::string& ssl_session_cache_shard, |
474 ClientSocketFactory* client_socket_factory, | 474 ClientSocketFactory* client_socket_factory, |
475 TransportClientSocketPool* transport_pool, | 475 TransportClientSocketPool* transport_pool, |
476 SOCKSClientSocketPool* socks_pool, | 476 SOCKSClientSocketPool* socks_pool, |
477 HttpProxyClientSocketPool* http_proxy_pool, | 477 HttpProxyClientSocketPool* http_proxy_pool, |
478 SSLConfigService* ssl_config_service, | 478 SSLConfigService* ssl_config_service, |
479 NetLog* net_log) | 479 NetLog* net_log) |
480 : transport_pool_(transport_pool), | 480 : transport_pool_(transport_pool), |
481 socks_pool_(socks_pool), | 481 socks_pool_(socks_pool), |
482 http_proxy_pool_(http_proxy_pool), | 482 http_proxy_pool_(http_proxy_pool), |
483 base_(max_sockets, max_sockets_per_group, histograms, | 483 base_(this, max_sockets, max_sockets_per_group, histograms, |
484 ClientSocketPool::unused_idle_socket_timeout(), | 484 ClientSocketPool::unused_idle_socket_timeout(), |
485 ClientSocketPool::used_idle_socket_timeout(), | 485 ClientSocketPool::used_idle_socket_timeout(), |
486 new SSLConnectJobFactory(transport_pool, | 486 new SSLConnectJobFactory(transport_pool, |
487 socks_pool, | 487 socks_pool, |
488 http_proxy_pool, | 488 http_proxy_pool, |
489 client_socket_factory, | 489 client_socket_factory, |
490 host_resolver, | 490 host_resolver, |
491 SSLClientSocketContext( | 491 SSLClientSocketContext( |
492 cert_verifier, | 492 cert_verifier, |
493 server_bound_cert_service, | 493 server_bound_cert_service, |
494 transport_security_state, | 494 transport_security_state, |
495 ssl_session_cache_shard), | 495 ssl_session_cache_shard), |
496 net_log)), | 496 net_log)), |
497 ssl_config_service_(ssl_config_service) { | 497 ssl_config_service_(ssl_config_service) { |
498 if (ssl_config_service_.get()) | 498 if (ssl_config_service_.get()) |
499 ssl_config_service_->AddObserver(this); | 499 ssl_config_service_->AddObserver(this); |
500 if (transport_pool_) | 500 if (transport_pool_) |
501 transport_pool_->AddLayeredPool(this); | 501 base_.AddLowerLayeredPool(transport_pool_); |
502 if (socks_pool_) | 502 if (socks_pool_) |
503 socks_pool_->AddLayeredPool(this); | 503 base_.AddLowerLayeredPool(socks_pool_); |
504 if (http_proxy_pool_) | 504 if (http_proxy_pool_) |
505 http_proxy_pool_->AddLayeredPool(this); | 505 base_.AddLowerLayeredPool(http_proxy_pool_); |
506 } | 506 } |
507 | 507 |
508 SSLClientSocketPool::~SSLClientSocketPool() { | 508 SSLClientSocketPool::~SSLClientSocketPool() { |
509 if (http_proxy_pool_) | |
510 http_proxy_pool_->RemoveLayeredPool(this); | |
511 if (socks_pool_) | |
512 socks_pool_->RemoveLayeredPool(this); | |
513 if (transport_pool_) | |
514 transport_pool_->RemoveLayeredPool(this); | |
515 if (ssl_config_service_.get()) | 509 if (ssl_config_service_.get()) |
516 ssl_config_service_->RemoveObserver(this); | 510 ssl_config_service_->RemoveObserver(this); |
517 } | 511 } |
518 | 512 |
519 ConnectJob* SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob( | 513 ConnectJob* SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob( |
520 const std::string& group_name, | 514 const std::string& group_name, |
521 const PoolBase::Request& request, | 515 const PoolBase::Request& request, |
522 ConnectJob::Delegate* delegate) const { | 516 ConnectJob::Delegate* delegate) const { |
523 return new SSLConnectJob(group_name, request.params(), ConnectionTimeout(), | 517 return new SSLConnectJob(group_name, request.params(), ConnectionTimeout(), |
524 transport_pool_, socks_pool_, http_proxy_pool_, | 518 transport_pool_, socks_pool_, http_proxy_pool_, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 556 |
563 void SSLClientSocketPool::ReleaseSocket(const std::string& group_name, | 557 void SSLClientSocketPool::ReleaseSocket(const std::string& group_name, |
564 StreamSocket* socket, int id) { | 558 StreamSocket* socket, int id) { |
565 base_.ReleaseSocket(group_name, socket, id); | 559 base_.ReleaseSocket(group_name, socket, id); |
566 } | 560 } |
567 | 561 |
568 void SSLClientSocketPool::FlushWithError(int error) { | 562 void SSLClientSocketPool::FlushWithError(int error) { |
569 base_.FlushWithError(error); | 563 base_.FlushWithError(error); |
570 } | 564 } |
571 | 565 |
572 bool SSLClientSocketPool::IsStalled() const { | |
573 return base_.IsStalled() || | |
574 (transport_pool_ && transport_pool_->IsStalled()) || | |
575 (socks_pool_ && socks_pool_->IsStalled()) || | |
576 (http_proxy_pool_ && http_proxy_pool_->IsStalled()); | |
577 } | |
578 | |
579 void SSLClientSocketPool::CloseIdleSockets() { | 566 void SSLClientSocketPool::CloseIdleSockets() { |
580 base_.CloseIdleSockets(); | 567 base_.CloseIdleSockets(); |
581 } | 568 } |
582 | 569 |
583 int SSLClientSocketPool::IdleSocketCount() const { | 570 int SSLClientSocketPool::IdleSocketCount() const { |
584 return base_.idle_socket_count(); | 571 return base_.idle_socket_count(); |
585 } | 572 } |
586 | 573 |
587 int SSLClientSocketPool::IdleSocketCountInGroup( | 574 int SSLClientSocketPool::IdleSocketCountInGroup( |
588 const std::string& group_name) const { | 575 const std::string& group_name) const { |
589 return base_.IdleSocketCountInGroup(group_name); | 576 return base_.IdleSocketCountInGroup(group_name); |
590 } | 577 } |
591 | 578 |
592 LoadState SSLClientSocketPool::GetLoadState( | 579 LoadState SSLClientSocketPool::GetLoadState( |
593 const std::string& group_name, const ClientSocketHandle* handle) const { | 580 const std::string& group_name, const ClientSocketHandle* handle) const { |
594 return base_.GetLoadState(group_name, handle); | 581 return base_.GetLoadState(group_name, handle); |
595 } | 582 } |
596 | 583 |
597 void SSLClientSocketPool::AddLayeredPool(LayeredPool* layered_pool) { | |
598 base_.AddLayeredPool(layered_pool); | |
599 } | |
600 | |
601 void SSLClientSocketPool::RemoveLayeredPool(LayeredPool* layered_pool) { | |
602 base_.RemoveLayeredPool(layered_pool); | |
603 } | |
604 | |
605 base::DictionaryValue* SSLClientSocketPool::GetInfoAsValue( | 584 base::DictionaryValue* SSLClientSocketPool::GetInfoAsValue( |
606 const std::string& name, | 585 const std::string& name, |
607 const std::string& type, | 586 const std::string& type, |
608 bool include_nested_pools) const { | 587 bool include_nested_pools) const { |
609 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); | 588 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); |
610 if (include_nested_pools) { | 589 if (include_nested_pools) { |
611 base::ListValue* list = new base::ListValue(); | 590 base::ListValue* list = new base::ListValue(); |
612 if (transport_pool_) { | 591 if (transport_pool_) { |
613 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", | 592 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", |
614 "transport_socket_pool", | 593 "transport_socket_pool", |
(...skipping 15 matching lines...) Expand all Loading... |
630 } | 609 } |
631 | 610 |
632 base::TimeDelta SSLClientSocketPool::ConnectionTimeout() const { | 611 base::TimeDelta SSLClientSocketPool::ConnectionTimeout() const { |
633 return base_.ConnectionTimeout(); | 612 return base_.ConnectionTimeout(); |
634 } | 613 } |
635 | 614 |
636 ClientSocketPoolHistograms* SSLClientSocketPool::histograms() const { | 615 ClientSocketPoolHistograms* SSLClientSocketPool::histograms() const { |
637 return base_.histograms(); | 616 return base_.histograms(); |
638 } | 617 } |
639 | 618 |
| 619 bool SSLClientSocketPool::IsStalled() const { |
| 620 return base_.IsStalled(); |
| 621 } |
| 622 |
| 623 void SSLClientSocketPool::AddHigherLayeredPool(HigherLayeredPool* higher_pool) { |
| 624 base_.AddHigherLayeredPool(higher_pool); |
| 625 } |
| 626 |
| 627 void SSLClientSocketPool::RemoveHigherLayeredPool( |
| 628 HigherLayeredPool* higher_pool) { |
| 629 base_.RemoveHigherLayeredPool(higher_pool); |
| 630 } |
| 631 |
| 632 bool SSLClientSocketPool::CloseOneIdleConnection() { |
| 633 if (base_.CloseOneIdleSocket()) |
| 634 return true; |
| 635 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
| 636 } |
| 637 |
640 void SSLClientSocketPool::OnSSLConfigChanged() { | 638 void SSLClientSocketPool::OnSSLConfigChanged() { |
641 FlushWithError(ERR_NETWORK_CHANGED); | 639 FlushWithError(ERR_NETWORK_CHANGED); |
642 } | 640 } |
643 | 641 |
644 bool SSLClientSocketPool::CloseOneIdleConnection() { | |
645 if (base_.CloseOneIdleSocket()) | |
646 return true; | |
647 return base_.CloseOneIdleConnectionInLayeredPool(); | |
648 } | |
649 | |
650 } // namespace net | 642 } // namespace net |
OLD | NEW |