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