summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 20:26:13 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 20:26:13 +0000
commit2431756ea7ceea7ac837522d948c3628cf83b647 (patch)
tree89e8921ce9f257f2dfeeb2491fb0ea246d4d1050 /net/http
parent252c50a4cdb5a9506938b231f4bd19afd5365757 (diff)
downloadchromium_src-2431756ea7ceea7ac837522d948c3628cf83b647.zip
chromium_src-2431756ea7ceea7ac837522d948c3628cf83b647.tar.gz
chromium_src-2431756ea7ceea7ac837522d948c3628cf83b647.tar.bz2
Stop refcounting ClientSocketPool.
Establishes that HttpNetworkSession owns all the socket pools. Move out all the socket pools into a ClientSocketPoolManager. This is because of the dependency tree amongst socket pools, which dictates the order in which they must be constructed and destructed. In order to better establish it, I moved them out to their own class. HttpNetworkSession owns the ClientSocketPoolManager which owns the pools. We pass the pools as raw pointers everywhere. Note that ClientSocketPoolManager owns more pools than are publicly accessible via its interface. That's because some of them are wrapped by publicly exposed pools. Also, ClientSocketPoolHistograms used to be reference counted. That's because it can be shared by multiple ClientSocketPools. But it's effectively a global as well, so I make their lifetimes persist for the length of ClientSocketPoolManager too. I also removed internal refcounting in ClientSocketPoolBase. I had refcounted it before I knew about ScopedRunnableMethodFactory back when I first started. I cleaned up the unit tests a lot. Back when I was a young padawan, I didn't really know what I was doing, so I copy/pasted a metric asston of code. Turns out most of it was stupid, so I fixed it. I also stopped the use of implementation inheritance with ClientSocketPoolTest because it's discouraged by the style guide and more importantly because it caused the ClientSocketHandles within the TestSocketRequest vector to be destroyed _after_ the pools themselves were destroyed, which is bad since the handles will call pool_->Release() which blows up. BUG=56215,56215 TEST=Existing unit tests Review URL: http://codereview.chromium.org/3389020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_cache.cc3
-rw-r--r--net/http/http_network_session.cc186
-rw-r--r--net/http/http_network_session.h99
-rw-r--r--net/http/http_network_transaction_unittest.cc62
-rw-r--r--net/http/http_proxy_client_socket_pool.cc25
-rw-r--r--net/http/http_proxy_client_socket_pool.h33
-rw-r--r--net/http/http_proxy_client_socket_pool_unittest.cc55
-rw-r--r--net/http/http_response_body_drainer_unittest.cc3
-rw-r--r--net/http/http_stream_request.cc10
9 files changed, 148 insertions, 328 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 2dd2347..2b2a221 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -392,8 +392,7 @@ void HttpCache::CloseCurrentConnections() {
static_cast<net::HttpNetworkLayer*>(network_layer_.get());
HttpNetworkSession* session = network->GetSession();
if (session) {
- session->ssl_socket_pool()->Flush();
- session->tcp_socket_pool()->Flush();
+ session->FlushSocketPools();
if (session->spdy_session_pool())
session->spdy_session_pool()->CloseCurrentSessions();
}
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
index 851956e..7b4fe0e 100644
--- a/net/http/http_network_session.cc
+++ b/net/http/http_network_session.cc
@@ -17,38 +17,6 @@
namespace net {
-namespace {
-
-// Total limit of sockets.
-int g_max_sockets = 256;
-
-// Default to allow up to 6 connections per host. Experiment and tuning may
-// try other values (greater than 0). Too large may cause many problems, such
-// as home routers blocking the connections!?!? See http://crbug.com/12066.
-int g_max_sockets_per_group = 6;
-
-// The max number of sockets to allow per proxy server. This applies both to
-// http and SOCKS proxies. See http://crbug.com/12066 and
-// http://crbug.com/44501 for details about proxy server connection limits.
-int g_max_sockets_per_proxy_server = 32;
-
-// Appends information about all |socket_pools| to the end of |list|.
-template <class MapType>
-static void AddSocketPoolsToList(ListValue* list,
- const MapType& socket_pools,
- const std::string& type,
- bool include_nested_pools) {
- typename MapType::const_iterator socket_pool_it = socket_pools.begin();
- for (typename MapType::const_iterator it = socket_pools.begin();
- it != socket_pools.end(); it++) {
- list->Append(it->second->GetInfoAsValue(it->first.ToString(),
- type,
- include_nested_pools));
- }
-}
-
-} // namespace
-
// TODO(mbelshe): Move the socket factories into HttpStreamFactory.
HttpNetworkSession::HttpNetworkSession(
HostResolver* host_resolver,
@@ -59,29 +27,15 @@ HttpNetworkSession::HttpNetworkSession(
HttpAuthHandlerFactory* http_auth_handler_factory,
HttpNetworkDelegate* network_delegate,
NetLog* net_log)
- : tcp_pool_histograms_(new ClientSocketPoolHistograms("TCP")),
- tcp_for_http_proxy_pool_histograms_(
- new ClientSocketPoolHistograms("TCPforHTTPProxy")),
- http_proxy_pool_histograms_(new ClientSocketPoolHistograms("HTTPProxy")),
- tcp_for_https_proxy_pool_histograms_(
- new ClientSocketPoolHistograms("TCPforHTTPSProxy")),
- ssl_for_https_proxy_pool_histograms_(
- new ClientSocketPoolHistograms("SSLforHTTPSProxy")),
- tcp_for_socks_pool_histograms_(
- new ClientSocketPoolHistograms("TCPforSOCKS")),
- socks_pool_histograms_(new ClientSocketPoolHistograms("SOCK")),
- ssl_pool_histograms_(new ClientSocketPoolHistograms("SSL")),
- tcp_socket_pool_(new TCPClientSocketPool(
- g_max_sockets, g_max_sockets_per_group, tcp_pool_histograms_,
- host_resolver, client_socket_factory, net_log)),
- ssl_socket_pool_(new SSLClientSocketPool(
- g_max_sockets, g_max_sockets_per_group, ssl_pool_histograms_,
- host_resolver, client_socket_factory, tcp_socket_pool_, NULL,
- NULL, ssl_config_service, net_log)),
- socket_factory_(client_socket_factory),
+ : socket_factory_(client_socket_factory),
host_resolver_(host_resolver),
proxy_service_(proxy_service),
ssl_config_service_(ssl_config_service),
+ socket_pool_manager_(net_log,
+ client_socket_factory,
+ host_resolver,
+ proxy_service,
+ ssl_config_service),
spdy_session_pool_(spdy_session_pool),
http_stream_factory_(new HttpStreamFactory()),
http_auth_handler_factory_(http_auth_handler_factory),
@@ -93,6 +47,7 @@ HttpNetworkSession::HttpNetworkSession(
HttpNetworkSession::~HttpNetworkSession() {
STLDeleteElements(&response_drainers_);
+ spdy_session_pool_->CloseAllSessions();
}
void HttpNetworkSession::AddResponseDrainer(HttpResponseBodyDrainer* drainer) {
@@ -106,131 +61,4 @@ void HttpNetworkSession::RemoveResponseDrainer(
response_drainers_.erase(drainer);
}
-const scoped_refptr<HttpProxyClientSocketPool>&
-HttpNetworkSession::GetSocketPoolForHTTPProxy(const HostPortPair& http_proxy) {
- HTTPProxySocketPoolMap::const_iterator it =
- http_proxy_socket_pools_.find(http_proxy);
- if (it != http_proxy_socket_pools_.end())
- return it->second;
-
- std::pair<HTTPProxySocketPoolMap::iterator, bool> ret =
- http_proxy_socket_pools_.insert(
- std::make_pair(
- http_proxy,
- new HttpProxyClientSocketPool(
- g_max_sockets_per_proxy_server, g_max_sockets_per_group,
- http_proxy_pool_histograms_, host_resolver_,
- new TCPClientSocketPool(
- g_max_sockets_per_proxy_server, g_max_sockets_per_group,
- tcp_for_http_proxy_pool_histograms_, host_resolver_,
- socket_factory_, net_log_),
- new SSLClientSocketPool(
- g_max_sockets_per_proxy_server, g_max_sockets_per_group,
- ssl_for_https_proxy_pool_histograms_, host_resolver_,
- socket_factory_,
- new TCPClientSocketPool(
- g_max_sockets_per_proxy_server,
- g_max_sockets_per_group,
- tcp_for_https_proxy_pool_histograms_, host_resolver_,
- socket_factory_, net_log_),
- NULL, NULL, ssl_config_service_, net_log_),
- net_log_)));
-
- return ret.first->second;
-}
-
-const scoped_refptr<SOCKSClientSocketPool>&
-HttpNetworkSession::GetSocketPoolForSOCKSProxy(
- const HostPortPair& socks_proxy) {
- SOCKSSocketPoolMap::const_iterator it = socks_socket_pools_.find(socks_proxy);
- if (it != socks_socket_pools_.end())
- return it->second;
-
- std::pair<SOCKSSocketPoolMap::iterator, bool> ret =
- socks_socket_pools_.insert(
- std::make_pair(socks_proxy, new SOCKSClientSocketPool(
- g_max_sockets_per_proxy_server, g_max_sockets_per_group,
- socks_pool_histograms_, host_resolver_,
- new TCPClientSocketPool(g_max_sockets_per_proxy_server,
- g_max_sockets_per_group, tcp_for_socks_pool_histograms_,
- host_resolver_, socket_factory_, net_log_),
- net_log_)));
-
- return ret.first->second;
-}
-
-const scoped_refptr<SSLClientSocketPool>&
-HttpNetworkSession::GetSocketPoolForSSLWithProxy(
- const HostPortPair& proxy_server) {
- SSLSocketPoolMap::const_iterator it =
- ssl_socket_pools_for_proxies_.find(proxy_server);
- if (it != ssl_socket_pools_for_proxies_.end())
- return it->second;
-
- SSLClientSocketPool* new_pool = new SSLClientSocketPool(
- g_max_sockets_per_proxy_server, g_max_sockets_per_group,
- ssl_pool_histograms_, host_resolver_, socket_factory_,
- NULL,
- GetSocketPoolForHTTPProxy(proxy_server),
- GetSocketPoolForSOCKSProxy(proxy_server),
- ssl_config_service_, net_log_);
-
- std::pair<SSLSocketPoolMap::iterator, bool> ret =
- ssl_socket_pools_for_proxies_.insert(std::make_pair(proxy_server,
- new_pool));
-
- return ret.first->second;
-}
-
-Value* HttpNetworkSession::SocketPoolInfoToValue() const {
- ListValue* list = new ListValue();
- list->Append(tcp_socket_pool_->GetInfoAsValue("tcp_socket_pool",
- "tcp_socket_pool",
- false));
- // Third parameter is false because |ssl_socket_pool_| uses |tcp_socket_pool_|
- // internally, and do not want to add it a second time.
- list->Append(ssl_socket_pool_->GetInfoAsValue("ssl_socket_pool",
- "ssl_socket_pool",
- false));
- AddSocketPoolsToList(list,
- http_proxy_socket_pools_,
- "http_proxy_socket_pool",
- true);
- AddSocketPoolsToList(list,
- socks_socket_pools_,
- "socks_socket_pool",
- true);
-
- // Third parameter is false because |ssl_socket_pools_for_proxies_| use
- // socket pools in |http_proxy_socket_pools_| and |socks_socket_pools_|.
- AddSocketPoolsToList(list,
- ssl_socket_pools_for_proxies_,
- "ssl_socket_pool_for_proxies",
- false);
- return list;
-}
-
-// static
-int HttpNetworkSession::max_sockets_per_group() {
- return g_max_sockets_per_group;
-}
-
-// static
-void HttpNetworkSession::set_max_sockets_per_group(int socket_count) {
- DCHECK_LT(0, socket_count);
- // The following is a sanity check... but we should NEVER be near this value.
- DCHECK_GT(100, socket_count);
- g_max_sockets_per_group = socket_count;
-}
-
-// static
-void HttpNetworkSession::set_max_sockets_per_proxy_server(int socket_count) {
- DCHECK_LT(0, socket_count);
- DCHECK_GT(100, socket_count); // Sanity check.
- // Assert this case early on. The max number of sockets per group cannot
- // exceed the max number of sockets per proxy server.
- DCHECK_LE(g_max_sockets_per_group, socket_count);
- g_max_sockets_per_proxy_server = socket_count;
-}
-
} // namespace net
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index dfa535b..3d1211c 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -19,23 +19,25 @@
#include "net/http/http_auth_cache.h"
#include "net/http/http_network_delegate.h"
#include "net/http/http_network_transaction.h"
-#include "net/http/http_proxy_client_socket_pool.h"
#include "net/http/http_stream_factory.h"
#include "net/proxy/proxy_service.h"
-#include "net/socket/client_socket_pool_histograms.h"
-#include "net/socket/socks_client_socket_pool.h"
-#include "net/socket/ssl_client_socket_pool.h"
-#include "net/socket/tcp_client_socket_pool.h"
+#include "net/socket/client_socket_pool_manager.h"
#include "net/spdy/spdy_settings_storage.h"
+class Value;
+
namespace net {
class ClientSocketFactory;
class HttpAuthHandlerFactory;
class HttpNetworkDelegate;
class HttpNetworkSessionPeer;
+class HttpProxyClientSocketPool;
class HttpResponseBodyDrainer;
class SpdySessionPool;
+class SOCKSClientSocketPool;
+class SSLClientSocketPool;
+class TCPClientSocketPool;
// This class holds session objects used by HttpNetworkTransaction objects.
class HttpNetworkSession : public base::RefCounted<HttpNetworkSession>,
@@ -75,23 +77,28 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession>,
return &spdy_settings_;
}
- // TCP sockets come from the tcp_socket_pool().
- const scoped_refptr<TCPClientSocketPool>& tcp_socket_pool() {
- return tcp_socket_pool_;
+ TCPClientSocketPool* tcp_socket_pool() {
+ return socket_pool_manager_.tcp_socket_pool();
}
- const scoped_refptr<SSLClientSocketPool>& ssl_socket_pool() {
- return ssl_socket_pool_;
+ SSLClientSocketPool* ssl_socket_pool() {
+ return socket_pool_manager_.ssl_socket_pool();
}
- const scoped_refptr<SOCKSClientSocketPool>& GetSocketPoolForSOCKSProxy(
- const HostPortPair& socks_proxy);
+ SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy(
+ const HostPortPair& socks_proxy) {
+ return socket_pool_manager_.GetSocketPoolForSOCKSProxy(socks_proxy);
+ }
- const scoped_refptr<HttpProxyClientSocketPool>& GetSocketPoolForHTTPProxy(
- const HostPortPair& http_proxy);
+ HttpProxyClientSocketPool* GetSocketPoolForHTTPProxy(
+ const HostPortPair& http_proxy) {
+ return socket_pool_manager_.GetSocketPoolForHTTPProxy(http_proxy);
+ }
- const scoped_refptr<SSLClientSocketPool>& GetSocketPoolForSSLWithProxy(
- const HostPortPair& proxy_server);
+ SSLClientSocketPool* GetSocketPoolForSSLWithProxy(
+ const HostPortPair& proxy_server) {
+ return socket_pool_manager_.GetSocketPoolForSSLWithProxy(proxy_server);
+ }
// SSL sockets come from the socket_factory().
ClientSocketFactory* socket_factory() { return socket_factory_; }
@@ -114,74 +121,28 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession>,
// Creates a Value summary of the state of the socket pools. The caller is
// responsible for deleting the returned value.
- Value* SocketPoolInfoToValue() const;
-
- static int max_sockets_per_group();
- static void set_max_sockets_per_group(int socket_count);
- static void set_max_sockets_per_proxy_server(int socket_count);
+ Value* SocketPoolInfoToValue() const {
+ return socket_pool_manager_.SocketPoolInfoToValue();
+ }
-#ifdef UNIT_TEST
void FlushSocketPools() {
- if (ssl_socket_pool_.get())
- ssl_socket_pool_->Flush();
- if (tcp_socket_pool_.get())
- tcp_socket_pool_->Flush();
-
- for (SSLSocketPoolMap::const_iterator it =
- ssl_socket_pools_for_proxies_.begin();
- it != ssl_socket_pools_for_proxies_.end();
- it++)
- it->second->Flush();
-
- for (SOCKSSocketPoolMap::const_iterator it =
- socks_socket_pools_.begin();
- it != socks_socket_pools_.end();
- it++)
- it->second->Flush();
-
- for (HTTPProxySocketPoolMap::const_iterator it =
- http_proxy_socket_pools_.begin();
- it != http_proxy_socket_pools_.end();
- it++)
- it->second->Flush();
- }
-#endif
+ socket_pool_manager_.FlushSocketPools();
+ }
private:
- typedef std::map<HostPortPair, scoped_refptr<HttpProxyClientSocketPool> >
- HTTPProxySocketPoolMap;
- typedef std::map<HostPortPair, scoped_refptr<SOCKSClientSocketPool> >
- SOCKSSocketPoolMap;
- typedef std::map<HostPortPair, scoped_refptr<SSLClientSocketPool> >
- SSLSocketPoolMap;
-
friend class base::RefCounted<HttpNetworkSession>;
friend class HttpNetworkSessionPeer;
~HttpNetworkSession();
+ ClientSocketFactory* const socket_factory_;
HttpAuthCache auth_cache_;
SSLClientAuthCache ssl_client_auth_cache_;
HttpAlternateProtocols alternate_protocols_;
- scoped_refptr<ClientSocketPoolHistograms> tcp_pool_histograms_;
- scoped_refptr<ClientSocketPoolHistograms> tcp_for_http_proxy_pool_histograms_;
- scoped_refptr<ClientSocketPoolHistograms> http_proxy_pool_histograms_;
- scoped_refptr<ClientSocketPoolHistograms>
- tcp_for_https_proxy_pool_histograms_;
- scoped_refptr<ClientSocketPoolHistograms>
- ssl_for_https_proxy_pool_histograms_;
- scoped_refptr<ClientSocketPoolHistograms> tcp_for_socks_pool_histograms_;
- scoped_refptr<ClientSocketPoolHistograms> socks_pool_histograms_;
- scoped_refptr<ClientSocketPoolHistograms> ssl_pool_histograms_;
- scoped_refptr<TCPClientSocketPool> tcp_socket_pool_;
- scoped_refptr<SSLClientSocketPool> ssl_socket_pool_;
- HTTPProxySocketPoolMap http_proxy_socket_pools_;
- SOCKSSocketPoolMap socks_socket_pools_;
- SSLSocketPoolMap ssl_socket_pools_for_proxies_;
- ClientSocketFactory* socket_factory_;
scoped_refptr<HostResolver> host_resolver_;
scoped_refptr<ProxyService> proxy_service_;
scoped_refptr<SSLConfigService> ssl_config_service_;
+ ClientSocketPoolManager socket_pool_manager_;
scoped_refptr<SpdySessionPool> spdy_session_pool_;
scoped_refptr<HttpStreamFactory> http_stream_factory_;
HttpAuthHandlerFactory* http_auth_handler_factory_;
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index b04a0a5..68e4038 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -72,30 +72,48 @@ class HttpNetworkSessionPeer {
const scoped_refptr<HttpNetworkSession>& session)
: session_(session) {}
- void SetTCPSocketPool(const scoped_refptr<TCPClientSocketPool>& pool) {
- session_->tcp_socket_pool_ = pool;
+ void SetTCPSocketPool(TCPClientSocketPool* pool) {
+ session_->socket_pool_manager_.tcp_socket_pool_.reset(pool);
}
void SetSocketPoolForSOCKSProxy(
const HostPortPair& socks_proxy,
- const scoped_refptr<SOCKSClientSocketPool>& pool) {
- session_->socks_socket_pools_[socks_proxy] = pool;
+ SOCKSClientSocketPool* pool) {
+ ClientSocketPoolManager* socket_pool_manager =
+ &session_->socket_pool_manager_;
+
+ // Call through the public interface to force initialization of the
+ // wrapped socket pools.
+ delete socket_pool_manager->GetSocketPoolForSOCKSProxy(socks_proxy);
+ socket_pool_manager->socks_socket_pools_[socks_proxy] = pool;
}
void SetSocketPoolForHTTPProxy(
const HostPortPair& http_proxy,
- const scoped_refptr<HttpProxyClientSocketPool>& pool) {
- session_->http_proxy_socket_pools_[http_proxy] = pool;
+ HttpProxyClientSocketPool* pool) {
+ ClientSocketPoolManager* socket_pool_manager =
+ &session_->socket_pool_manager_;
+
+ // Call through the public interface to force initialization of the
+ // wrapped socket pools.
+ delete socket_pool_manager->GetSocketPoolForHTTPProxy(http_proxy);
+ socket_pool_manager->http_proxy_socket_pools_[http_proxy] = pool;
}
- void SetSSLSocketPool(const scoped_refptr<SSLClientSocketPool>& pool) {
- session_->ssl_socket_pool_ = pool;
+ void SetSSLSocketPool(SSLClientSocketPool* pool) {
+ session_->socket_pool_manager_.ssl_socket_pool_.reset(pool);
}
void SetSocketPoolForSSLWithProxy(
const HostPortPair& proxy_host,
- const scoped_refptr<SSLClientSocketPool>& pool) {
- session_->ssl_socket_pools_for_proxies_[proxy_host] = pool;
+ SSLClientSocketPool* pool) {
+ ClientSocketPoolManager* socket_pool_manager =
+ &session_->socket_pool_manager_;
+
+ // Call through the public interface to force initialization of the
+ // wrapped socket pools.
+ delete socket_pool_manager->GetSocketPoolForSSLWithProxy(proxy_host);
+ socket_pool_manager->ssl_socket_pools_for_proxies_[proxy_host] = pool;
}
private:
@@ -4837,11 +4855,11 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForDirectConnections) {
SetupSessionForGroupNameTests(tests[i].proxy_server));
HttpNetworkSessionPeer peer(session);
- scoped_refptr<CaptureGroupNameTCPSocketPool> tcp_conn_pool(
- new CaptureGroupNameTCPSocketPool(session.get()));
+ CaptureGroupNameTCPSocketPool* tcp_conn_pool =
+ new CaptureGroupNameTCPSocketPool(session);
peer.SetTCPSocketPool(tcp_conn_pool);
- scoped_refptr<CaptureGroupNameSSLSocketPool> ssl_conn_pool(
- new CaptureGroupNameSSLSocketPool(session.get()));
+ CaptureGroupNameSSLSocketPool* ssl_conn_pool =
+ new CaptureGroupNameSSLSocketPool(session.get());
peer.SetSSLSocketPool(ssl_conn_pool);
EXPECT_EQ(ERR_IO_PENDING,
@@ -4891,11 +4909,11 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForHTTPProxyConnections) {
HttpNetworkSessionPeer peer(session);
HostPortPair proxy_host("http_proxy", 80);
- scoped_refptr<CaptureGroupNameHttpProxySocketPool> http_proxy_pool(
- new CaptureGroupNameHttpProxySocketPool(session.get()));
+ CaptureGroupNameHttpProxySocketPool* http_proxy_pool =
+ new CaptureGroupNameHttpProxySocketPool(session);
peer.SetSocketPoolForHTTPProxy(proxy_host, http_proxy_pool);
- scoped_refptr<CaptureGroupNameSSLSocketPool> ssl_conn_pool(
- new CaptureGroupNameSSLSocketPool(session.get()));
+ CaptureGroupNameSSLSocketPool* ssl_conn_pool =
+ new CaptureGroupNameSSLSocketPool(session);
peer.SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool);
EXPECT_EQ(ERR_IO_PENDING,
@@ -4956,11 +4974,11 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForSOCKSConnections) {
HttpNetworkSessionPeer peer(session);
HostPortPair proxy_host("socks_proxy", 1080);
- scoped_refptr<CaptureGroupNameSOCKSSocketPool> socks_conn_pool(
- new CaptureGroupNameSOCKSSocketPool(session.get()));
+ CaptureGroupNameSOCKSSocketPool* socks_conn_pool =
+ new CaptureGroupNameSOCKSSocketPool(session);
peer.SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool);
- scoped_refptr<CaptureGroupNameSSLSocketPool> ssl_conn_pool(
- new CaptureGroupNameSSLSocketPool(session.get()));
+ CaptureGroupNameSSLSocketPool* ssl_conn_pool =
+ new CaptureGroupNameSSLSocketPool(session);
peer.SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool);
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
diff --git a/net/http/http_proxy_client_socket_pool.cc b/net/http/http_proxy_client_socket_pool.cc
index 16f9597..fa49944 100644
--- a/net/http/http_proxy_client_socket_pool.cc
+++ b/net/http/http_proxy_client_socket_pool.cc
@@ -16,8 +16,9 @@
#include "net/socket/client_socket_factory.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/client_socket_pool_base.h"
-#include "net/socket/tcp_client_socket_pool.h"
#include "net/socket/ssl_client_socket.h"
+#include "net/socket/ssl_client_socket_pool.h"
+#include "net/socket/tcp_client_socket_pool.h"
namespace net {
@@ -59,8 +60,8 @@ HttpProxyConnectJob::HttpProxyConnectJob(
const std::string& group_name,
const scoped_refptr<HttpProxySocketParams>& params,
const base::TimeDelta& timeout_duration,
- const scoped_refptr<TCPClientSocketPool>& tcp_pool,
- const scoped_refptr<SSLClientSocketPool>& ssl_pool,
+ TCPClientSocketPool* tcp_pool,
+ SSLClientSocketPool* ssl_pool,
const scoped_refptr<HostResolver>& host_resolver,
Delegate* delegate,
NetLog* net_log)
@@ -237,8 +238,8 @@ int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) {
HttpProxyClientSocketPool::
HttpProxyConnectJobFactory::HttpProxyConnectJobFactory(
- const scoped_refptr<TCPClientSocketPool>& tcp_pool,
- const scoped_refptr<SSLClientSocketPool>& ssl_pool,
+ TCPClientSocketPool* tcp_pool,
+ SSLClientSocketPool* ssl_pool,
HostResolver* host_resolver,
NetLog* net_log)
: tcp_pool_(tcp_pool),
@@ -269,10 +270,10 @@ HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob(
HttpProxyClientSocketPool::HttpProxyClientSocketPool(
int max_sockets,
int max_sockets_per_group,
- const scoped_refptr<ClientSocketPoolHistograms>& histograms,
+ ClientSocketPoolHistograms* histograms,
const scoped_refptr<HostResolver>& host_resolver,
- const scoped_refptr<TCPClientSocketPool>& tcp_pool,
- const scoped_refptr<SSLClientSocketPool>& ssl_pool,
+ TCPClientSocketPool* tcp_pool,
+ SSLClientSocketPool* ssl_pool,
NetLog* net_log)
: tcp_pool_(tcp_pool),
ssl_pool_(ssl_pool),
@@ -311,10 +312,6 @@ void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name,
void HttpProxyClientSocketPool::Flush() {
base_.Flush();
- if (ssl_pool_)
- ssl_pool_->Flush();
- if (tcp_pool_)
- tcp_pool_->Flush();
}
void HttpProxyClientSocketPool::CloseIdleSockets() {
@@ -338,12 +335,12 @@ DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue(
DictionaryValue* dict = base_.GetInfoAsValue(name, type);
if (include_nested_pools) {
ListValue* list = new ListValue();
- if (tcp_pool_.get()) {
+ if (tcp_pool_) {
list->Append(tcp_pool_->GetInfoAsValue("tcp_socket_pool",
"tcp_socket_pool",
true));
}
- if (ssl_pool_.get()) {
+ if (ssl_pool_) {
list->Append(ssl_pool_->GetInfoAsValue("ssl_socket_pool",
"ssl_socket_pool",
true));
diff --git a/net/http/http_proxy_client_socket_pool.h b/net/http/http_proxy_client_socket_pool.h
index cfeb9a3..ea3c51f 100644
--- a/net/http/http_proxy_client_socket_pool.h
+++ b/net/http/http_proxy_client_socket_pool.h
@@ -82,8 +82,8 @@ class HttpProxyConnectJob : public ConnectJob {
HttpProxyConnectJob(const std::string& group_name,
const scoped_refptr<HttpProxySocketParams>& params,
const base::TimeDelta& timeout_duration,
- const scoped_refptr<TCPClientSocketPool>& tcp_pool,
- const scoped_refptr<SSLClientSocketPool>& ssl_pool,
+ TCPClientSocketPool* tcp_pool,
+ SSLClientSocketPool* ssl_pool,
const scoped_refptr<HostResolver> &host_resolver,
Delegate* delegate,
NetLog* net_log);
@@ -128,8 +128,8 @@ class HttpProxyConnectJob : public ConnectJob {
int DoHttpProxyConnectComplete(int result);
scoped_refptr<HttpProxySocketParams> params_;
- const scoped_refptr<TCPClientSocketPool> tcp_pool_;
- const scoped_refptr<SSLClientSocketPool> ssl_pool_;
+ TCPClientSocketPool* const tcp_pool_;
+ SSLClientSocketPool* const ssl_pool_;
const scoped_refptr<HostResolver> resolver_;
State next_state_;
@@ -146,12 +146,14 @@ class HttpProxyClientSocketPool : public ClientSocketPool {
HttpProxyClientSocketPool(
int max_sockets,
int max_sockets_per_group,
- const scoped_refptr<ClientSocketPoolHistograms>& histograms,
+ ClientSocketPoolHistograms* histograms,
const scoped_refptr<HostResolver>& host_resolver,
- const scoped_refptr<TCPClientSocketPool>& tcp_pool,
- const scoped_refptr<SSLClientSocketPool>& ssl_pool,
+ TCPClientSocketPool* tcp_pool,
+ SSLClientSocketPool* ssl_pool,
NetLog* net_log);
+ virtual ~HttpProxyClientSocketPool();
+
// ClientSocketPool methods:
virtual int RequestSocket(const std::string& group_name,
const void* connect_params,
@@ -188,21 +190,18 @@ class HttpProxyClientSocketPool : public ClientSocketPool {
return base_.ConnectionTimeout();
}
- virtual scoped_refptr<ClientSocketPoolHistograms> histograms() const {
+ virtual ClientSocketPoolHistograms* histograms() const {
return base_.histograms();
};
- protected:
- virtual ~HttpProxyClientSocketPool();
-
private:
typedef ClientSocketPoolBase<HttpProxySocketParams> PoolBase;
class HttpProxyConnectJobFactory : public PoolBase::ConnectJobFactory {
public:
HttpProxyConnectJobFactory(
- const scoped_refptr<TCPClientSocketPool>& tcp_pool,
- const scoped_refptr<SSLClientSocketPool>& ssl_pool,
+ TCPClientSocketPool* tcp_pool,
+ SSLClientSocketPool* ssl_pool,
HostResolver* host_resolver,
NetLog* net_log);
@@ -214,8 +213,8 @@ class HttpProxyClientSocketPool : public ClientSocketPool {
virtual base::TimeDelta ConnectionTimeout() const { return timeout_; }
private:
- const scoped_refptr<TCPClientSocketPool> tcp_pool_;
- const scoped_refptr<SSLClientSocketPool> ssl_pool_;
+ TCPClientSocketPool* const tcp_pool_;
+ SSLClientSocketPool* const ssl_pool_;
const scoped_refptr<HostResolver> host_resolver_;
NetLog* net_log_;
base::TimeDelta timeout_;
@@ -223,8 +222,8 @@ class HttpProxyClientSocketPool : public ClientSocketPool {
DISALLOW_COPY_AND_ASSIGN(HttpProxyConnectJobFactory);
};
- const scoped_refptr<TCPClientSocketPool> tcp_pool_;
- const scoped_refptr<SSLClientSocketPool> ssl_pool_;
+ TCPClientSocketPool* const tcp_pool_;
+ SSLClientSocketPool* const ssl_pool_;
PoolBase base_;
DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocketPool);
diff --git a/net/http/http_proxy_client_socket_pool_unittest.cc b/net/http/http_proxy_client_socket_pool_unittest.cc
index 6d03c19..4a68d9b 100644
--- a/net/http/http_proxy_client_socket_pool_unittest.cc
+++ b/net/http/http_proxy_client_socket_pool_unittest.cc
@@ -45,11 +45,16 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam {
ignored_ssl_socket_params_(new SSLSocketParams(
ignored_tcp_socket_params_, NULL, NULL, ProxyServer::SCHEME_DIRECT,
"host", ssl_config_, 0, false, false)),
- tcp_histograms_(new ClientSocketPoolHistograms("MockTCP")),
- tcp_socket_pool_(new MockTCPClientSocketPool(kMaxSockets,
- kMaxSocketsPerGroup, tcp_histograms_, &tcp_client_socket_factory_)),
- ssl_socket_pool_(new MockSSLClientSocketPool(kMaxSockets,
- kMaxSocketsPerGroup, tcp_histograms_, &tcp_client_socket_factory_)),
+ tcp_histograms_("MockTCP"),
+ tcp_socket_pool_(
+ kMaxSockets, kMaxSocketsPerGroup,
+ &tcp_histograms_,
+ &tcp_client_socket_factory_),
+ ssl_histograms_("MockSSL"),
+ ssl_socket_pool_(kMaxSockets, kMaxSocketsPerGroup,
+ &ssl_histograms_,
+ &tcp_client_socket_factory_,
+ &tcp_socket_pool_),
host_resolver_(new MockHostResolver),
http_auth_handler_factory_(
HttpAuthHandlerFactory::CreateDefault(host_resolver_)),
@@ -61,11 +66,16 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam {
http_auth_handler_factory_.get(),
NULL,
NULL)),
- http_proxy_histograms_(
- new ClientSocketPoolHistograms("HttpProxyUnitTest")),
- pool_(new HttpProxyClientSocketPool(kMaxSockets, kMaxSocketsPerGroup,
- http_proxy_histograms_, NULL, tcp_socket_pool_, ssl_socket_pool_,
- NULL)) {
+ http_proxy_histograms_("HttpProxyUnitTest"),
+ pool_(kMaxSockets, kMaxSocketsPerGroup,
+ &http_proxy_histograms_,
+ NULL,
+ &tcp_socket_pool_,
+ &ssl_socket_pool_,
+ NULL) {
+ }
+
+ virtual ~HttpProxyClientSocketPoolTest() {
}
void AddAuthToCache() {
@@ -114,17 +124,18 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam {
scoped_refptr<TCPSocketParams> ignored_tcp_socket_params_;
scoped_refptr<SSLSocketParams> ignored_ssl_socket_params_;
- scoped_refptr<ClientSocketPoolHistograms> tcp_histograms_;
+ ClientSocketPoolHistograms tcp_histograms_;
MockClientSocketFactory tcp_client_socket_factory_;
- scoped_refptr<MockTCPClientSocketPool> tcp_socket_pool_;
- scoped_refptr<MockSSLClientSocketPool> ssl_socket_pool_;
+ MockTCPClientSocketPool tcp_socket_pool_;
+ ClientSocketPoolHistograms ssl_histograms_;
+ MockSSLClientSocketPool ssl_socket_pool_;
MockClientSocketFactory socket_factory_;
scoped_refptr<HostResolver> host_resolver_;
scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_;
scoped_refptr<HttpNetworkSession> session_;
- scoped_refptr<ClientSocketPoolHistograms> http_proxy_histograms_;
- scoped_refptr<HttpProxyClientSocketPool> pool_;
+ ClientSocketPoolHistograms http_proxy_histograms_;
+ HttpProxyClientSocketPool pool_;
};
//-----------------------------------------------------------------------------
@@ -140,7 +151,7 @@ TEST_P(HttpProxyClientSocketPoolTest, NoTunnel) {
tcp_client_socket_factory_.AddSocketDataProvider(&data);
ClientSocketHandle handle;
- int rv = handle.Init("a", GetNoTunnelParams(), LOW, NULL, pool_,
+ int rv = handle.Init("a", GetNoTunnelParams(), LOW, NULL, &pool_,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_TRUE(handle.is_initialized());
@@ -170,7 +181,7 @@ TEST_P(HttpProxyClientSocketPoolTest, NeedAuth) {
ClientSocketHandle handle;
TestCompletionCallback callback;
- int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, pool_,
+ int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, &pool_,
BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
@@ -204,7 +215,7 @@ TEST_P(HttpProxyClientSocketPoolTest, HaveAuth) {
ClientSocketHandle handle;
TestCompletionCallback callback;
- int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, pool_,
+ int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, &pool_,
BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_TRUE(handle.is_initialized());
@@ -232,7 +243,7 @@ TEST_P(HttpProxyClientSocketPoolTest, AsyncHaveAuth) {
ClientSocketHandle handle;
TestCompletionCallback callback;
- int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, pool_,
+ int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, &pool_,
BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
@@ -254,7 +265,7 @@ TEST_P(HttpProxyClientSocketPoolTest, TCPError) {
ClientSocketHandle handle;
TestCompletionCallback callback;
- int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, pool_,
+ int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, &pool_,
BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
@@ -288,7 +299,7 @@ TEST_P(HttpProxyClientSocketPoolTest, TunnelUnexpectedClose) {
ClientSocketHandle handle;
TestCompletionCallback callback;
- int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, pool_,
+ int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, &pool_,
BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
@@ -317,7 +328,7 @@ TEST_P(HttpProxyClientSocketPoolTest, TunnelSetupError) {
ClientSocketHandle handle;
TestCompletionCallback callback;
- int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, pool_,
+ int rv = handle.Init("a", GetTunnelParams(), LOW, &callback, &pool_,
BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
diff --git a/net/http/http_response_body_drainer_unittest.cc b/net/http/http_response_body_drainer_unittest.cc
index 413324d..6226b98 100644
--- a/net/http/http_response_body_drainer_unittest.cc
+++ b/net/http/http_response_body_drainer_unittest.cc
@@ -16,6 +16,7 @@
#include "net/http/http_network_session.h"
#include "net/http/http_stream.h"
#include "net/proxy/proxy_service.h"
+#include "net/spdy/spdy_session_pool.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
@@ -173,7 +174,7 @@ class HttpResponseBodyDrainerTest : public testing::Test {
ProxyService::CreateDirect(),
NULL,
new SSLConfigServiceDefaults,
- NULL,
+ new SpdySessionPool(NULL),
NULL,
NULL,
NULL)),
diff --git a/net/http/http_stream_request.cc b/net/http/http_stream_request.cc
index 2761e1b..67aefb0 100644
--- a/net/http/http_stream_request.cc
+++ b/net/http/http_stream_request.cc
@@ -15,9 +15,15 @@
#include "net/http/http_basic_stream.h"
#include "net/http/http_network_session.h"
#include "net/http/http_proxy_client_socket.h"
+#include "net/http/http_proxy_client_socket_pool.h"
#include "net/http/http_request_info.h"
#include "net/socket/client_socket_handle.h"
+#include "net/socket/client_socket_handle.h"
+#include "net/socket/socks_client_socket_pool.h"
+#include "net/socket/ssl_client_socket.h"
#include "net/socket/ssl_client_socket.h"
+#include "net/socket/ssl_client_socket_pool.h"
+#include "net/socket/tcp_client_socket_pool.h"
#include "net/spdy/spdy_http_stream.h"
#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_session_pool.h"
@@ -536,7 +542,7 @@ int HttpStreamRequest::DoInitConnection() {
GenerateSslParams(tcp_params, http_proxy_params, socks_params,
proxy_info()->proxy_server().scheme(),
want_spdy_over_npn);
- scoped_refptr<SSLClientSocketPool> ssl_pool;
+ SSLClientSocketPool* ssl_pool = NULL;
if (proxy_info()->is_direct())
ssl_pool = session_->ssl_socket_pool();
else
@@ -803,7 +809,7 @@ scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSslParams(
}
scoped_refptr<SSLSocketParams> ssl_params =
- new SSLSocketParams(tcp_params, http_proxy_params, socks_params,
+ new SSLSocketParams(tcp_params, socks_params, http_proxy_params,
proxy_scheme, request_info().url.HostNoBrackets(),
*ssl_config(), load_flags,
force_spdy_always_ && force_spdy_over_ssl_,