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