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