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/time.h" | 9 #include "base/time.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 SSLClientSocketPool* ssl_pool, | 390 SSLClientSocketPool* ssl_pool, |
391 NetLog* net_log) | 391 NetLog* net_log) |
392 : transport_pool_(transport_pool), | 392 : transport_pool_(transport_pool), |
393 ssl_pool_(ssl_pool), | 393 ssl_pool_(ssl_pool), |
394 base_(max_sockets, max_sockets_per_group, histograms, | 394 base_(max_sockets, max_sockets_per_group, histograms, |
395 ClientSocketPool::unused_idle_socket_timeout(), | 395 ClientSocketPool::unused_idle_socket_timeout(), |
396 ClientSocketPool::used_idle_socket_timeout(), | 396 ClientSocketPool::used_idle_socket_timeout(), |
397 new HttpProxyConnectJobFactory(transport_pool, | 397 new HttpProxyConnectJobFactory(transport_pool, |
398 ssl_pool, | 398 ssl_pool, |
399 host_resolver, | 399 host_resolver, |
400 net_log)) { | 400 net_log)) {} |
401 // We should always have a |transport_pool_| except in unit tests. | |
402 if (transport_pool_) | |
403 transport_pool_->AddLayeredPool(this); | |
404 if (ssl_pool_) | |
405 ssl_pool_->AddLayeredPool(this); | |
406 } | |
407 | 401 |
408 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { | 402 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() {} |
409 if (ssl_pool_) | |
410 ssl_pool_->RemoveLayeredPool(this); | |
411 // We should always have a |transport_pool_| except in unit tests. | |
412 if (transport_pool_) | |
413 transport_pool_->RemoveLayeredPool(this); | |
414 } | |
415 | 403 |
416 int HttpProxyClientSocketPool::RequestSocket( | 404 int HttpProxyClientSocketPool::RequestSocket( |
417 const std::string& group_name, const void* socket_params, | 405 const std::string& group_name, const void* socket_params, |
418 RequestPriority priority, ClientSocketHandle* handle, | 406 RequestPriority priority, ClientSocketHandle* handle, |
419 const CompletionCallback& callback, const BoundNetLog& net_log) { | 407 const CompletionCallback& callback, const BoundNetLog& net_log) { |
420 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = | 408 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = |
421 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); | 409 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); |
422 | 410 |
423 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 411 return base_.RequestSocket(group_name, *casted_socket_params, priority, |
424 handle, callback, net_log); | 412 handle, callback, net_log); |
(...skipping 18 matching lines...) Expand all Loading... |
443 | 431 |
444 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, | 432 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, |
445 StreamSocket* socket, int id) { | 433 StreamSocket* socket, int id) { |
446 base_.ReleaseSocket(group_name, socket, id); | 434 base_.ReleaseSocket(group_name, socket, id); |
447 } | 435 } |
448 | 436 |
449 void HttpProxyClientSocketPool::Flush() { | 437 void HttpProxyClientSocketPool::Flush() { |
450 base_.Flush(); | 438 base_.Flush(); |
451 } | 439 } |
452 | 440 |
453 bool HttpProxyClientSocketPool::IsStalled() const { | |
454 return base_.IsStalled() || | |
455 (transport_pool_ && transport_pool_->IsStalled()) || | |
456 (ssl_pool_ && ssl_pool_->IsStalled()); | |
457 } | |
458 | |
459 void HttpProxyClientSocketPool::CloseIdleSockets() { | 441 void HttpProxyClientSocketPool::CloseIdleSockets() { |
460 base_.CloseIdleSockets(); | 442 base_.CloseIdleSockets(); |
461 } | 443 } |
462 | 444 |
463 int HttpProxyClientSocketPool::IdleSocketCount() const { | 445 int HttpProxyClientSocketPool::IdleSocketCount() const { |
464 return base_.idle_socket_count(); | 446 return base_.idle_socket_count(); |
465 } | 447 } |
466 | 448 |
467 int HttpProxyClientSocketPool::IdleSocketCountInGroup( | 449 int HttpProxyClientSocketPool::IdleSocketCountInGroup( |
468 const std::string& group_name) const { | 450 const std::string& group_name) const { |
469 return base_.IdleSocketCountInGroup(group_name); | 451 return base_.IdleSocketCountInGroup(group_name); |
470 } | 452 } |
471 | 453 |
472 LoadState HttpProxyClientSocketPool::GetLoadState( | 454 LoadState HttpProxyClientSocketPool::GetLoadState( |
473 const std::string& group_name, const ClientSocketHandle* handle) const { | 455 const std::string& group_name, const ClientSocketHandle* handle) const { |
474 return base_.GetLoadState(group_name, handle); | 456 return base_.GetLoadState(group_name, handle); |
475 } | 457 } |
476 | 458 |
477 void HttpProxyClientSocketPool::AddLayeredPool(LayeredPool* layered_pool) { | |
478 base_.AddLayeredPool(layered_pool); | |
479 } | |
480 | |
481 void HttpProxyClientSocketPool::RemoveLayeredPool(LayeredPool* layered_pool) { | |
482 base_.RemoveLayeredPool(layered_pool); | |
483 } | |
484 | |
485 DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( | 459 DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( |
486 const std::string& name, | 460 const std::string& name, |
487 const std::string& type, | 461 const std::string& type, |
488 bool include_nested_pools) const { | 462 bool include_nested_pools) const { |
489 DictionaryValue* dict = base_.GetInfoAsValue(name, type); | 463 DictionaryValue* dict = base_.GetInfoAsValue(name, type); |
490 if (include_nested_pools) { | 464 if (include_nested_pools) { |
491 ListValue* list = new ListValue(); | 465 ListValue* list = new ListValue(); |
492 if (transport_pool_) { | 466 if (transport_pool_) { |
493 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", | 467 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", |
494 "transport_socket_pool", | 468 "transport_socket_pool", |
(...skipping 10 matching lines...) Expand all Loading... |
505 } | 479 } |
506 | 480 |
507 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { | 481 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { |
508 return base_.ConnectionTimeout(); | 482 return base_.ConnectionTimeout(); |
509 } | 483 } |
510 | 484 |
511 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { | 485 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { |
512 return base_.histograms(); | 486 return base_.histograms(); |
513 } | 487 } |
514 | 488 |
515 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | |
516 if (base_.CloseOneIdleSocket()) | |
517 return true; | |
518 return base_.CloseOneIdleConnectionInLayeredPool(); | |
519 } | |
520 | |
521 } // namespace net | 489 } // namespace net |
OLD | NEW |