summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 23:57:54 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 23:57:54 +0000
commit73c4532bd7f5b84bc822a4acca5c5b8affef4129 (patch)
treedc2a525aab1bda568b52ea78e72c8be79b9165dc /net/socket
parent3209e71131849f3e0d513cd3fd8dca881f05d531 (diff)
downloadchromium_src-73c4532bd7f5b84bc822a4acca5c5b8affef4129.zip
chromium_src-73c4532bd7f5b84bc822a4acca5c5b8affef4129.tar.gz
chromium_src-73c4532bd7f5b84bc822a4acca5c5b8affef4129.tar.bz2
Stop refcounting HostResolver.
BUG=46049 TEST=none Review URL: http://codereview.chromium.org/3601002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/client_socket_pool_manager.h2
-rw-r--r--net/socket/socks5_client_socket_unittest.cc2
-rw-r--r--net/socket/socks_client_socket_pool.cc4
-rw-r--r--net/socket/socks_client_socket_pool.h8
-rw-r--r--net/socket/socks_client_socket_unittest.cc40
-rw-r--r--net/socket/ssl_client_socket_pool.cc4
-rw-r--r--net/socket/ssl_client_socket_pool.h8
-rw-r--r--net/socket/ssl_client_socket_pool_unittest.cc8
-rw-r--r--net/socket/ssl_client_socket_unittest.cc20
-rw-r--r--net/socket/tcp_client_socket_pool.h2
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc4
-rw-r--r--net/socket/tcp_client_socket_unittest.cc2
12 files changed, 57 insertions, 47 deletions
diff --git a/net/socket/client_socket_pool_manager.h b/net/socket/client_socket_pool_manager.h
index 40f831f..02a73a9 100644
--- a/net/socket/client_socket_pool_manager.h
+++ b/net/socket/client_socket_pool_manager.h
@@ -99,7 +99,7 @@ class ClientSocketPoolManager : public NonThreadSafe {
NetLog* const net_log_;
ClientSocketFactory* const socket_factory_;
- const scoped_refptr<HostResolver> host_resolver_;
+ HostResolver* const host_resolver_;
const scoped_refptr<ProxyService> proxy_service_;
const scoped_refptr<SSLConfigService> ssl_config_service_;
diff --git a/net/socket/socks5_client_socket_unittest.cc b/net/socket/socks5_client_socket_unittest.cc
index 9ceffd0..43a441d 100644
--- a/net/socket/socks5_client_socket_unittest.cc
+++ b/net/socket/socks5_client_socket_unittest.cc
@@ -48,7 +48,7 @@ class SOCKS5ClientSocketTest : public PlatformTest {
AddressList address_list_;
ClientSocket* tcp_sock_;
TestCompletionCallback callback_;
- scoped_refptr<MockHostResolver> host_resolver_;
+ scoped_ptr<MockHostResolver> host_resolver_;
scoped_ptr<SocketDataProvider> data_;
private:
diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc
index 129c075..cae333a 100644
--- a/net/socket/socks_client_socket_pool.cc
+++ b/net/socket/socks_client_socket_pool.cc
@@ -44,7 +44,7 @@ SOCKSConnectJob::SOCKSConnectJob(
const scoped_refptr<SOCKSSocketParams>& socks_params,
const base::TimeDelta& timeout_duration,
TCPClientSocketPool* tcp_pool,
- const scoped_refptr<HostResolver>& host_resolver,
+ HostResolver* host_resolver,
Delegate* delegate,
NetLog* net_log)
: ConnectJob(group_name, timeout_duration, delegate,
@@ -181,7 +181,7 @@ SOCKSClientSocketPool::SOCKSClientSocketPool(
int max_sockets,
int max_sockets_per_group,
ClientSocketPoolHistograms* histograms,
- const scoped_refptr<HostResolver>& host_resolver,
+ HostResolver* host_resolver,
TCPClientSocketPool* tcp_pool,
NetLog* net_log)
: tcp_pool_(tcp_pool),
diff --git a/net/socket/socks_client_socket_pool.h b/net/socket/socks_client_socket_pool.h
index 383de63..a257d0f 100644
--- a/net/socket/socks_client_socket_pool.h
+++ b/net/socket/socks_client_socket_pool.h
@@ -58,7 +58,7 @@ class SOCKSConnectJob : public ConnectJob {
const scoped_refptr<SOCKSSocketParams>& params,
const base::TimeDelta& timeout_duration,
TCPClientSocketPool* tcp_pool,
- const scoped_refptr<HostResolver> &host_resolver,
+ HostResolver* host_resolver,
Delegate* delegate,
NetLog* net_log);
virtual ~SOCKSConnectJob();
@@ -92,7 +92,7 @@ class SOCKSConnectJob : public ConnectJob {
scoped_refptr<SOCKSSocketParams> socks_params_;
TCPClientSocketPool* const tcp_pool_;
- const scoped_refptr<HostResolver> resolver_;
+ HostResolver* const resolver_;
State next_state_;
CompletionCallbackImpl<SOCKSConnectJob> callback_;
@@ -108,7 +108,7 @@ class SOCKSClientSocketPool : public ClientSocketPool {
int max_sockets,
int max_sockets_per_group,
ClientSocketPoolHistograms* histograms,
- const scoped_refptr<HostResolver>& host_resolver,
+ HostResolver* host_resolver,
TCPClientSocketPool* tcp_pool,
NetLog* net_log);
@@ -178,7 +178,7 @@ class SOCKSClientSocketPool : public ClientSocketPool {
private:
TCPClientSocketPool* const tcp_pool_;
- const scoped_refptr<HostResolver> host_resolver_;
+ HostResolver* const host_resolver_;
NetLog* net_log_;
DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJobFactory);
diff --git a/net/socket/socks_client_socket_unittest.cc b/net/socket/socks_client_socket_unittest.cc
index 8ed82b9..086b21d9 100644
--- a/net/socket/socks_client_socket_unittest.cc
+++ b/net/socket/socks_client_socket_unittest.cc
@@ -41,11 +41,8 @@ class SOCKSClientSocketTest : public PlatformTest {
AddressList address_list_;
ClientSocket* tcp_sock_;
TestCompletionCallback callback_;
- scoped_refptr<MockHostResolver> host_resolver_;
+ scoped_ptr<MockHostResolver> host_resolver_;
scoped_ptr<SocketDataProvider> data_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocketTest);
};
SOCKSClientSocketTest::SOCKSClientSocketTest()
@@ -135,7 +132,9 @@ TEST_F(SOCKSClientSocketTest, CompleteHandshake) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80, &log));
+ host_resolver_.get(),
+ "localhost", 80,
+ &log));
// At this state the TCP connection is completed but not the SOCKS handshake.
EXPECT_TRUE(tcp_sock_->IsConnected());
@@ -203,7 +202,9 @@ TEST_F(SOCKSClientSocketTest, HandshakeFailures) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80, &log));
+ host_resolver_.get(),
+ "localhost", 80,
+ &log));
int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -233,7 +234,9 @@ TEST_F(SOCKSClientSocketTest, PartialServerReads) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80, &log));
+ host_resolver_.get(),
+ "localhost", 80,
+ &log));
int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -265,7 +268,9 @@ TEST_F(SOCKSClientSocketTest, PartialClientWrites) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80, &log));
+ host_resolver_.get(),
+ "localhost", 80,
+ &log));
int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -291,7 +296,9 @@ TEST_F(SOCKSClientSocketTest, FailedSocketRead) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, "localhost", 80, &log));
+ host_resolver_.get(),
+ "localhost", 80,
+ &log));
int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -322,7 +329,9 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AFailedDNS) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, hostname, 80, &log));
+ host_resolver_.get(),
+ hostname, 80,
+ &log));
int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -356,7 +365,9 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AIfDomainInIPv6) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- host_resolver_, hostname, 80, &log));
+ host_resolver_.get(),
+ hostname, 80,
+ &log));
int rv = user_sock_->Connect(&callback_);
EXPECT_EQ(ERR_IO_PENDING, rv);
@@ -373,8 +384,7 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AIfDomainInIPv6) {
// Calls Disconnect() while a host resolve is in progress. The outstanding host
// resolve should be cancelled.
TEST_F(SOCKSClientSocketTest, DisconnectWhileHostResolveInProgress) {
- scoped_refptr<HangingHostResolver> hanging_resolver =
- new HangingHostResolver();
+ scoped_ptr<HangingHostResolver> hanging_resolver(new HangingHostResolver());
// Doesn't matter what the socket data is, we will never use it -- garbage.
MockWrite data_writes[] = { MockWrite(false, "", 0) };
@@ -382,7 +392,9 @@ TEST_F(SOCKSClientSocketTest, DisconnectWhileHostResolveInProgress) {
user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes),
- hanging_resolver, "foo", 80, NULL));
+ hanging_resolver.get(),
+ "foo", 80,
+ NULL));
// Start connecting (will get stuck waiting for the host to resolve).
int rv = user_sock_->Connect(&callback_);
diff --git a/net/socket/ssl_client_socket_pool.cc b/net/socket/ssl_client_socket_pool.cc
index 6069f4d..ceea81b 100644
--- a/net/socket/ssl_client_socket_pool.cc
+++ b/net/socket/ssl_client_socket_pool.cc
@@ -74,7 +74,7 @@ SSLConnectJob::SSLConnectJob(
SOCKSClientSocketPool* socks_pool,
HttpProxyClientSocketPool* http_proxy_pool,
ClientSocketFactory* client_socket_factory,
- const scoped_refptr<HostResolver>& host_resolver,
+ HostResolver* host_resolver,
Delegate* delegate,
NetLog* net_log)
: ConnectJob(group_name, timeout_duration, delegate,
@@ -377,7 +377,7 @@ SSLClientSocketPool::SSLClientSocketPool(
int max_sockets,
int max_sockets_per_group,
ClientSocketPoolHistograms* histograms,
- const scoped_refptr<HostResolver>& host_resolver,
+ HostResolver* host_resolver,
ClientSocketFactory* client_socket_factory,
TCPClientSocketPool* tcp_pool,
SOCKSClientSocketPool* socks_pool,
diff --git a/net/socket/ssl_client_socket_pool.h b/net/socket/ssl_client_socket_pool.h
index c9a93ac..6aff091 100644
--- a/net/socket/ssl_client_socket_pool.h
+++ b/net/socket/ssl_client_socket_pool.h
@@ -90,7 +90,7 @@ class SSLConnectJob : public ConnectJob {
SOCKSClientSocketPool* socks_pool,
HttpProxyClientSocketPool* http_proxy_pool,
ClientSocketFactory* client_socket_factory,
- const scoped_refptr<HostResolver>& host_resolver,
+ HostResolver* host_resolver,
Delegate* delegate,
NetLog* net_log);
virtual ~SSLConnectJob();
@@ -137,7 +137,7 @@ class SSLConnectJob : public ConnectJob {
SOCKSClientSocketPool* const socks_pool_;
HttpProxyClientSocketPool* const http_proxy_pool_;
ClientSocketFactory* const client_socket_factory_;
- const scoped_refptr<HostResolver> resolver_;
+ HostResolver* const resolver_;
State next_state_;
CompletionCallbackImpl<SSLConnectJob> callback_;
@@ -161,7 +161,7 @@ class SSLClientSocketPool : public ClientSocketPool,
int max_sockets,
int max_sockets_per_group,
ClientSocketPoolHistograms* histograms,
- const scoped_refptr<HostResolver>& host_resolver,
+ HostResolver* host_resolver,
ClientSocketFactory* client_socket_factory,
TCPClientSocketPool* tcp_pool,
SOCKSClientSocketPool* socks_pool,
@@ -245,7 +245,7 @@ class SSLClientSocketPool : public ClientSocketPool,
SOCKSClientSocketPool* const socks_pool_;
HttpProxyClientSocketPool* const http_proxy_pool_;
ClientSocketFactory* const client_socket_factory_;
- const scoped_refptr<HostResolver> host_resolver_;
+ HostResolver* const host_resolver_;
base::TimeDelta timeout_;
NetLog* net_log_;
diff --git a/net/socket/ssl_client_socket_pool_unittest.cc b/net/socket/ssl_client_socket_pool_unittest.cc
index feac473..91290bb 100644
--- a/net/socket/ssl_client_socket_pool_unittest.cc
+++ b/net/socket/ssl_client_socket_pool_unittest.cc
@@ -37,8 +37,8 @@ class SSLClientSocketPoolTest : public testing::Test {
SSLClientSocketPoolTest()
: host_resolver_(new MockHostResolver),
http_auth_handler_factory_(HttpAuthHandlerFactory::CreateDefault(
- host_resolver_)),
- session_(new HttpNetworkSession(host_resolver_,
+ host_resolver_.get())),
+ session_(new HttpNetworkSession(host_resolver_.get(),
ProxyService::CreateDirect(),
&socket_factory_,
new SSLConfigServiceDefaults,
@@ -76,7 +76,7 @@ class SSLClientSocketPoolTest : public testing::Test {
kMaxSockets,
kMaxSocketsPerGroup,
&http_proxy_histograms_,
- new MockHostResolver,
+ host_resolver_.get(),
&tcp_socket_pool_,
NULL,
NULL) {
@@ -122,7 +122,7 @@ class SSLClientSocketPoolTest : public testing::Test {
}
MockClientSocketFactory socket_factory_;
- scoped_refptr<HostResolver> host_resolver_;
+ scoped_ptr<HostResolver> host_resolver_;
scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_;
scoped_refptr<HttpNetworkSession> session_;
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 70540f9..e545388 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -26,14 +26,10 @@ const net::SSLConfig kDefaultSSLConfig;
class SSLClientSocketTest : public PlatformTest {
public:
SSLClientSocketTest()
- : resolver_(net::CreateSystemHostResolver(
- net::HostResolver::kDefaultParallelism,
- NULL)),
- socket_factory_(net::ClientSocketFactory::GetDefaultFactory()) {
+ : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()) {
}
protected:
- scoped_refptr<net::HostResolver> resolver_;
net::ClientSocketFactory* socket_factory_;
};
@@ -292,9 +288,10 @@ TEST_F(SSLClientSocketTest, Read) {
EXPECT_EQ(net::OK, rv);
scoped_ptr<net::SSLClientSocket> sock(
- socket_factory_->CreateSSLClientSocket(transport,
- test_server.host_port_pair().host(),
- kDefaultSSLConfig));
+ socket_factory_->CreateSSLClientSocket(
+ transport,
+ test_server.host_port_pair().host(),
+ kDefaultSSLConfig));
rv = sock->Connect(&callback);
if (rv != net::OK) {
@@ -351,9 +348,10 @@ TEST_F(SSLClientSocketTest, Read_FullDuplex) {
EXPECT_EQ(net::OK, rv);
scoped_ptr<net::SSLClientSocket> sock(
- socket_factory_->CreateSSLClientSocket(transport,
- test_server.host_port_pair().host(),
- kDefaultSSLConfig));
+ socket_factory_->CreateSSLClientSocket(
+ transport,
+ test_server.host_port_pair().host(),
+ kDefaultSSLConfig));
rv = sock->Connect(&callback);
if (rv != net::OK) {
diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/tcp_client_socket_pool.h
index 1de3870..4837468 100644
--- a/net/socket/tcp_client_socket_pool.h
+++ b/net/socket/tcp_client_socket_pool.h
@@ -191,7 +191,7 @@ class TCPClientSocketPool : public ClientSocketPool {
private:
ClientSocketFactory* const client_socket_factory_;
- const scoped_refptr<HostResolver> host_resolver_;
+ HostResolver* const host_resolver_;
NetLog* net_log_;
DISALLOW_COPY_AND_ASSIGN(TCPConnectJobFactory);
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index 1e701aa..c550232 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -285,7 +285,7 @@ class TCPClientSocketPoolTest : public testing::Test {
pool_(kMaxSockets,
kMaxSocketsPerGroup,
histograms_.get(),
- host_resolver_,
+ host_resolver_.get(),
&client_socket_factory_,
NULL) {
}
@@ -315,7 +315,7 @@ class TCPClientSocketPoolTest : public testing::Test {
scoped_refptr<TCPSocketParams> params_;
scoped_refptr<TCPSocketParams> low_params_;
scoped_ptr<ClientSocketPoolHistograms> histograms_;
- scoped_refptr<MockHostResolver> host_resolver_;
+ scoped_ptr<MockHostResolver> host_resolver_;
MockClientSocketFactory client_socket_factory_;
TCPClientSocketPool pool_;
ClientSocketPoolTest test_base_;
diff --git a/net/socket/tcp_client_socket_unittest.cc b/net/socket/tcp_client_socket_unittest.cc
index 17ec51c..fdd966c 100644
--- a/net/socket/tcp_client_socket_unittest.cc
+++ b/net/socket/tcp_client_socket_unittest.cc
@@ -91,7 +91,7 @@ void TCPClientSocketTest::SetUp() {
listen_port_ = port;
AddressList addr;
- scoped_refptr<HostResolver> resolver(
+ scoped_ptr<HostResolver> resolver(
CreateSystemHostResolver(HostResolver::kDefaultParallelism,
NULL));
HostResolver::RequestInfo info(HostPortPair("localhost", listen_port_));