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