| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 SSLClientSocketContext( | 472 SSLClientSocketContext( |
| 473 cert_verifier, | 473 cert_verifier, |
| 474 server_bound_cert_service, | 474 server_bound_cert_service, |
| 475 transport_security_state, | 475 transport_security_state, |
| 476 ssl_host_info_factory, | 476 ssl_host_info_factory, |
| 477 ssl_session_cache_shard), | 477 ssl_session_cache_shard), |
| 478 net_log)), | 478 net_log)), |
| 479 ssl_config_service_(ssl_config_service) { | 479 ssl_config_service_(ssl_config_service) { |
| 480 if (ssl_config_service_) | 480 if (ssl_config_service_) |
| 481 ssl_config_service_->AddObserver(this); | 481 ssl_config_service_->AddObserver(this); |
| 482 if (transport_pool_) | |
| 483 transport_pool_->AddLayeredPool(this); | |
| 484 if (socks_pool_) | |
| 485 socks_pool_->AddLayeredPool(this); | |
| 486 if (http_proxy_pool_) | |
| 487 http_proxy_pool_->AddLayeredPool(this); | |
| 488 } | 482 } |
| 489 | 483 |
| 490 SSLClientSocketPool::~SSLClientSocketPool() { | 484 SSLClientSocketPool::~SSLClientSocketPool() { |
| 491 if (http_proxy_pool_) | |
| 492 http_proxy_pool_->RemoveLayeredPool(this); | |
| 493 if (socks_pool_) | |
| 494 socks_pool_->RemoveLayeredPool(this); | |
| 495 if (transport_pool_) | |
| 496 transport_pool_->RemoveLayeredPool(this); | |
| 497 if (ssl_config_service_) | 485 if (ssl_config_service_) |
| 498 ssl_config_service_->RemoveObserver(this); | 486 ssl_config_service_->RemoveObserver(this); |
| 499 } | 487 } |
| 500 | 488 |
| 501 ConnectJob* SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob( | 489 ConnectJob* SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob( |
| 502 const std::string& group_name, | 490 const std::string& group_name, |
| 503 const PoolBase::Request& request, | 491 const PoolBase::Request& request, |
| 504 ConnectJob::Delegate* delegate) const { | 492 ConnectJob::Delegate* delegate) const { |
| 505 return new SSLConnectJob(group_name, request.params(), ConnectionTimeout(), | 493 return new SSLConnectJob(group_name, request.params(), ConnectionTimeout(), |
| 506 transport_pool_, socks_pool_, http_proxy_pool_, | 494 transport_pool_, socks_pool_, http_proxy_pool_, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 | 527 |
| 540 void SSLClientSocketPool::ReleaseSocket(const std::string& group_name, | 528 void SSLClientSocketPool::ReleaseSocket(const std::string& group_name, |
| 541 StreamSocket* socket, int id) { | 529 StreamSocket* socket, int id) { |
| 542 base_.ReleaseSocket(group_name, socket, id); | 530 base_.ReleaseSocket(group_name, socket, id); |
| 543 } | 531 } |
| 544 | 532 |
| 545 void SSLClientSocketPool::Flush() { | 533 void SSLClientSocketPool::Flush() { |
| 546 base_.Flush(); | 534 base_.Flush(); |
| 547 } | 535 } |
| 548 | 536 |
| 549 bool SSLClientSocketPool::IsStalled() const { | |
| 550 return base_.IsStalled() || | |
| 551 (transport_pool_ && transport_pool_->IsStalled()) || | |
| 552 (socks_pool_ && socks_pool_->IsStalled()) || | |
| 553 (http_proxy_pool_ && http_proxy_pool_->IsStalled()); | |
| 554 } | |
| 555 | |
| 556 void SSLClientSocketPool::CloseIdleSockets() { | 537 void SSLClientSocketPool::CloseIdleSockets() { |
| 557 base_.CloseIdleSockets(); | 538 base_.CloseIdleSockets(); |
| 558 } | 539 } |
| 559 | 540 |
| 560 int SSLClientSocketPool::IdleSocketCount() const { | 541 int SSLClientSocketPool::IdleSocketCount() const { |
| 561 return base_.idle_socket_count(); | 542 return base_.idle_socket_count(); |
| 562 } | 543 } |
| 563 | 544 |
| 564 int SSLClientSocketPool::IdleSocketCountInGroup( | 545 int SSLClientSocketPool::IdleSocketCountInGroup( |
| 565 const std::string& group_name) const { | 546 const std::string& group_name) const { |
| 566 return base_.IdleSocketCountInGroup(group_name); | 547 return base_.IdleSocketCountInGroup(group_name); |
| 567 } | 548 } |
| 568 | 549 |
| 569 LoadState SSLClientSocketPool::GetLoadState( | 550 LoadState SSLClientSocketPool::GetLoadState( |
| 570 const std::string& group_name, const ClientSocketHandle* handle) const { | 551 const std::string& group_name, const ClientSocketHandle* handle) const { |
| 571 return base_.GetLoadState(group_name, handle); | 552 return base_.GetLoadState(group_name, handle); |
| 572 } | 553 } |
| 573 | 554 |
| 574 void SSLClientSocketPool::AddLayeredPool(LayeredPool* layered_pool) { | |
| 575 base_.AddLayeredPool(layered_pool); | |
| 576 } | |
| 577 | |
| 578 void SSLClientSocketPool::RemoveLayeredPool(LayeredPool* layered_pool) { | |
| 579 base_.RemoveLayeredPool(layered_pool); | |
| 580 } | |
| 581 | |
| 582 DictionaryValue* SSLClientSocketPool::GetInfoAsValue( | 555 DictionaryValue* SSLClientSocketPool::GetInfoAsValue( |
| 583 const std::string& name, | 556 const std::string& name, |
| 584 const std::string& type, | 557 const std::string& type, |
| 585 bool include_nested_pools) const { | 558 bool include_nested_pools) const { |
| 586 DictionaryValue* dict = base_.GetInfoAsValue(name, type); | 559 DictionaryValue* dict = base_.GetInfoAsValue(name, type); |
| 587 if (include_nested_pools) { | 560 if (include_nested_pools) { |
| 588 ListValue* list = new ListValue(); | 561 ListValue* list = new ListValue(); |
| 589 if (transport_pool_) { | 562 if (transport_pool_) { |
| 590 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", | 563 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", |
| 591 "transport_socket_pool", | 564 "transport_socket_pool", |
| (...skipping 19 matching lines...) Expand all Loading... |
| 611 } | 584 } |
| 612 | 585 |
| 613 ClientSocketPoolHistograms* SSLClientSocketPool::histograms() const { | 586 ClientSocketPoolHistograms* SSLClientSocketPool::histograms() const { |
| 614 return base_.histograms(); | 587 return base_.histograms(); |
| 615 } | 588 } |
| 616 | 589 |
| 617 void SSLClientSocketPool::OnSSLConfigChanged() { | 590 void SSLClientSocketPool::OnSSLConfigChanged() { |
| 618 Flush(); | 591 Flush(); |
| 619 } | 592 } |
| 620 | 593 |
| 621 bool SSLClientSocketPool::CloseOneIdleConnection() { | |
| 622 if (base_.CloseOneIdleSocket()) | |
| 623 return true; | |
| 624 return base_.CloseOneIdleConnectionInLayeredPool(); | |
| 625 } | |
| 626 | |
| 627 } // namespace net | 594 } // namespace net |
| OLD | NEW |