summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-17 05:35:06 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-17 05:35:06 +0000
commitd510a78cd1aef9c2bdc692c79bae4a89f4851a98 (patch)
tree1a81aa485c053d3e66ca3ba79f5563838e63ba85 /net
parenta05725888f71e72e3335d265e47643fd2768e39f (diff)
downloadchromium_src-d510a78cd1aef9c2bdc692c79bae4a89f4851a98.zip
chromium_src-d510a78cd1aef9c2bdc692c79bae4a89f4851a98.tar.gz
chromium_src-d510a78cd1aef9c2bdc692c79bae4a89f4851a98.tar.bz2
This is roughly a reland of r43908, although I had to rewrite a fair chunk since code's changed a lot. I've changed it so as not to flush the host resolver too. I suspect there might have been a bug there. I was unable to reproduce the crash here on network change, so I think either that fixed it or something else changed under the hood. In any case, I want to reland this and see if anyone encounters any problems with it.
BUG=40455,40457 Review URL: http://codereview.chromium.org/2114004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47395 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_cache.cc2
-rw-r--r--net/http/http_network_layer.cc3
-rw-r--r--net/http/http_network_session.cc62
-rw-r--r--net/http/http_network_session.h23
-rw-r--r--net/http/http_network_session_unittest.cc103
-rw-r--r--net/http/http_network_transaction_unittest.cc11
-rw-r--r--net/net.gyp1
-rw-r--r--net/socket/client_socket_pool_base.cc14
-rw-r--r--net/socket/client_socket_pool_base.h18
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc4
-rw-r--r--net/socket/socks_client_socket_pool.cc6
-rw-r--r--net/socket/socks_client_socket_pool.h3
-rw-r--r--net/socket/socks_client_socket_pool_unittest.cc12
-rw-r--r--net/socket/tcp_client_socket_pool.cc6
-rw-r--r--net/socket/tcp_client_socket_pool.h3
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc35
-rw-r--r--net/spdy/spdy_network_transaction_unittest.cc1
-rw-r--r--net/spdy/spdy_session_unittest.cc1
-rw-r--r--net/spdy/spdy_stream_unittest.cc1
19 files changed, 182 insertions, 127 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index d6624be..5f3c0dc 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -411,7 +411,7 @@ void HttpCache::CloseCurrentConnections() {
session->tcp_socket_pool()->CloseIdleSockets();
if (session->spdy_session_pool())
session->spdy_session_pool()->CloseAllSessions();
- session->ReplaceTCPSocketPool();
+ session->Flush();
}
}
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 09ee5cd..d5ae8e3 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -103,10 +103,9 @@ void HttpNetworkLayer::Suspend(bool suspend) {
HttpNetworkSession* HttpNetworkLayer::GetSession() {
if (!session_) {
DCHECK(proxy_service_);
- SpdySessionPool* spdy_pool = new SpdySessionPool;
session_ = new HttpNetworkSession(
network_change_notifier_, host_resolver_, proxy_service_,
- socket_factory_, ssl_config_service_, spdy_pool,
+ socket_factory_, ssl_config_service_,
http_auth_handler_factory_);
// These were just temps for lazy-initializing HttpNetworkSession.
network_change_notifier_ = NULL;
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
index 2d05a55..7899828 100644
--- a/net/http/http_network_session.cc
+++ b/net/http/http_network_session.cc
@@ -35,31 +35,61 @@ uint16 g_fixed_https_port = 0;
} // namespace
-// TODO(vandebo) when we've completely converted to pools, the base TCP
-// pool name should get changed to TCP instead of Transport.
HttpNetworkSession::HttpNetworkSession(
NetworkChangeNotifier* network_change_notifier,
HostResolver* host_resolver,
ProxyService* proxy_service,
ClientSocketFactory* client_socket_factory,
SSLConfigService* ssl_config_service,
- SpdySessionPool* spdy_session_pool,
HttpAuthHandlerFactory* http_auth_handler_factory)
: network_change_notifier_(network_change_notifier),
- tcp_socket_pool_(new TCPClientSocketPool(
- g_max_sockets, g_max_sockets_per_group, "Transport",
- host_resolver, client_socket_factory, network_change_notifier_)),
socket_factory_(client_socket_factory),
host_resolver_(host_resolver),
+ tcp_socket_pool_(CreateNewTCPSocketPool()),
proxy_service_(proxy_service),
ssl_config_service_(ssl_config_service),
- spdy_session_pool_(spdy_session_pool),
+ spdy_session_pool_(new SpdySessionPool),
http_auth_handler_factory_(http_auth_handler_factory) {
DCHECK(proxy_service);
DCHECK(ssl_config_service);
+
+ if (network_change_notifier_)
+ network_change_notifier_->AddObserver(this);
}
HttpNetworkSession::~HttpNetworkSession() {
+ if (network_change_notifier_)
+ network_change_notifier_->RemoveObserver(this);
+}
+
+void HttpNetworkSession::OnIPAddressChanged() {
+ Flush();
+}
+
+void HttpNetworkSession::Flush() {
+ // TODO(willchan): Flush |host_resolver_|.
+ tcp_socket_pool()->CloseIdleSockets();
+ tcp_socket_pool_ = CreateNewTCPSocketPool();
+ for (HTTPProxySocketPoolMap::iterator it = http_proxy_socket_pool_.begin();
+ it != http_proxy_socket_pool_.end(); ++it)
+ it->second->CloseIdleSockets();
+ http_proxy_socket_pool_.clear();
+ for (SOCKSSocketPoolMap::iterator it = socks_socket_pool_.begin();
+ it != socks_socket_pool_.end(); ++it)
+ it->second->CloseIdleSockets();
+ socks_socket_pool_.clear();
+ spdy_session_pool_ = new SpdySessionPool;
+}
+
+scoped_refptr<TCPClientSocketPool>
+HttpNetworkSession::CreateNewTCPSocketPool() {
+ // TODO(vandebo) when we've completely converted to pools, the base TCP
+ // pool name should get changed to TCP instead of Transport.
+ return new TCPClientSocketPool(g_max_sockets,
+ g_max_sockets_per_group,
+ "Transport",
+ host_resolver_,
+ socket_factory_);
}
const scoped_refptr<TCPClientSocketPool>&
@@ -75,8 +105,7 @@ HttpNetworkSession::GetSocketPoolForHTTPProxy(const HostPortPair& http_proxy) {
http_proxy,
new TCPClientSocketPool(
g_max_sockets_per_proxy_server, g_max_sockets_per_group,
- "HTTPProxy", host_resolver_, socket_factory_,
- network_change_notifier_)));
+ "HTTPProxy", host_resolver_, socket_factory_)));
return ret.first->second;
}
@@ -98,9 +127,7 @@ HttpNetworkSession::GetSocketPoolForSOCKSProxy(
new TCPClientSocketPool(g_max_sockets_per_proxy_server,
g_max_sockets_per_group,
"TCPForSOCKS", host_resolver_,
- socket_factory_,
- network_change_notifier_),
- network_change_notifier_)));
+ socket_factory_))));
return ret.first->second;
}
@@ -133,15 +160,4 @@ void HttpNetworkSession::set_fixed_https_port(uint16 port) {
g_fixed_https_port = port;
}
-// TODO(vandebo) when we've completely converted to pools, the base TCP
-// pool name should get changed to TCP instead of Transport.
-void HttpNetworkSession::ReplaceTCPSocketPool() {
- tcp_socket_pool_ = new TCPClientSocketPool(g_max_sockets,
- g_max_sockets_per_group,
- "Transport",
- host_resolver_,
- socket_factory_,
- network_change_notifier_);
-}
-
} // namespace net
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index 9674b21..b8edd71 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -10,6 +10,7 @@
#include "base/scoped_ptr.h"
#include "net/base/host_port_pair.h"
#include "net/base/host_resolver.h"
+#include "net/base/network_change_notifier.h"
#include "net/base/ssl_client_auth_cache.h"
#include "net/base/ssl_config_service.h"
#include "net/http/http_alternate_protocols.h"
@@ -28,7 +29,9 @@ class NetworkChangeNotifier;
class SpdySessionPool;
// This class holds session objects used by HttpNetworkTransaction objects.
-class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
+class HttpNetworkSession
+ : public base::RefCounted<HttpNetworkSession>,
+ public NetworkChangeNotifier::Observer {
public:
HttpNetworkSession(
NetworkChangeNotifier* network_change_notifier,
@@ -36,9 +39,15 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
ProxyService* proxy_service,
ClientSocketFactory* client_socket_factory,
SSLConfigService* ssl_config_service,
- SpdySessionPool* spdy_session_pool,
HttpAuthHandlerFactory* http_auth_handler_factory);
+ // NetworkChangeNotifier::Observer methods:
+ virtual void OnIPAddressChanged();
+
+ // Flushes cached data in the HttpNetworkSession. Typically called on IP
+ // address change.
+ void Flush();
+
HttpAuthCache* auth_cache() { return &auth_cache_; }
SSLClientAuthCache* ssl_client_auth_cache() {
return &ssl_client_auth_cache_;
@@ -82,10 +91,6 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
return http_auth_handler_factory_;
}
- // Replace the current socket pool with a new one. This effectively
- // abandons the current pool. This is only used for debugging.
- void ReplaceTCPSocketPool();
-
static void set_max_sockets_per_group(int socket_count);
static uint16 fixed_http_port();
@@ -105,15 +110,17 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
~HttpNetworkSession();
+ scoped_refptr<TCPClientSocketPool> CreateNewTCPSocketPool();
+
HttpAuthCache auth_cache_;
SSLClientAuthCache ssl_client_auth_cache_;
HttpAlternateProtocols alternate_protocols_;
NetworkChangeNotifier* const network_change_notifier_;
+ ClientSocketFactory* socket_factory_;
+ scoped_refptr<HostResolver> host_resolver_;
scoped_refptr<TCPClientSocketPool> tcp_socket_pool_;
HTTPProxySocketPoolMap http_proxy_socket_pool_;
SOCKSSocketPoolMap socks_socket_pool_;
- ClientSocketFactory* socket_factory_;
- scoped_refptr<HostResolver> host_resolver_;
scoped_refptr<ProxyService> proxy_service_;
scoped_refptr<SSLConfigService> ssl_config_service_;
scoped_refptr<SpdySessionPool> spdy_session_pool_;
diff --git a/net/http/http_network_session_unittest.cc b/net/http/http_network_session_unittest.cc
new file mode 100644
index 0000000..6601a32
--- /dev/null
+++ b/net/http/http_network_session_unittest.cc
@@ -0,0 +1,103 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http/http_network_session.h"
+
+#include "base/ref_counted.h"
+#include "net/base/mock_host_resolver.h"
+#include "net/base/mock_network_change_notifier.h"
+#include "net/base/ssl_config_service_defaults.h"
+#include "net/base/test_completion_callback.h"
+#include "net/http/http_auth_handler_factory.h"
+#include "net/proxy/proxy_service.h"
+#include "net/socket/client_socket_handle.h"
+#include "net/socket/socket_test_util.h"
+#include "net/socket/tcp_client_socket_pool.h"
+#include "net/spdy/spdy_session.h"
+#include "net/spdy/spdy_session_pool.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace {
+
+TEST(HttpNetworkSessionTest, FlushOnNetworkChange) {
+ MockNetworkChangeNotifier mock_notifier;
+ scoped_refptr<MockCachingHostResolver> mock_resolver(
+ new MockCachingHostResolver);
+ MockClientSocketFactory mock_factory;
+ scoped_ptr<HttpAuthHandlerFactory> auth_handler_factory(
+ HttpAuthHandlerFactory::CreateDefault());
+ scoped_refptr<HttpNetworkSession> session(
+ new HttpNetworkSession(&mock_notifier,
+ mock_resolver,
+ ProxyService::CreateNull(),
+ &mock_factory,
+ new SSLConfigServiceDefaults,
+ auth_handler_factory.get()));
+
+ scoped_refptr<TCPClientSocketPool> tcp_socket_pool(
+ session->tcp_socket_pool());
+
+ // Start up one socket to leave idle in the pool.
+ StaticSocketDataProvider data;
+ mock_factory.AddSocketDataProvider(&data);
+ TestCompletionCallback callback;
+ ClientSocketHandle handle;
+ TCPSocketParams dest("www.google.com", 80, LOW, GURL(), false);
+ int rv = handle.Init(
+ "1", dest, LOW, &callback, tcp_socket_pool, BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ EXPECT_FALSE(handle.is_initialized());
+ EXPECT_FALSE(handle.socket());
+ EXPECT_EQ(OK, callback.WaitForResult());
+ EXPECT_TRUE(handle.is_initialized());
+ EXPECT_TRUE(handle.socket());
+
+ // Need to run all pending to release the socket back to the pool.
+ handle.Reset();
+ MessageLoop::current()->RunAllPending();
+
+ // Now we should have 1 idle socket.
+ EXPECT_EQ(1, tcp_socket_pool->IdleSocketCount());
+
+ // Start up another socket to keep as active. Hold onto it until after the IP
+ // address change causes a session flush.
+ StaticSocketDataProvider data2;
+ mock_factory.AddSocketDataProvider(&data2);
+ rv = handle.Init("2", dest, LOW, &callback, tcp_socket_pool, BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ EXPECT_FALSE(handle.is_initialized());
+ EXPECT_FALSE(handle.socket());
+ EXPECT_EQ(OK, callback.WaitForResult());
+ EXPECT_TRUE(handle.is_initialized());
+ EXPECT_TRUE(handle.socket());
+
+ HostPortPair host_port_pair("www.google.com", 80);
+
+ scoped_refptr<SpdySessionPool>
+ spdy_session_pool(session->spdy_session_pool());
+ scoped_refptr<SpdySession> spdy_session(session->spdy_session_pool()->Get(
+ host_port_pair, session, BoundNetLog()));
+
+ EXPECT_TRUE(spdy_session_pool->HasSession(host_port_pair));
+
+ // After an IP address change, we should have 0 idle sockets in the old pool
+ // and we should have replaced all the pools.
+ mock_notifier.NotifyIPAddressChange();
+ EXPECT_EQ(0, tcp_socket_pool->IdleSocketCount());
+ EXPECT_NE(tcp_socket_pool, session->tcp_socket_pool());
+ EXPECT_EQ(0, session->tcp_socket_pool()->IdleSocketCount());
+ EXPECT_FALSE(session->spdy_session_pool()->HasSession(host_port_pair));
+ EXPECT_NE(session->spdy_session_pool(), spdy_session_pool);
+
+ // Release all the handles to old objects. Run all pending tasks afterwards
+ // to flush pending tasks such as releasing sockets.
+ tcp_socket_pool = NULL;
+ spdy_session_pool = NULL;
+ handle.Reset();
+ MessageLoop::current()->RunAllPending();
+}
+
+} // namespace
+} // namespace net
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index eac14e2..8ad5d2f 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -81,23 +81,20 @@ class SessionDependencies {
: host_resolver(new MockHostResolver),
proxy_service(ProxyService::CreateNull()),
ssl_config_service(new SSLConfigServiceDefaults),
- http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
- spdy_session_pool(new SpdySessionPool) {}
+ http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {}
// Custom proxy service dependency.
explicit SessionDependencies(ProxyService* proxy_service)
: host_resolver(new MockHostResolver),
proxy_service(proxy_service),
ssl_config_service(new SSLConfigServiceDefaults),
- http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
- spdy_session_pool(new SpdySessionPool) {}
+ http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {}
scoped_refptr<MockHostResolverBase> host_resolver;
scoped_refptr<ProxyService> proxy_service;
scoped_refptr<SSLConfigService> ssl_config_service;
MockClientSocketFactory socket_factory;
scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
- scoped_refptr<SpdySessionPool> spdy_session_pool;
};
ProxyService* CreateFixedProxyService(const std::string& proxy) {
@@ -112,7 +109,6 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
session_deps->proxy_service,
&session_deps->socket_factory,
session_deps->ssl_config_service,
- session_deps->spdy_session_pool,
session_deps->http_auth_handler_factory.get());
}
@@ -238,8 +234,7 @@ class CaptureGroupNameSocketPool : public EmulatedClientSocketPool {
public:
CaptureGroupNameSocketPool(HttpNetworkSession* session)
: EmulatedClientSocketPool(0, 0, "CaptureGroupNameTestPool",
- session->host_resolver(), NULL,
- NULL) {}
+ session->host_resolver(), NULL) {}
const std::string last_group_name_received() const {
return last_group_name_;
}
diff --git a/net/net.gyp b/net/net.gyp
index d07ca84..0ff019c 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -685,6 +685,7 @@
'http/http_cache_unittest.cc',
'http/http_chunked_decoder_unittest.cc',
'http/http_network_layer_unittest.cc',
+ 'http/http_network_session_unittest.cc',
'http/http_network_transaction_unittest.cc',
'http/http_request_headers_unittest.cc',
'http/http_response_headers_unittest.cc',
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 99011be..b008c54 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -112,8 +112,7 @@ ClientSocketPoolBaseHelper::ClientSocketPoolBaseHelper(
int max_sockets_per_group,
base::TimeDelta unused_idle_socket_timeout,
base::TimeDelta used_idle_socket_timeout,
- ConnectJobFactory* connect_job_factory,
- NetworkChangeNotifier* network_change_notifier)
+ ConnectJobFactory* connect_job_factory)
: idle_socket_count_(0),
connecting_socket_count_(0),
handed_out_socket_count_(0),
@@ -124,14 +123,10 @@ ClientSocketPoolBaseHelper::ClientSocketPoolBaseHelper(
used_idle_socket_timeout_(used_idle_socket_timeout),
may_have_stalled_group_(false),
connect_job_factory_(connect_job_factory),
- network_change_notifier_(network_change_notifier),
backup_jobs_enabled_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
DCHECK_LE(0, max_sockets_per_group);
DCHECK_LE(max_sockets_per_group, max_sockets);
-
- if (network_change_notifier_)
- network_change_notifier_->AddObserver(this);
}
ClientSocketPoolBaseHelper::~ClientSocketPoolBaseHelper() {
@@ -143,9 +138,6 @@ ClientSocketPoolBaseHelper::~ClientSocketPoolBaseHelper() {
CloseIdleSockets();
CHECK(group_map_.empty());
DCHECK_EQ(0, connecting_socket_count_);
-
- if (network_change_notifier_)
- network_change_notifier_->RemoveObserver(this);
}
// InsertRequestIntoQueue inserts the request into the queue based on
@@ -610,10 +602,6 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete(
}
}
-void ClientSocketPoolBaseHelper::OnIPAddressChanged() {
- CloseIdleSockets();
-}
-
void ClientSocketPoolBaseHelper::RemoveConnectJob(const ConnectJob *job,
Group* group) {
CHECK_GT(connecting_socket_count_, 0);
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 89bdb78..55ce7f7 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -39,7 +39,6 @@
#include "net/base/load_states.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
-#include "net/base/network_change_notifier.h"
#include "net/base/request_priority.h"
#include "net/socket/client_socket.h"
#include "net/socket/client_socket_pool.h"
@@ -124,8 +123,7 @@ namespace internal {
// ClientSocketPoolBase instead.
class ClientSocketPoolBaseHelper
: public base::RefCounted<ClientSocketPoolBaseHelper>,
- public ConnectJob::Delegate,
- public NetworkChangeNotifier::Observer {
+ public ConnectJob::Delegate {
public:
class Request {
public:
@@ -172,8 +170,7 @@ class ClientSocketPoolBaseHelper
int max_sockets_per_group,
base::TimeDelta unused_idle_socket_timeout,
base::TimeDelta used_idle_socket_timeout,
- ConnectJobFactory* connect_job_factory,
- NetworkChangeNotifier* network_change_notifier);
+ ConnectJobFactory* connect_job_factory);
// See ClientSocketPool::RequestSocket for documentation on this function.
// ClientSocketPoolBaseHelper takes ownership of |request|, which must be
@@ -213,9 +210,6 @@ class ClientSocketPoolBaseHelper
// ConnectJob::Delegate methods:
virtual void OnConnectJobComplete(int result, ConnectJob* job);
- // NetworkChangeNotifier::Observer methods:
- virtual void OnIPAddressChanged();
-
// For testing.
bool may_have_stalled_group() const { return may_have_stalled_group_; }
@@ -439,8 +433,6 @@ class ClientSocketPoolBaseHelper
const scoped_ptr<ConnectJobFactory> connect_job_factory_;
- NetworkChangeNotifier* const network_change_notifier_;
-
// TODO(vandebo) Remove when backup jobs move to TCPClientSocketPool
bool backup_jobs_enabled_;
@@ -507,14 +499,12 @@ class ClientSocketPoolBase {
const std::string& name,
base::TimeDelta unused_idle_socket_timeout,
base::TimeDelta used_idle_socket_timeout,
- ConnectJobFactory* connect_job_factory,
- NetworkChangeNotifier* network_change_notifier)
+ ConnectJobFactory* connect_job_factory)
: name_(name),
helper_(new internal::ClientSocketPoolBaseHelper(
max_sockets, max_sockets_per_group,
unused_idle_socket_timeout, used_idle_socket_timeout,
- new ConnectJobFactoryAdaptor(connect_job_factory),
- network_change_notifier)) {}
+ new ConnectJobFactoryAdaptor(connect_job_factory))) {}
virtual ~ClientSocketPoolBase() {}
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index f21ee55..6d68097 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -26,7 +26,7 @@ namespace {
const int kDefaultMaxSockets = 4;
const int kDefaultMaxSocketsPerGroup = 2;
-const net::RequestPriority kDefaultPriority = MEDIUM;
+const RequestPriority kDefaultPriority = MEDIUM;
typedef const void* TestSocketParams;
typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase;
@@ -288,7 +288,7 @@ class TestClientSocketPool : public ClientSocketPool {
TestClientSocketPoolBase::ConnectJobFactory* connect_job_factory)
: base_(max_sockets, max_sockets_per_group, name,
unused_idle_socket_timeout, used_idle_socket_timeout,
- connect_job_factory, NULL) {}
+ connect_job_factory) {}
virtual int RequestSocket(
const std::string& group_name,
diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc
index b98f9fd..febcdbf 100644
--- a/net/socket/socks_client_socket_pool.cc
+++ b/net/socket/socks_client_socket_pool.cc
@@ -161,13 +161,11 @@ SOCKSClientSocketPool::SOCKSClientSocketPool(
int max_sockets_per_group,
const std::string& name,
const scoped_refptr<HostResolver>& host_resolver,
- const scoped_refptr<TCPClientSocketPool>& tcp_pool,
- NetworkChangeNotifier* network_change_notifier)
+ const scoped_refptr<TCPClientSocketPool>& tcp_pool)
: base_(max_sockets, max_sockets_per_group, name,
base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout),
base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout),
- new SOCKSConnectJobFactory(tcp_pool, host_resolver),
- network_change_notifier) {}
+ new SOCKSConnectJobFactory(tcp_pool, host_resolver)) {}
SOCKSClientSocketPool::~SOCKSClientSocketPool() {}
diff --git a/net/socket/socks_client_socket_pool.h b/net/socket/socks_client_socket_pool.h
index a786dc1..5b91ad3 100644
--- a/net/socket/socks_client_socket_pool.h
+++ b/net/socket/socks_client_socket_pool.h
@@ -109,8 +109,7 @@ class SOCKSClientSocketPool : public ClientSocketPool {
int max_sockets_per_group,
const std::string& name,
const scoped_refptr<HostResolver>& host_resolver,
- const scoped_refptr<TCPClientSocketPool>& tcp_pool,
- NetworkChangeNotifier* network_change_notifier);
+ const scoped_refptr<TCPClientSocketPool>& tcp_pool);
// ClientSocketPool methods:
virtual int RequestSocket(const std::string& group_name,
diff --git a/net/socket/socks_client_socket_pool_unittest.cc b/net/socket/socks_client_socket_pool_unittest.cc
index 6072ad3..335f289 100644
--- a/net/socket/socks_client_socket_pool_unittest.cc
+++ b/net/socket/socks_client_socket_pool_unittest.cc
@@ -10,7 +10,6 @@
#include "base/compiler_specific.h"
#include "base/time.h"
#include "net/base/mock_host_resolver.h"
-#include "net/base/mock_network_change_notifier.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/socket/client_socket_factory.h"
@@ -83,10 +82,9 @@ class MockTCPClientSocketPool : public TCPClientSocketPool {
MockTCPClientSocketPool(int max_sockets, int max_sockets_per_group,
const std::string& name,
- ClientSocketFactory* socket_factory,
- NetworkChangeNotifier* network_change_notifier)
+ ClientSocketFactory* socket_factory)
: TCPClientSocketPool(max_sockets, max_sockets_per_group, name,
- NULL, NULL, network_change_notifier),
+ NULL, NULL),
client_socket_factory_(socket_factory),
release_count_(0),
cancel_count_(0) {}
@@ -171,13 +169,13 @@ class SOCKSClientSocketPoolTest : public ClientSocketPoolTest {
HostPortPair("proxy", 80), MEDIUM, GURL(), false),
tcp_socket_pool_(new MockTCPClientSocketPool(
kMaxSockets, kMaxSocketsPerGroup, "MockTCP",
- &tcp_client_socket_factory_, &tcp_notifier_)),
+ &tcp_client_socket_factory_)),
ignored_socket_params_(ignored_tcp_socket_params_, true,
HostPortPair("host", 80),
MEDIUM, GURL()),
pool_(new SOCKSClientSocketPool(
kMaxSockets, kMaxSocketsPerGroup, "SOCKSUnitTest", NULL,
- tcp_socket_pool_.get(), &socks_notifier_)) {
+ tcp_socket_pool_.get())) {
}
int StartRequest(const std::string& group_name, RequestPriority priority) {
@@ -187,11 +185,9 @@ class SOCKSClientSocketPoolTest : public ClientSocketPoolTest {
TCPSocketParams ignored_tcp_socket_params_;
MockClientSocketFactory tcp_client_socket_factory_;
- MockNetworkChangeNotifier tcp_notifier_;
scoped_refptr<MockTCPClientSocketPool> tcp_socket_pool_;
SOCKSSocketParams ignored_socket_params_;
- MockNetworkChangeNotifier socks_notifier_;
scoped_refptr<SOCKSClientSocketPool> pool_;
};
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index 74841cf..2f8e7675 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -177,13 +177,11 @@ TCPClientSocketPool::TCPClientSocketPool(
int max_sockets_per_group,
const std::string& name,
HostResolver* host_resolver,
- ClientSocketFactory* client_socket_factory,
- NetworkChangeNotifier* network_change_notifier)
+ ClientSocketFactory* client_socket_factory)
: base_(max_sockets, max_sockets_per_group, name,
base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout),
base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout),
- new TCPConnectJobFactory(client_socket_factory, host_resolver),
- network_change_notifier) {
+ new TCPConnectJobFactory(client_socket_factory, host_resolver)) {
base_.enable_backup_jobs();
}
diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/tcp_client_socket_pool.h
index 30158f6..8a62a06 100644
--- a/net/socket/tcp_client_socket_pool.h
+++ b/net/socket/tcp_client_socket_pool.h
@@ -116,8 +116,7 @@ class TCPClientSocketPool : public ClientSocketPool {
int max_sockets_per_group,
const std::string& name,
HostResolver* host_resolver,
- ClientSocketFactory* client_socket_factory,
- NetworkChangeNotifier* network_change_notifier);
+ ClientSocketFactory* client_socket_factory);
// ClientSocketPool methods:
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index cba12b5..fdd8e6e 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -8,7 +8,6 @@
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "net/base/mock_host_resolver.h"
-#include "net/base/mock_network_change_notifier.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/socket/client_socket.h"
@@ -263,9 +262,7 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest {
kMaxSocketsPerGroup,
"TCPUnitTest",
host_resolver_,
- &client_socket_factory_,
- &notifier_)) {
- }
+ &client_socket_factory_)) {}
int StartRequest(const std::string& group_name, RequestPriority priority) {
return StartRequestUsingPool(
@@ -275,7 +272,6 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest {
TCPSocketParams ignored_socket_params_;
scoped_refptr<MockHostResolver> host_resolver_;
MockClientSocketFactory client_socket_factory_;
- MockNetworkChangeNotifier notifier_;
scoped_refptr<TCPClientSocketPool> pool_;
};
@@ -652,32 +648,6 @@ TEST_F(TCPClientSocketPoolTest, FailingActiveRequestWithPendingRequests) {
EXPECT_EQ(ERR_CONNECTION_FAILED, requests_[i]->WaitForResult());
}
-TEST_F(TCPClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) {
- TestCompletionCallback callback;
- ClientSocketHandle handle;
- TCPSocketParams dest("www.google.com", 80, LOW, GURL(), false);
- int rv = handle.Init("a", dest, LOW, &callback, pool_, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_FALSE(handle.is_initialized());
- EXPECT_FALSE(handle.socket());
-
- EXPECT_EQ(OK, callback.WaitForResult());
- EXPECT_TRUE(handle.is_initialized());
- EXPECT_TRUE(handle.socket());
-
- handle.Reset();
-
- // Need to run all pending to release the socket back to the pool.
- MessageLoop::current()->RunAllPending();
-
- // Now we should have 1 idle socket.
- EXPECT_EQ(1, pool_->IdleSocketCount());
-
- // After an IP address change, we should have 0 idle sockets.
- notifier_.NotifyIPAddressChange();
- EXPECT_EQ(0, pool_->IdleSocketCount());
-}
-
TEST_F(TCPClientSocketPoolTest, BackupSocketConnect) {
// Case 1 tests the first socket stalling, and the backup connecting.
MockClientSocketFactory::ClientSocketType case1_types[] = {
@@ -736,8 +706,7 @@ TEST_F(TCPClientSocketPoolTest, BackupSocketConnect) {
kMaxSocketsPerGroup,
"TCPUnitTest",
host_resolver_,
- &client_socket_factory_,
- NULL);
+ &client_socket_factory_);
}
}
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index add273b..e4279b0 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -86,7 +86,6 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
session_deps->proxy_service,
&session_deps->socket_factory,
session_deps->ssl_config_service,
- session_deps->spdy_session_pool,
session_deps->http_auth_handler_factory.get());
}
diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc
index ab7b12c..c5a5d0d 100644
--- a/net/spdy/spdy_session_unittest.cc
+++ b/net/spdy/spdy_session_unittest.cc
@@ -54,7 +54,6 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
session_deps->proxy_service,
&session_deps->socket_factory,
session_deps->ssl_config_service,
- session_deps->spdy_session_pool,
NULL);
}
diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc
index 3da9da73..5d226c7 100644
--- a/net/spdy/spdy_stream_unittest.cc
+++ b/net/spdy/spdy_stream_unittest.cc
@@ -77,7 +77,6 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
session_deps->proxy_service,
&session_deps->socket_factory,
session_deps->ssl_config_service,
- session_deps->spdy_session_pool,
session_deps->http_auth_handler_factory.get());
}