summaryrefslogtreecommitdiffstats
path: root/net/socket/tcp_client_socket_pool_unittest.cc
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-27 00:07:38 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-27 00:07:38 +0000
commit7fc5b09a0544d3fe96ba95d5dfe09eecd3e745dc (patch)
treeedff04322f7c9653b8f0dfc85365ed433266b58e /net/socket/tcp_client_socket_pool_unittest.cc
parentf26795ebb86f6bcd4da9d4971e252eea933cfdf3 (diff)
downloadchromium_src-7fc5b09a0544d3fe96ba95d5dfe09eecd3e745dc.zip
chromium_src-7fc5b09a0544d3fe96ba95d5dfe09eecd3e745dc.tar.gz
chromium_src-7fc5b09a0544d3fe96ba95d5dfe09eecd3e745dc.tar.bz2
Make a proper TCPSocketParams
BUG=none TEST=existing unit tests Review URL: http://codereview.chromium.org/661194 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_pool_unittest.cc')
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc53
1 files changed, 26 insertions, 27 deletions
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index 2678848..c9d80f1 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -206,7 +206,7 @@ class MockClientSocketFactory : public ClientSocketFactory {
class TCPClientSocketPoolTest : public ClientSocketPoolTest {
protected:
TCPClientSocketPoolTest()
- : ignored_request_info_("ignored", 80),
+ : ignored_socket_params_("ignored", 80, MEDIUM, GURL(), false),
host_resolver_(new MockHostResolver),
pool_(new TCPClientSocketPool(kMaxSockets,
kMaxSocketsPerGroup,
@@ -217,10 +217,10 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest {
int StartRequest(const std::string& group_name, RequestPriority priority) {
return StartRequestUsingPool(
- pool_.get(), group_name, priority, ignored_request_info_);
+ pool_.get(), group_name, priority, ignored_socket_params_);
}
- HostResolver::RequestInfo ignored_request_info_;
+ TCPSocketParams ignored_socket_params_;
scoped_refptr<MockHostResolver> host_resolver_;
MockClientSocketFactory client_socket_factory_;
MockNetworkChangeNotifier notifier_;
@@ -230,8 +230,8 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest {
TEST_F(TCPClientSocketPoolTest, Basic) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- HostResolver::RequestInfo info("www.google.com", 80);
- int rv = handle.Init("a", info, LOW, &callback, pool_.get(), NULL);
+ TCPSocketParams dest("www.google.com", 80, LOW, GURL(), false);
+ int rv = handle.Init("a", dest, LOW, &callback, pool_.get(), NULL);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -246,10 +246,11 @@ TEST_F(TCPClientSocketPoolTest, Basic) {
TEST_F(TCPClientSocketPoolTest, InitHostResolutionFailure) {
host_resolver_->rules()->AddSimulatedFailure("unresolvable.host.name");
TestSocketRequest req(&request_order_, &completion_count_);
- HostResolver::RequestInfo info("unresolvable.host.name", 80);
+ TCPSocketParams dest("unresolvable.host.name", 80, kDefaultPriority, GURL(),
+ false);
EXPECT_EQ(ERR_IO_PENDING,
req.handle()->Init(
- "a", info, kDefaultPriority, &req, pool_.get(), NULL));
+ "a", dest, kDefaultPriority, &req, pool_.get(), NULL));
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req.WaitForResult());
}
@@ -257,17 +258,17 @@ TEST_F(TCPClientSocketPoolTest, InitConnectionFailure) {
client_socket_factory_.set_client_socket_type(
MockClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET);
TestSocketRequest req(&request_order_, &completion_count_);
- HostResolver::RequestInfo info("a", 80);
+ TCPSocketParams dest("a", 80, kDefaultPriority, GURL(), false);
EXPECT_EQ(ERR_IO_PENDING,
req.handle()->Init(
- "a", info, kDefaultPriority, &req, pool_.get(), NULL));
+ "a", dest, kDefaultPriority, &req, pool_.get(), NULL));
EXPECT_EQ(ERR_CONNECTION_FAILED, req.WaitForResult());
// Make the host resolutions complete synchronously this time.
host_resolver_->set_synchronous_mode(true);
EXPECT_EQ(ERR_CONNECTION_FAILED,
req.handle()->Init(
- "a", info, kDefaultPriority, &req, pool_.get(), NULL));
+ "a", dest, kDefaultPriority, &req, pool_.get(), NULL));
}
TEST_F(TCPClientSocketPoolTest, PendingRequests) {
@@ -371,10 +372,10 @@ TEST_F(TCPClientSocketPoolTest, PendingRequests_NoKeepAlive) {
// ClientSocketPool which will crash if the group was not cleared properly.
TEST_F(TCPClientSocketPoolTest, CancelRequestClearGroup) {
TestSocketRequest req(&request_order_, &completion_count_);
- HostResolver::RequestInfo info("www.google.com", 80);
+ TCPSocketParams dest("www.google.com", 80, kDefaultPriority, GURL(), false);
EXPECT_EQ(ERR_IO_PENDING,
req.handle()->Init(
- "a", info, kDefaultPriority, &req, pool_.get(), NULL));
+ "a", dest, kDefaultPriority, &req, pool_.get(), NULL));
req.handle()->Reset();
// There is a race condition here. If the worker pool doesn't post the task
@@ -390,13 +391,13 @@ TEST_F(TCPClientSocketPoolTest, TwoRequestsCancelOne) {
TestSocketRequest req(&request_order_, &completion_count_);
TestSocketRequest req2(&request_order_, &completion_count_);
- HostResolver::RequestInfo info("www.google.com", 80);
+ TCPSocketParams dest("www.google.com", 80, kDefaultPriority, GURL(), false);
EXPECT_EQ(ERR_IO_PENDING,
req.handle()->Init(
- "a", info, kDefaultPriority, &req, pool_.get(), NULL));
+ "a", dest, kDefaultPriority, &req, pool_.get(), NULL));
EXPECT_EQ(ERR_IO_PENDING,
req2.handle()->Init(
- "a", info, kDefaultPriority, &req2, pool_.get(), NULL));
+ "a", dest, kDefaultPriority, &req2, pool_.get(), NULL));
req.handle()->Reset();
@@ -411,17 +412,17 @@ TEST_F(TCPClientSocketPoolTest, ConnectCancelConnect) {
TestCompletionCallback callback;
TestSocketRequest req(&request_order_, &completion_count_);
- HostResolver::RequestInfo info("www.google.com", 80);
+ TCPSocketParams dest("www.google.com", 80, kDefaultPriority, GURL(), false);
EXPECT_EQ(ERR_IO_PENDING,
handle.Init(
- "a", info, kDefaultPriority, &callback, pool_.get(), NULL));
+ "a", dest, kDefaultPriority, &callback, pool_.get(), NULL));
handle.Reset();
TestCompletionCallback callback2;
EXPECT_EQ(ERR_IO_PENDING,
handle.Init(
- "a", info, kDefaultPriority, &callback2, pool_.get(), NULL));
+ "a", dest, kDefaultPriority, &callback2, pool_.get(), NULL));
host_resolver_->set_synchronous_mode(true);
// At this point, handle has two ConnectingSockets out for it. Due to the
@@ -519,9 +520,8 @@ class RequestSocketCallback : public CallbackRunner< Tuple1<int> > {
MessageLoop::current()->RunAllPending();
}
within_callback_ = true;
- int rv = handle_->Init(
- "a", HostResolver::RequestInfo("www.google.com", 80), LOWEST,
- this, pool_.get(), NULL);
+ TCPSocketParams dest("www.google.com", 80, LOWEST, GURL(), false);
+ int rv = handle_->Init("a", dest, LOWEST, this, pool_.get(), NULL);
EXPECT_EQ(OK, rv);
}
}
@@ -540,9 +540,8 @@ class RequestSocketCallback : public CallbackRunner< Tuple1<int> > {
TEST_F(TCPClientSocketPoolTest, RequestTwice) {
ClientSocketHandle handle;
RequestSocketCallback callback(&handle, pool_.get());
- int rv = handle.Init(
- "a", HostResolver::RequestInfo("www.google.com", 80), LOWEST,
- &callback, pool_.get(), NULL);
+ TCPSocketParams dest("www.google.com", 80, LOWEST, GURL(), false);
+ int rv = handle.Init("a", dest, LOWEST, &callback, pool_.get(), NULL);
ASSERT_EQ(ERR_IO_PENDING, rv);
// The callback is going to request "www.google.com". We want it to complete
@@ -604,8 +603,8 @@ TEST_F(TCPClientSocketPoolTest, FailingActiveRequestWithPendingRequests) {
TEST_F(TCPClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- HostResolver::RequestInfo info("www.google.com", 80);
- int rv = handle.Init("a", info, LOW, &callback, pool_.get(), NULL);
+ TCPSocketParams dest("www.google.com", 80, LOW, GURL(), false);
+ int rv = handle.Init("a", dest, LOW, &callback, pool_.get(), NULL);
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());