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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 HttpProxyClientSocketPool::HttpProxyClientSocketPool( | 418 HttpProxyClientSocketPool::HttpProxyClientSocketPool( |
419 int max_sockets, | 419 int max_sockets, |
420 int max_sockets_per_group, | 420 int max_sockets_per_group, |
421 ClientSocketPoolHistograms* histograms, | 421 ClientSocketPoolHistograms* histograms, |
422 HostResolver* host_resolver, | 422 HostResolver* host_resolver, |
423 TransportClientSocketPool* transport_pool, | 423 TransportClientSocketPool* transport_pool, |
424 SSLClientSocketPool* ssl_pool, | 424 SSLClientSocketPool* ssl_pool, |
425 NetLog* net_log) | 425 NetLog* net_log) |
426 : transport_pool_(transport_pool), | 426 : transport_pool_(transport_pool), |
427 ssl_pool_(ssl_pool), | 427 ssl_pool_(ssl_pool), |
428 base_(max_sockets, max_sockets_per_group, histograms, | 428 base_(this, max_sockets, max_sockets_per_group, histograms, |
429 ClientSocketPool::unused_idle_socket_timeout(), | 429 ClientSocketPool::unused_idle_socket_timeout(), |
430 ClientSocketPool::used_idle_socket_timeout(), | 430 ClientSocketPool::used_idle_socket_timeout(), |
431 new HttpProxyConnectJobFactory(transport_pool, | 431 new HttpProxyConnectJobFactory(transport_pool, |
432 ssl_pool, | 432 ssl_pool, |
433 host_resolver, | 433 host_resolver, |
434 net_log)) { | 434 net_log)) { |
435 // We should always have a |transport_pool_| except in unit tests. | 435 // We should always have a |transport_pool_| except in unit tests. |
436 if (transport_pool_) | 436 if (transport_pool_) |
437 transport_pool_->AddLayeredPool(this); | 437 base_.AddLowerLayeredPool(transport_pool_); |
438 if (ssl_pool_) | 438 if (ssl_pool_) |
439 ssl_pool_->AddLayeredPool(this); | 439 base_.AddLowerLayeredPool(ssl_pool_); |
440 } | 440 } |
441 | 441 |
442 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { | 442 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { |
443 if (ssl_pool_) | |
444 ssl_pool_->RemoveLayeredPool(this); | |
445 // We should always have a |transport_pool_| except in unit tests. | |
446 if (transport_pool_) | |
447 transport_pool_->RemoveLayeredPool(this); | |
448 } | 443 } |
449 | 444 |
450 int HttpProxyClientSocketPool::RequestSocket( | 445 int HttpProxyClientSocketPool::RequestSocket( |
451 const std::string& group_name, const void* socket_params, | 446 const std::string& group_name, const void* socket_params, |
452 RequestPriority priority, ClientSocketHandle* handle, | 447 RequestPriority priority, ClientSocketHandle* handle, |
453 const CompletionCallback& callback, const BoundNetLog& net_log) { | 448 const CompletionCallback& callback, const BoundNetLog& net_log) { |
454 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = | 449 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = |
455 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); | 450 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); |
456 | 451 |
457 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 452 return base_.RequestSocket(group_name, *casted_socket_params, priority, |
(...skipping 20 matching lines...) Expand all Loading... |
478 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, | 473 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, |
479 scoped_ptr<StreamSocket> socket, | 474 scoped_ptr<StreamSocket> socket, |
480 int id) { | 475 int id) { |
481 base_.ReleaseSocket(group_name, socket.Pass(), id); | 476 base_.ReleaseSocket(group_name, socket.Pass(), id); |
482 } | 477 } |
483 | 478 |
484 void HttpProxyClientSocketPool::FlushWithError(int error) { | 479 void HttpProxyClientSocketPool::FlushWithError(int error) { |
485 base_.FlushWithError(error); | 480 base_.FlushWithError(error); |
486 } | 481 } |
487 | 482 |
488 bool HttpProxyClientSocketPool::IsStalled() const { | |
489 return base_.IsStalled() || | |
490 (transport_pool_ && transport_pool_->IsStalled()) || | |
491 (ssl_pool_ && ssl_pool_->IsStalled()); | |
492 } | |
493 | |
494 void HttpProxyClientSocketPool::CloseIdleSockets() { | 483 void HttpProxyClientSocketPool::CloseIdleSockets() { |
495 base_.CloseIdleSockets(); | 484 base_.CloseIdleSockets(); |
496 } | 485 } |
497 | 486 |
498 int HttpProxyClientSocketPool::IdleSocketCount() const { | 487 int HttpProxyClientSocketPool::IdleSocketCount() const { |
499 return base_.idle_socket_count(); | 488 return base_.idle_socket_count(); |
500 } | 489 } |
501 | 490 |
502 int HttpProxyClientSocketPool::IdleSocketCountInGroup( | 491 int HttpProxyClientSocketPool::IdleSocketCountInGroup( |
503 const std::string& group_name) const { | 492 const std::string& group_name) const { |
504 return base_.IdleSocketCountInGroup(group_name); | 493 return base_.IdleSocketCountInGroup(group_name); |
505 } | 494 } |
506 | 495 |
507 LoadState HttpProxyClientSocketPool::GetLoadState( | 496 LoadState HttpProxyClientSocketPool::GetLoadState( |
508 const std::string& group_name, const ClientSocketHandle* handle) const { | 497 const std::string& group_name, const ClientSocketHandle* handle) const { |
509 return base_.GetLoadState(group_name, handle); | 498 return base_.GetLoadState(group_name, handle); |
510 } | 499 } |
511 | 500 |
512 void HttpProxyClientSocketPool::AddLayeredPool(LayeredPool* layered_pool) { | |
513 base_.AddLayeredPool(layered_pool); | |
514 } | |
515 | |
516 void HttpProxyClientSocketPool::RemoveLayeredPool(LayeredPool* layered_pool) { | |
517 base_.RemoveLayeredPool(layered_pool); | |
518 } | |
519 | |
520 base::DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( | 501 base::DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( |
521 const std::string& name, | 502 const std::string& name, |
522 const std::string& type, | 503 const std::string& type, |
523 bool include_nested_pools) const { | 504 bool include_nested_pools) const { |
524 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); | 505 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); |
525 if (include_nested_pools) { | 506 if (include_nested_pools) { |
526 base::ListValue* list = new base::ListValue(); | 507 base::ListValue* list = new base::ListValue(); |
527 if (transport_pool_) { | 508 if (transport_pool_) { |
528 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", | 509 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", |
529 "transport_socket_pool", | 510 "transport_socket_pool", |
(...skipping 10 matching lines...) Expand all Loading... |
540 } | 521 } |
541 | 522 |
542 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { | 523 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { |
543 return base_.ConnectionTimeout(); | 524 return base_.ConnectionTimeout(); |
544 } | 525 } |
545 | 526 |
546 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { | 527 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { |
547 return base_.histograms(); | 528 return base_.histograms(); |
548 } | 529 } |
549 | 530 |
| 531 bool HttpProxyClientSocketPool::IsStalled() const { |
| 532 return base_.IsStalled(); |
| 533 } |
| 534 |
| 535 void HttpProxyClientSocketPool::AddHigherLayeredPool( |
| 536 HigherLayeredPool* higher_pool) { |
| 537 base_.AddHigherLayeredPool(higher_pool); |
| 538 } |
| 539 |
| 540 void HttpProxyClientSocketPool::RemoveHigherLayeredPool( |
| 541 HigherLayeredPool* higher_pool) { |
| 542 base_.RemoveHigherLayeredPool(higher_pool); |
| 543 } |
| 544 |
550 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | 545 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { |
551 if (base_.CloseOneIdleSocket()) | 546 if (base_.CloseOneIdleSocket()) |
552 return true; | 547 return true; |
553 return base_.CloseOneIdleConnectionInLayeredPool(); | 548 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
554 } | 549 } |
555 | 550 |
556 } // namespace net | 551 } // namespace net |
OLD | NEW |