Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: net/http/http_proxy_client_socket_pool.cc

Issue 18796003: When an idle socket is added back to a socket pool, check for stalled jobs in lower pools (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 HttpProxyClientSocketPool::HttpProxyClientSocketPool( 405 HttpProxyClientSocketPool::HttpProxyClientSocketPool(
406 int max_sockets, 406 int max_sockets,
407 int max_sockets_per_group, 407 int max_sockets_per_group,
408 ClientSocketPoolHistograms* histograms, 408 ClientSocketPoolHistograms* histograms,
409 HostResolver* host_resolver, 409 HostResolver* host_resolver,
410 TransportClientSocketPool* transport_pool, 410 TransportClientSocketPool* transport_pool,
411 SSLClientSocketPool* ssl_pool, 411 SSLClientSocketPool* ssl_pool,
412 NetLog* net_log) 412 NetLog* net_log)
413 : transport_pool_(transport_pool), 413 : transport_pool_(transport_pool),
414 ssl_pool_(ssl_pool), 414 ssl_pool_(ssl_pool),
415 base_(max_sockets, max_sockets_per_group, histograms, 415 base_(this, max_sockets, max_sockets_per_group, histograms,
416 ClientSocketPool::unused_idle_socket_timeout(), 416 ClientSocketPool::unused_idle_socket_timeout(),
417 ClientSocketPool::used_idle_socket_timeout(), 417 ClientSocketPool::used_idle_socket_timeout(),
418 new HttpProxyConnectJobFactory(transport_pool, 418 new HttpProxyConnectJobFactory(transport_pool,
419 ssl_pool, 419 ssl_pool,
420 host_resolver, 420 host_resolver,
421 net_log)) { 421 net_log)) {
422 // We should always have a |transport_pool_| except in unit tests. 422 // We should always have a |transport_pool_| except in unit tests.
423 if (transport_pool_) 423 if (transport_pool_)
424 transport_pool_->AddLayeredPool(this); 424 base_.AddLowerLayeredPool(transport_pool_);
425 if (ssl_pool_) 425 if (ssl_pool_)
426 ssl_pool_->AddLayeredPool(this); 426 base_.AddLowerLayeredPool(ssl_pool_);
427 } 427 }
428 428
429 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { 429 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() {
430 if (ssl_pool_)
431 ssl_pool_->RemoveLayeredPool(this);
432 // We should always have a |transport_pool_| except in unit tests.
433 if (transport_pool_)
434 transport_pool_->RemoveLayeredPool(this);
435 } 430 }
436 431
437 int HttpProxyClientSocketPool::RequestSocket( 432 int HttpProxyClientSocketPool::RequestSocket(
438 const std::string& group_name, const void* socket_params, 433 const std::string& group_name, const void* socket_params,
439 RequestPriority priority, ClientSocketHandle* handle, 434 RequestPriority priority, ClientSocketHandle* handle,
440 const CompletionCallback& callback, const BoundNetLog& net_log) { 435 const CompletionCallback& callback, const BoundNetLog& net_log) {
441 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = 436 const scoped_refptr<HttpProxySocketParams>* casted_socket_params =
442 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); 437 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params);
443 438
444 return base_.RequestSocket(group_name, *casted_socket_params, priority, 439 return base_.RequestSocket(group_name, *casted_socket_params, priority,
(...skipping 20 matching lines...) Expand all
465 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, 460 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name,
466 scoped_ptr<StreamSocket> socket, 461 scoped_ptr<StreamSocket> socket,
467 int id) { 462 int id) {
468 base_.ReleaseSocket(group_name, socket.Pass(), id); 463 base_.ReleaseSocket(group_name, socket.Pass(), id);
469 } 464 }
470 465
471 void HttpProxyClientSocketPool::FlushWithError(int error) { 466 void HttpProxyClientSocketPool::FlushWithError(int error) {
472 base_.FlushWithError(error); 467 base_.FlushWithError(error);
473 } 468 }
474 469
475 bool HttpProxyClientSocketPool::IsStalled() const {
476 return base_.IsStalled() ||
477 (transport_pool_ && transport_pool_->IsStalled()) ||
478 (ssl_pool_ && ssl_pool_->IsStalled());
479 }
480
481 void HttpProxyClientSocketPool::CloseIdleSockets() { 470 void HttpProxyClientSocketPool::CloseIdleSockets() {
482 base_.CloseIdleSockets(); 471 base_.CloseIdleSockets();
483 } 472 }
484 473
485 int HttpProxyClientSocketPool::IdleSocketCount() const { 474 int HttpProxyClientSocketPool::IdleSocketCount() const {
486 return base_.idle_socket_count(); 475 return base_.idle_socket_count();
487 } 476 }
488 477
489 int HttpProxyClientSocketPool::IdleSocketCountInGroup( 478 int HttpProxyClientSocketPool::IdleSocketCountInGroup(
490 const std::string& group_name) const { 479 const std::string& group_name) const {
491 return base_.IdleSocketCountInGroup(group_name); 480 return base_.IdleSocketCountInGroup(group_name);
492 } 481 }
493 482
494 LoadState HttpProxyClientSocketPool::GetLoadState( 483 LoadState HttpProxyClientSocketPool::GetLoadState(
495 const std::string& group_name, const ClientSocketHandle* handle) const { 484 const std::string& group_name, const ClientSocketHandle* handle) const {
496 return base_.GetLoadState(group_name, handle); 485 return base_.GetLoadState(group_name, handle);
497 } 486 }
498 487
499 void HttpProxyClientSocketPool::AddLayeredPool(LayeredPool* layered_pool) {
500 base_.AddLayeredPool(layered_pool);
501 }
502
503 void HttpProxyClientSocketPool::RemoveLayeredPool(LayeredPool* layered_pool) {
504 base_.RemoveLayeredPool(layered_pool);
505 }
506
507 base::DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( 488 base::DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue(
508 const std::string& name, 489 const std::string& name,
509 const std::string& type, 490 const std::string& type,
510 bool include_nested_pools) const { 491 bool include_nested_pools) const {
511 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); 492 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type);
512 if (include_nested_pools) { 493 if (include_nested_pools) {
513 base::ListValue* list = new base::ListValue(); 494 base::ListValue* list = new base::ListValue();
514 if (transport_pool_) { 495 if (transport_pool_) {
515 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", 496 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool",
516 "transport_socket_pool", 497 "transport_socket_pool",
(...skipping 10 matching lines...) Expand all
527 } 508 }
528 509
529 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { 510 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const {
530 return base_.ConnectionTimeout(); 511 return base_.ConnectionTimeout();
531 } 512 }
532 513
533 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { 514 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const {
534 return base_.histograms(); 515 return base_.histograms();
535 } 516 }
536 517
518 bool HttpProxyClientSocketPool::IsStalled() const {
519 return base_.IsStalled();
520 }
521
522 void HttpProxyClientSocketPool::AddHigherLayeredPool(
523 HigherLayeredPool* higher_pool) {
524 base_.AddHigherLayeredPool(higher_pool);
525 }
526
527 void HttpProxyClientSocketPool::RemoveHigherLayeredPool(
528 HigherLayeredPool* higher_pool) {
529 base_.RemoveHigherLayeredPool(higher_pool);
530 }
531
537 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { 532 bool HttpProxyClientSocketPool::CloseOneIdleConnection() {
538 if (base_.CloseOneIdleSocket()) 533 if (base_.CloseOneIdleSocket())
539 return true; 534 return true;
540 return base_.CloseOneIdleConnectionInLayeredPool(); 535 return base_.CloseOneIdleConnectionInHigherLayeredPool();
541 } 536 }
542 537
543 } // namespace net 538 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698