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/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" |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
(...skipping 372 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( | 398 int HttpProxyClientSocketPool::RequestSocket( |
411 const std::string& group_name, const void* socket_params, | 399 const std::string& group_name, const void* socket_params, |
412 RequestPriority priority, ClientSocketHandle* handle, | 400 RequestPriority priority, ClientSocketHandle* handle, |
413 const CompletionCallback& callback, const BoundNetLog& net_log) { | 401 const CompletionCallback& callback, const BoundNetLog& net_log) { |
414 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = | 402 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = |
415 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); | 403 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); |
416 | 404 |
417 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 405 return base_.RequestSocket(group_name, *casted_socket_params, priority, |
418 handle, callback, net_log); | 406 handle, callback, net_log); |
(...skipping 18 matching lines...) Expand all Loading... |
437 | 425 |
438 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, | 426 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, |
439 StreamSocket* socket, int id) { | 427 StreamSocket* socket, int id) { |
440 base_.ReleaseSocket(group_name, socket, id); | 428 base_.ReleaseSocket(group_name, socket, id); |
441 } | 429 } |
442 | 430 |
443 void HttpProxyClientSocketPool::Flush() { | 431 void HttpProxyClientSocketPool::Flush() { |
444 base_.Flush(); | 432 base_.Flush(); |
445 } | 433 } |
446 | 434 |
447 bool HttpProxyClientSocketPool::IsStalled() const { | |
448 return base_.IsStalled() || | |
449 (transport_pool_ && transport_pool_->IsStalled()) || | |
450 (ssl_pool_ && ssl_pool_->IsStalled()); | |
451 } | |
452 | |
453 void HttpProxyClientSocketPool::CloseIdleSockets() { | 435 void HttpProxyClientSocketPool::CloseIdleSockets() { |
454 base_.CloseIdleSockets(); | 436 base_.CloseIdleSockets(); |
455 } | 437 } |
456 | 438 |
457 int HttpProxyClientSocketPool::IdleSocketCount() const { | 439 int HttpProxyClientSocketPool::IdleSocketCount() const { |
458 return base_.idle_socket_count(); | 440 return base_.idle_socket_count(); |
459 } | 441 } |
460 | 442 |
461 int HttpProxyClientSocketPool::IdleSocketCountInGroup( | 443 int HttpProxyClientSocketPool::IdleSocketCountInGroup( |
462 const std::string& group_name) const { | 444 const std::string& group_name) const { |
463 return base_.IdleSocketCountInGroup(group_name); | 445 return base_.IdleSocketCountInGroup(group_name); |
464 } | 446 } |
465 | 447 |
466 LoadState HttpProxyClientSocketPool::GetLoadState( | 448 LoadState HttpProxyClientSocketPool::GetLoadState( |
467 const std::string& group_name, const ClientSocketHandle* handle) const { | 449 const std::string& group_name, const ClientSocketHandle* handle) const { |
468 return base_.GetLoadState(group_name, handle); | 450 return base_.GetLoadState(group_name, handle); |
469 } | 451 } |
470 | 452 |
471 void HttpProxyClientSocketPool::AddLayeredPool(LayeredPool* layered_pool) { | |
472 base_.AddLayeredPool(layered_pool); | |
473 } | |
474 | |
475 void HttpProxyClientSocketPool::RemoveLayeredPool(LayeredPool* layered_pool) { | |
476 base_.RemoveLayeredPool(layered_pool); | |
477 } | |
478 | |
479 DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( | 453 DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( |
480 const std::string& name, | 454 const std::string& name, |
481 const std::string& type, | 455 const std::string& type, |
482 bool include_nested_pools) const { | 456 bool include_nested_pools) const { |
483 DictionaryValue* dict = base_.GetInfoAsValue(name, type); | 457 DictionaryValue* dict = base_.GetInfoAsValue(name, type); |
484 if (include_nested_pools) { | 458 if (include_nested_pools) { |
485 ListValue* list = new ListValue(); | 459 ListValue* list = new ListValue(); |
486 if (transport_pool_) { | 460 if (transport_pool_) { |
487 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", | 461 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", |
488 "transport_socket_pool", | 462 "transport_socket_pool", |
(...skipping 10 matching lines...) Expand all Loading... |
499 } | 473 } |
500 | 474 |
501 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { | 475 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { |
502 return base_.ConnectionTimeout(); | 476 return base_.ConnectionTimeout(); |
503 } | 477 } |
504 | 478 |
505 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { | 479 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { |
506 return base_.histograms(); | 480 return base_.histograms(); |
507 } | 481 } |
508 | 482 |
509 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | |
510 if (base_.CloseOneIdleSocket()) | |
511 return true; | |
512 return base_.CloseOneIdleConnectionInLayeredPool(); | |
513 } | |
514 | |
515 } // namespace net | 483 } // namespace net |
OLD | NEW |