| 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/http/http_proxy_client_socket_pool.h" | 5 #include "net/http/http_proxy_client_socket_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 HttpProxyClientSocketPool::HttpProxyClientSocketPool( | 404 HttpProxyClientSocketPool::HttpProxyClientSocketPool( |
| 405 int max_sockets, | 405 int max_sockets, |
| 406 int max_sockets_per_group, | 406 int max_sockets_per_group, |
| 407 ClientSocketPoolHistograms* histograms, | 407 ClientSocketPoolHistograms* histograms, |
| 408 HostResolver* host_resolver, | 408 HostResolver* host_resolver, |
| 409 TransportClientSocketPool* transport_pool, | 409 TransportClientSocketPool* transport_pool, |
| 410 SSLClientSocketPool* ssl_pool, | 410 SSLClientSocketPool* ssl_pool, |
| 411 NetLog* net_log) | 411 NetLog* net_log) |
| 412 : transport_pool_(transport_pool), | 412 : transport_pool_(transport_pool), |
| 413 ssl_pool_(ssl_pool), | 413 ssl_pool_(ssl_pool), |
| 414 base_(max_sockets, max_sockets_per_group, histograms, | 414 base_(this, max_sockets, max_sockets_per_group, histograms, |
| 415 ClientSocketPool::unused_idle_socket_timeout(), | 415 ClientSocketPool::unused_idle_socket_timeout(), |
| 416 ClientSocketPool::used_idle_socket_timeout(), | 416 ClientSocketPool::used_idle_socket_timeout(), |
| 417 new HttpProxyConnectJobFactory(transport_pool, | 417 new HttpProxyConnectJobFactory(transport_pool, |
| 418 ssl_pool, | 418 ssl_pool, |
| 419 host_resolver, | 419 host_resolver, |
| 420 net_log)) { | 420 net_log)) { |
| 421 // We should always have a |transport_pool_| except in unit tests. | 421 // We should always have a |transport_pool_| except in unit tests. |
| 422 if (transport_pool_) | 422 if (transport_pool_) |
| 423 transport_pool_->AddLayeredPool(this); | 423 base_.AddLowerLayeredPool(transport_pool_); |
| 424 if (ssl_pool_) | 424 if (ssl_pool_) |
| 425 ssl_pool_->AddLayeredPool(this); | 425 base_.AddLowerLayeredPool(ssl_pool_); |
| 426 } | 426 } |
| 427 | 427 |
| 428 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { | 428 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { |
| 429 if (ssl_pool_) | |
| 430 ssl_pool_->RemoveLayeredPool(this); | |
| 431 // We should always have a |transport_pool_| except in unit tests. | |
| 432 if (transport_pool_) | |
| 433 transport_pool_->RemoveLayeredPool(this); | |
| 434 } | 429 } |
| 435 | 430 |
| 436 int HttpProxyClientSocketPool::RequestSocket( | 431 int HttpProxyClientSocketPool::RequestSocket( |
| 437 const std::string& group_name, const void* socket_params, | 432 const std::string& group_name, const void* socket_params, |
| 438 RequestPriority priority, ClientSocketHandle* handle, | 433 RequestPriority priority, ClientSocketHandle* handle, |
| 439 const CompletionCallback& callback, const BoundNetLog& net_log) { | 434 const CompletionCallback& callback, const BoundNetLog& net_log) { |
| 440 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = | 435 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = |
| 441 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); | 436 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); |
| 442 | 437 |
| 443 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 438 return base_.RequestSocket(group_name, *casted_socket_params, priority, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 463 | 458 |
| 464 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, | 459 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, |
| 465 StreamSocket* socket, int id) { | 460 StreamSocket* socket, int id) { |
| 466 base_.ReleaseSocket(group_name, socket, id); | 461 base_.ReleaseSocket(group_name, socket, id); |
| 467 } | 462 } |
| 468 | 463 |
| 469 void HttpProxyClientSocketPool::FlushWithError(int error) { | 464 void HttpProxyClientSocketPool::FlushWithError(int error) { |
| 470 base_.FlushWithError(error); | 465 base_.FlushWithError(error); |
| 471 } | 466 } |
| 472 | 467 |
| 473 bool HttpProxyClientSocketPool::IsStalled() const { | |
| 474 return base_.IsStalled() || | |
| 475 (transport_pool_ && transport_pool_->IsStalled()) || | |
| 476 (ssl_pool_ && ssl_pool_->IsStalled()); | |
| 477 } | |
| 478 | |
| 479 void HttpProxyClientSocketPool::CloseIdleSockets() { | 468 void HttpProxyClientSocketPool::CloseIdleSockets() { |
| 480 base_.CloseIdleSockets(); | 469 base_.CloseIdleSockets(); |
| 481 } | 470 } |
| 482 | 471 |
| 483 int HttpProxyClientSocketPool::IdleSocketCount() const { | 472 int HttpProxyClientSocketPool::IdleSocketCount() const { |
| 484 return base_.idle_socket_count(); | 473 return base_.idle_socket_count(); |
| 485 } | 474 } |
| 486 | 475 |
| 487 int HttpProxyClientSocketPool::IdleSocketCountInGroup( | 476 int HttpProxyClientSocketPool::IdleSocketCountInGroup( |
| 488 const std::string& group_name) const { | 477 const std::string& group_name) const { |
| 489 return base_.IdleSocketCountInGroup(group_name); | 478 return base_.IdleSocketCountInGroup(group_name); |
| 490 } | 479 } |
| 491 | 480 |
| 492 LoadState HttpProxyClientSocketPool::GetLoadState( | 481 LoadState HttpProxyClientSocketPool::GetLoadState( |
| 493 const std::string& group_name, const ClientSocketHandle* handle) const { | 482 const std::string& group_name, const ClientSocketHandle* handle) const { |
| 494 return base_.GetLoadState(group_name, handle); | 483 return base_.GetLoadState(group_name, handle); |
| 495 } | 484 } |
| 496 | 485 |
| 497 void HttpProxyClientSocketPool::AddLayeredPool(LayeredPool* layered_pool) { | |
| 498 base_.AddLayeredPool(layered_pool); | |
| 499 } | |
| 500 | |
| 501 void HttpProxyClientSocketPool::RemoveLayeredPool(LayeredPool* layered_pool) { | |
| 502 base_.RemoveLayeredPool(layered_pool); | |
| 503 } | |
| 504 | |
| 505 base::DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( | 486 base::DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( |
| 506 const std::string& name, | 487 const std::string& name, |
| 507 const std::string& type, | 488 const std::string& type, |
| 508 bool include_nested_pools) const { | 489 bool include_nested_pools) const { |
| 509 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); | 490 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); |
| 510 if (include_nested_pools) { | 491 if (include_nested_pools) { |
| 511 base::ListValue* list = new base::ListValue(); | 492 base::ListValue* list = new base::ListValue(); |
| 512 if (transport_pool_) { | 493 if (transport_pool_) { |
| 513 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", | 494 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", |
| 514 "transport_socket_pool", | 495 "transport_socket_pool", |
| (...skipping 10 matching lines...) Expand all Loading... |
| 525 } | 506 } |
| 526 | 507 |
| 527 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { | 508 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { |
| 528 return base_.ConnectionTimeout(); | 509 return base_.ConnectionTimeout(); |
| 529 } | 510 } |
| 530 | 511 |
| 531 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { | 512 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { |
| 532 return base_.histograms(); | 513 return base_.histograms(); |
| 533 } | 514 } |
| 534 | 515 |
| 516 bool HttpProxyClientSocketPool::IsStalled() const { |
| 517 return base_.IsStalled(); |
| 518 } |
| 519 |
| 520 void HttpProxyClientSocketPool::AddHigherLayeredPool( |
| 521 HigherLayeredPool* higher_pool) { |
| 522 base_.AddHigherLayeredPool(higher_pool); |
| 523 } |
| 524 |
| 525 void HttpProxyClientSocketPool::RemoveHigherLayeredPool( |
| 526 HigherLayeredPool* higher_pool) { |
| 527 base_.RemoveHigherLayeredPool(higher_pool); |
| 528 } |
| 529 |
| 535 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | 530 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { |
| 536 if (base_.CloseOneIdleSocket()) | 531 if (base_.CloseOneIdleSocket()) |
| 537 return true; | 532 return true; |
| 538 return base_.CloseOneIdleConnectionInLayeredPool(); | 533 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
| 539 } | 534 } |
| 540 | 535 |
| 541 } // namespace net | 536 } // namespace net |
| OLD | NEW |