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

Unified Diff: net/socket/transport_client_socket_pool_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/socket/transport_client_socket_pool_unittest.cc
diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc
index 425bb8cc421ac4a36695cfc5758bda2e0efc4077..940690ca6f1585558a0d01646b059ac37cf08f3b 100644
--- a/net/socket/transport_client_socket_pool_unittest.cc
+++ b/net/socket/transport_client_socket_pool_unittest.cc
@@ -89,23 +89,16 @@ class MockClientSocket : public StreamSocket {
MockClientSocket(const AddressList& addrlist, net::NetLog* net_log)
: connected_(false),
addrlist_(addrlist),
- net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) {
- }
+ net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) {}
// StreamSocket implementation.
virtual int Connect(const CompletionCallback& callback) OVERRIDE {
connected_ = true;
return OK;
}
- virtual void Disconnect() OVERRIDE {
- connected_ = false;
- }
- virtual bool IsConnected() const OVERRIDE {
- return connected_;
- }
- virtual bool IsConnectedAndIdle() const OVERRIDE {
- return connected_;
- }
+ virtual void Disconnect() OVERRIDE { connected_ = false; }
+ virtual bool IsConnected() const OVERRIDE { return connected_; }
+ virtual bool IsConnectedAndIdle() const OVERRIDE { return connected_; }
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE {
return ERR_UNEXPECTED;
}
@@ -118,30 +111,26 @@ class MockClientSocket : public StreamSocket {
SetIPv6Address(address);
return OK;
}
- virtual const BoundNetLog& NetLog() const OVERRIDE {
- return net_log_;
- }
+ virtual const BoundNetLog& NetLog() const OVERRIDE { return net_log_; }
virtual void SetSubresourceSpeculation() OVERRIDE {}
virtual void SetOmniboxSpeculation() OVERRIDE {}
virtual bool WasEverUsed() const OVERRIDE { return false; }
virtual bool UsingTCPFastOpen() const OVERRIDE { return false; }
- virtual bool WasNpnNegotiated() const OVERRIDE {
- return false;
- }
+ virtual bool WasNpnNegotiated() const OVERRIDE { return false; }
virtual NextProto GetNegotiatedProtocol() const OVERRIDE {
return kProtoUnknown;
}
- virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE {
- return false;
- }
+ virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE { return false; }
// Socket implementation.
- virtual int Read(IOBuffer* buf, int buf_len,
+ virtual int Read(IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) OVERRIDE {
return ERR_FAILED;
}
- virtual int Write(IOBuffer* buf, int buf_len,
+ virtual int Write(IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) OVERRIDE {
return ERR_FAILED;
}
@@ -160,8 +149,7 @@ class MockFailingClientSocket : public StreamSocket {
public:
MockFailingClientSocket(const AddressList& addrlist, net::NetLog* net_log)
: addrlist_(addrlist),
- net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) {
- }
+ net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) {}
// StreamSocket implementation.
virtual int Connect(const CompletionCallback& callback) OVERRIDE {
@@ -170,43 +158,35 @@ class MockFailingClientSocket : public StreamSocket {
virtual void Disconnect() OVERRIDE {}
- virtual bool IsConnected() const OVERRIDE {
- return false;
- }
- virtual bool IsConnectedAndIdle() const OVERRIDE {
- return false;
- }
+ virtual bool IsConnected() const OVERRIDE { return false; }
+ virtual bool IsConnectedAndIdle() const OVERRIDE { return false; }
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE {
return ERR_UNEXPECTED;
}
virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE {
return ERR_UNEXPECTED;
}
- virtual const BoundNetLog& NetLog() const OVERRIDE {
- return net_log_;
- }
+ virtual const BoundNetLog& NetLog() const OVERRIDE { return net_log_; }
virtual void SetSubresourceSpeculation() OVERRIDE {}
virtual void SetOmniboxSpeculation() OVERRIDE {}
virtual bool WasEverUsed() const OVERRIDE { return false; }
virtual bool UsingTCPFastOpen() const OVERRIDE { return false; }
- virtual bool WasNpnNegotiated() const OVERRIDE {
- return false;
- }
+ virtual bool WasNpnNegotiated() const OVERRIDE { return false; }
virtual NextProto GetNegotiatedProtocol() const OVERRIDE {
return kProtoUnknown;
}
- virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE {
- return false;
- }
+ virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE { return false; }
// Socket implementation.
- virtual int Read(IOBuffer* buf, int buf_len,
+ virtual int Read(IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) OVERRIDE {
return ERR_FAILED;
}
- virtual int Write(IOBuffer* buf, int buf_len,
+ virtual int Write(IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) OVERRIDE {
return ERR_FAILED;
}
@@ -226,39 +206,34 @@ class MockPendingClientSocket : public StreamSocket {
// or fail.
// |should_stall| indicates that this socket should never connect.
// |delay_ms| is the delay, in milliseconds, before simulating a connect.
- MockPendingClientSocket(
- const AddressList& addrlist,
- bool should_connect,
- bool should_stall,
- base::TimeDelta delay,
- net::NetLog* net_log)
+ MockPendingClientSocket(const AddressList& addrlist,
+ bool should_connect,
+ bool should_stall,
+ base::TimeDelta delay,
+ net::NetLog* net_log)
: should_connect_(should_connect),
should_stall_(should_stall),
delay_(delay),
is_connected_(false),
addrlist_(addrlist),
net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)),
- weak_factory_(this) {
- }
+ weak_factory_(this) {}
// StreamSocket implementation.
virtual int Connect(const CompletionCallback& callback) OVERRIDE {
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&MockPendingClientSocket::DoCallback,
- weak_factory_.GetWeakPtr(), callback),
+ weak_factory_.GetWeakPtr(),
+ callback),
delay_);
return ERR_IO_PENDING;
}
virtual void Disconnect() OVERRIDE {}
- virtual bool IsConnected() const OVERRIDE {
- return is_connected_;
- }
- virtual bool IsConnectedAndIdle() const OVERRIDE {
- return is_connected_;
- }
+ virtual bool IsConnected() const OVERRIDE { return is_connected_; }
+ virtual bool IsConnectedAndIdle() const OVERRIDE { return is_connected_; }
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE {
return ERR_UNEXPECTED;
}
@@ -271,31 +246,27 @@ class MockPendingClientSocket : public StreamSocket {
SetIPv6Address(address);
return OK;
}
- virtual const BoundNetLog& NetLog() const OVERRIDE {
- return net_log_;
- }
+ virtual const BoundNetLog& NetLog() const OVERRIDE { return net_log_; }
virtual void SetSubresourceSpeculation() OVERRIDE {}
virtual void SetOmniboxSpeculation() OVERRIDE {}
virtual bool WasEverUsed() const OVERRIDE { return false; }
virtual bool UsingTCPFastOpen() const OVERRIDE { return false; }
- virtual bool WasNpnNegotiated() const OVERRIDE {
- return false;
- }
+ virtual bool WasNpnNegotiated() const OVERRIDE { return false; }
virtual NextProto GetNegotiatedProtocol() const OVERRIDE {
return kProtoUnknown;
}
- virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE {
- return false;
- }
+ virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE { return false; }
// Socket implementation.
- virtual int Read(IOBuffer* buf, int buf_len,
+ virtual int Read(IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) OVERRIDE {
return ERR_FAILED;
}
- virtual int Write(IOBuffer* buf, int buf_len,
+ virtual int Write(IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) OVERRIDE {
return ERR_FAILED;
}
@@ -342,9 +313,12 @@ class MockClientSocketFactory : public ClientSocketFactory {
};
explicit MockClientSocketFactory(NetLog* net_log)
- : net_log_(net_log), allocation_count_(0),
- client_socket_type_(MOCK_CLIENT_SOCKET), client_socket_types_(NULL),
- client_socket_index_(0), client_socket_index_max_(0),
+ : net_log_(net_log),
+ allocation_count_(0),
+ client_socket_type_(MOCK_CLIENT_SOCKET),
+ client_socket_types_(NULL),
+ client_socket_index_(0),
+ client_socket_index_max_(0),
delay_(base::TimeDelta::FromMilliseconds(
ClientSocketPool::kMaxConnectRetryIntervalMs)) {}
@@ -377,21 +351,17 @@ class MockClientSocketFactory : public ClientSocketFactory {
return scoped_ptr<StreamSocket>(
new MockFailingClientSocket(addresses, net_log_));
case MOCK_PENDING_CLIENT_SOCKET:
- return scoped_ptr<StreamSocket>(
- new MockPendingClientSocket(
- addresses, true, false, base::TimeDelta(), net_log_));
+ return scoped_ptr<StreamSocket>(new MockPendingClientSocket(
+ addresses, true, false, base::TimeDelta(), net_log_));
case MOCK_PENDING_FAILING_CLIENT_SOCKET:
- return scoped_ptr<StreamSocket>(
- new MockPendingClientSocket(
- addresses, false, false, base::TimeDelta(), net_log_));
+ return scoped_ptr<StreamSocket>(new MockPendingClientSocket(
+ addresses, false, false, base::TimeDelta(), net_log_));
case MOCK_DELAYED_CLIENT_SOCKET:
- return scoped_ptr<StreamSocket>(
- new MockPendingClientSocket(
- addresses, true, false, delay_, net_log_));
+ return scoped_ptr<StreamSocket>(new MockPendingClientSocket(
+ addresses, true, false, delay_, net_log_));
case MOCK_STALLED_CLIENT_SOCKET:
- return scoped_ptr<StreamSocket>(
- new MockPendingClientSocket(
- addresses, true, true, base::TimeDelta(), net_log_));
+ return scoped_ptr<StreamSocket>(new MockPendingClientSocket(
+ addresses, true, true, base::TimeDelta(), net_log_));
default:
NOTREACHED();
return scoped_ptr<StreamSocket>(
@@ -408,9 +378,7 @@ class MockClientSocketFactory : public ClientSocketFactory {
return scoped_ptr<SSLClientSocket>();
}
- virtual void ClearSSLSessionCache() OVERRIDE {
- NOTIMPLEMENTED();
- }
+ virtual void ClearSSLSessionCache() OVERRIDE { NOTIMPLEMENTED(); }
int allocation_count() const { return allocation_count_; }
@@ -446,10 +414,10 @@ class TransportClientSocketPoolTest : public testing::Test {
TransportClientSocketPoolTest()
: connect_backup_jobs_enabled_(
ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true)),
- params_(
- new TransportSocketParams(HostPortPair("www.google.com", 80),
- false, false,
- OnHostResolutionCallback())),
+ params_(new TransportSocketParams(HostPortPair("www.google.com", 80),
+ false,
+ false,
+ OnHostResolutionCallback())),
histograms_(new ClientSocketPoolHistograms("TCPUnitTest")),
host_resolver_(new MockHostResolver),
client_socket_factory_(&net_log_),
@@ -458,8 +426,7 @@ class TransportClientSocketPoolTest : public testing::Test {
histograms_.get(),
host_resolver_.get(),
&client_socket_factory_,
- NULL) {
- }
+ NULL) {}
virtual ~TransportClientSocketPoolTest() {
internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
@@ -467,9 +434,11 @@ class TransportClientSocketPoolTest : public testing::Test {
}
int StartRequest(const std::string& group_name, RequestPriority priority) {
- scoped_refptr<TransportSocketParams> params(new TransportSocketParams(
- HostPortPair("www.google.com", 80), false, false,
- OnHostResolutionCallback()));
+ scoped_refptr<TransportSocketParams> params(
+ new TransportSocketParams(HostPortPair("www.google.com", 80),
+ false,
+ false,
+ OnHostResolutionCallback()));
return test_base_.StartRequestUsingPool(
&pool_, group_name, priority, params);
}
@@ -575,8 +544,8 @@ TEST(TransportConnectJobTest, MakeAddrListStartWithIPv4) {
TEST_F(TransportClientSocketPoolTest, Basic) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("a", params_, LOW, callback.callback(), &pool_,
- BoundNetLog());
+ int rv = handle.Init(
+ "a", params_, LOW, callback.callback(), &pool_, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -595,7 +564,11 @@ TEST_F(TransportClientSocketPoolTest, SetResolvePriorityOnInit) {
TestCompletionCallback callback;
ClientSocketHandle handle;
EXPECT_EQ(ERR_IO_PENDING,
- handle.Init("a", params_, priority, callback.callback(), &pool_,
+ handle.Init("a",
+ params_,
+ priority,
+ callback.callback(),
+ &pool_,
BoundNetLog()));
EXPECT_EQ(priority, host_resolver_->last_request_priority());
}
@@ -607,11 +580,14 @@ TEST_F(TransportClientSocketPoolTest, InitHostResolutionFailure) {
ClientSocketHandle handle;
HostPortPair host_port_pair("unresolvable.host.name", 80);
scoped_refptr<TransportSocketParams> dest(new TransportSocketParams(
- host_port_pair, false, false,
- OnHostResolutionCallback()));
+ host_port_pair, false, false, OnHostResolutionCallback()));
EXPECT_EQ(ERR_IO_PENDING,
- handle.Init("a", dest, kDefaultPriority, callback.callback(),
- &pool_, BoundNetLog()));
+ handle.Init("a",
+ dest,
+ kDefaultPriority,
+ callback.callback(),
+ &pool_,
+ BoundNetLog()));
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback.WaitForResult());
}
@@ -621,15 +597,23 @@ TEST_F(TransportClientSocketPoolTest, InitConnectionFailure) {
TestCompletionCallback callback;
ClientSocketHandle handle;
EXPECT_EQ(ERR_IO_PENDING,
- handle.Init("a", params_, kDefaultPriority, callback.callback(),
- &pool_, BoundNetLog()));
+ handle.Init("a",
+ params_,
+ kDefaultPriority,
+ callback.callback(),
+ &pool_,
+ BoundNetLog()));
EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult());
// Make the host resolutions complete synchronously this time.
host_resolver_->set_synchronous_mode(true);
EXPECT_EQ(ERR_CONNECTION_FAILED,
- handle.Init("a", params_, kDefaultPriority, callback.callback(),
- &pool_, BoundNetLog()));
+ handle.Init("a",
+ params_,
+ kDefaultPriority,
+ callback.callback(),
+ &pool_,
+ BoundNetLog()));
}
TEST_F(TransportClientSocketPoolTest, PendingRequests) {
@@ -735,8 +719,12 @@ TEST_F(TransportClientSocketPoolTest, CancelRequestClearGroup) {
TestCompletionCallback callback;
ClientSocketHandle handle;
EXPECT_EQ(ERR_IO_PENDING,
- handle.Init("a", params_, kDefaultPriority, callback.callback(),
- &pool_, BoundNetLog()));
+ handle.Init("a",
+ params_,
+ kDefaultPriority,
+ callback.callback(),
+ &pool_,
+ BoundNetLog()));
handle.Reset();
}
@@ -747,11 +735,19 @@ TEST_F(TransportClientSocketPoolTest, TwoRequestsCancelOne) {
TestCompletionCallback callback2;
EXPECT_EQ(ERR_IO_PENDING,
- handle.Init("a", params_, kDefaultPriority, callback.callback(),
- &pool_, BoundNetLog()));
+ handle.Init("a",
+ params_,
+ kDefaultPriority,
+ callback.callback(),
+ &pool_,
+ BoundNetLog()));
EXPECT_EQ(ERR_IO_PENDING,
- handle2.Init("a", params_, kDefaultPriority, callback2.callback(),
- &pool_, BoundNetLog()));
+ handle2.Init("a",
+ params_,
+ kDefaultPriority,
+ callback2.callback(),
+ &pool_,
+ BoundNetLog()));
handle.Reset();
@@ -765,15 +761,23 @@ TEST_F(TransportClientSocketPoolTest, ConnectCancelConnect) {
ClientSocketHandle handle;
TestCompletionCallback callback;
EXPECT_EQ(ERR_IO_PENDING,
- handle.Init("a", params_, kDefaultPriority, callback.callback(),
- &pool_, BoundNetLog()));
+ handle.Init("a",
+ params_,
+ kDefaultPriority,
+ callback.callback(),
+ &pool_,
+ BoundNetLog()));
handle.Reset();
TestCompletionCallback callback2;
EXPECT_EQ(ERR_IO_PENDING,
- handle.Init("a", params_, kDefaultPriority, callback2.callback(),
- &pool_, BoundNetLog()));
+ handle.Init("a",
+ params_,
+ kDefaultPriority,
+ callback2.callback(),
+ &pool_,
+ BoundNetLog()));
host_resolver_->set_synchronous_mode(true);
// At this point, handle has two ConnectingSockets out for it. Due to the
@@ -824,8 +828,7 @@ TEST_F(TransportClientSocketPoolTest, CancelRequest) {
ReleaseAllConnections(ClientSocketPoolTest::KEEP_ALIVE);
- EXPECT_EQ(kMaxSocketsPerGroup,
- client_socket_factory_.allocation_count());
+ EXPECT_EQ(kMaxSocketsPerGroup, client_socket_factory_.allocation_count());
EXPECT_EQ(requests()->size() - kMaxSocketsPerGroup, completion_count());
EXPECT_EQ(1, GetOrderOfRequest(1));
@@ -858,8 +861,7 @@ class RequestSocketCallback : public TestCompletionCallbackBase {
pool_(pool),
within_callback_(false),
callback_(base::Bind(&RequestSocketCallback::OnComplete,
- base::Unretained(this))) {
- }
+ base::Unretained(this))) {}
virtual ~RequestSocketCallback() {}
@@ -881,11 +883,13 @@ class RequestSocketCallback : public TestCompletionCallbackBase {
base::MessageLoop::current()->RunUntilIdle();
}
within_callback_ = true;
- scoped_refptr<TransportSocketParams> dest(new TransportSocketParams(
- HostPortPair("www.google.com", 80), false, false,
- OnHostResolutionCallback()));
- int rv = handle_->Init("a", dest, LOWEST, callback(), pool_,
- BoundNetLog());
+ scoped_refptr<TransportSocketParams> dest(
+ new TransportSocketParams(HostPortPair("www.google.com", 80),
+ false,
+ false,
+ OnHostResolutionCallback()));
+ int rv =
+ handle_->Init("a", dest, LOWEST, callback(), pool_, BoundNetLog());
EXPECT_EQ(OK, rv);
}
}
@@ -901,11 +905,13 @@ class RequestSocketCallback : public TestCompletionCallbackBase {
TEST_F(TransportClientSocketPoolTest, RequestTwice) {
ClientSocketHandle handle;
RequestSocketCallback callback(&handle, &pool_);
- scoped_refptr<TransportSocketParams> dest(new TransportSocketParams(
- HostPortPair("www.google.com", 80), false, false,
- OnHostResolutionCallback()));
- int rv = handle.Init("a", dest, LOWEST, callback.callback(), &pool_,
- BoundNetLog());
+ scoped_refptr<TransportSocketParams> dest(
+ new TransportSocketParams(HostPortPair("www.google.com", 80),
+ false,
+ false,
+ OnHostResolutionCallback()));
+ int rv = handle.Init(
+ "a", dest, LOWEST, callback.callback(), &pool_, BoundNetLog());
ASSERT_EQ(ERR_IO_PENDING, rv);
// The callback is going to request "www.google.com". We want it to complete
@@ -967,8 +973,8 @@ TEST_F(TransportClientSocketPoolTest, FailingActiveRequestWithPendingRequests) {
TEST_F(TransportClientSocketPoolTest, IdleSocketLoadTiming) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("a", params_, LOW, callback.callback(), &pool_,
- BoundNetLog());
+ int rv = handle.Init(
+ "a", params_, LOW, callback.callback(), &pool_, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -985,8 +991,8 @@ TEST_F(TransportClientSocketPoolTest, IdleSocketLoadTiming) {
// Now we should have 1 idle socket.
EXPECT_EQ(1, pool_.IdleSocketCount());
- rv = handle.Init("a", params_, LOW, callback.callback(), &pool_,
- BoundNetLog());
+ rv = handle.Init(
+ "a", params_, LOW, callback.callback(), &pool_, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ(0, pool_.IdleSocketCount());
TestLoadTimingInfoConnectedReused(handle);
@@ -995,8 +1001,8 @@ TEST_F(TransportClientSocketPoolTest, IdleSocketLoadTiming) {
TEST_F(TransportClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("a", params_, LOW, callback.callback(), &pool_,
- BoundNetLog());
+ int rv = handle.Init(
+ "a", params_, LOW, callback.callback(), &pool_, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -1023,26 +1029,22 @@ TEST_F(TransportClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) {
TEST_F(TransportClientSocketPoolTest, BackupSocketConnect) {
// Case 1 tests the first socket stalling, and the backup connecting.
MockClientSocketFactory::ClientSocketType case1_types[] = {
- // The first socket will not connect.
- MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET,
- // The second socket will connect more quickly.
- MockClientSocketFactory::MOCK_CLIENT_SOCKET
- };
+ // The first socket will not connect.
+ MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET,
+ // The second socket will connect more quickly.
+ MockClientSocketFactory::MOCK_CLIENT_SOCKET};
// Case 2 tests the first socket being slow, so that we start the
// second connect, but the second connect stalls, and we still
// complete the first.
MockClientSocketFactory::ClientSocketType case2_types[] = {
- // The first socket will connect, although delayed.
- MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET,
- // The second socket will not connect.
- MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET
- };
+ // The first socket will connect, although delayed.
+ MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET,
+ // The second socket will not connect.
+ MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET};
- MockClientSocketFactory::ClientSocketType* cases[2] = {
- case1_types,
- case2_types
- };
+ MockClientSocketFactory::ClientSocketType* cases[2] = {case1_types,
+ case2_types};
for (size_t index = 0; index < arraysize(cases); ++index) {
client_socket_factory_.set_client_socket_types(cases[index], 2);
@@ -1051,8 +1053,8 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketConnect) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("b", params_, LOW, callback.callback(), &pool_,
- BoundNetLog());
+ int rv = handle.Init(
+ "b", params_, LOW, callback.callback(), &pool_, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -1093,8 +1095,8 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketCancel) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("c", params_, LOW, callback.callback(), &pool_,
- BoundNetLog());
+ int rv = handle.Init(
+ "c", params_, LOW, callback.callback(), &pool_, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -1127,11 +1129,10 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketCancel) {
// connection fails.
TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterStall) {
MockClientSocketFactory::ClientSocketType case_types[] = {
- // The first socket will not connect.
- MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET,
- // The second socket will fail immediately.
- MockClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET
- };
+ // The first socket will not connect.
+ MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET,
+ // The second socket will fail immediately.
+ MockClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET};
client_socket_factory_.set_client_socket_types(case_types, 2);
@@ -1139,8 +1140,8 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterStall) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("b", params_, LOW, callback.callback(), &pool_,
- BoundNetLog());
+ int rv = handle.Init(
+ "b", params_, LOW, callback.callback(), &pool_, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -1174,11 +1175,10 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterStall) {
// fails.
TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterDelay) {
MockClientSocketFactory::ClientSocketType case_types[] = {
- // The first socket will connect, although delayed.
- MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET,
- // The second socket will not connect.
- MockClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET
- };
+ // The first socket will connect, although delayed.
+ MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET,
+ // The second socket will not connect.
+ MockClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET};
client_socket_factory_.set_client_socket_types(case_types, 2);
client_socket_factory_.set_delay(base::TimeDelta::FromSeconds(5));
@@ -1187,8 +1187,8 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterDelay) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("b", params_, LOW, callback.callback(), &pool_,
- BoundNetLog());
+ int rv = handle.Init(
+ "b", params_, LOW, callback.callback(), &pool_, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -1229,22 +1229,21 @@ TEST_F(TransportClientSocketPoolTest, IPv6FallbackSocketIPv4FinishesFirst) {
NULL);
MockClientSocketFactory::ClientSocketType case_types[] = {
- // This is the IPv6 socket.
- MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET,
- // This is the IPv4 socket.
- MockClientSocketFactory::MOCK_PENDING_CLIENT_SOCKET
- };
+ // This is the IPv6 socket.
+ MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET,
+ // This is the IPv4 socket.
+ MockClientSocketFactory::MOCK_PENDING_CLIENT_SOCKET};
client_socket_factory_.set_client_socket_types(case_types, 2);
// Resolve an AddressList with a IPv6 address first and then a IPv4 address.
- host_resolver_->rules()
- ->AddIPLiteralRule("*", "2:abcd::3:4:ff,2.2.2.2", std::string());
+ host_resolver_->rules()->AddIPLiteralRule(
+ "*", "2:abcd::3:4:ff,2.2.2.2", std::string());
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("a", params_, LOW, callback.callback(), &pool,
- BoundNetLog());
+ int rv =
+ handle.Init("a", params_, LOW, callback.callback(), &pool, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -1272,24 +1271,23 @@ TEST_F(TransportClientSocketPoolTest, IPv6FallbackSocketIPv6FinishesFirst) {
NULL);
MockClientSocketFactory::ClientSocketType case_types[] = {
- // This is the IPv6 socket.
- MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET,
- // This is the IPv4 socket.
- MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET
- };
+ // This is the IPv6 socket.
+ MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET,
+ // This is the IPv4 socket.
+ MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET};
client_socket_factory_.set_client_socket_types(case_types, 2);
client_socket_factory_.set_delay(base::TimeDelta::FromMilliseconds(
TransportConnectJob::kIPv6FallbackTimerInMs + 50));
// Resolve an AddressList with a IPv6 address first and then a IPv4 address.
- host_resolver_->rules()
- ->AddIPLiteralRule("*", "2:abcd::3:4:ff,2.2.2.2", std::string());
+ host_resolver_->rules()->AddIPLiteralRule(
+ "*", "2:abcd::3:4:ff,2.2.2.2", std::string());
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("a", params_, LOW, callback.callback(), &pool,
- BoundNetLog());
+ int rv =
+ handle.Init("a", params_, LOW, callback.callback(), &pool, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -1317,13 +1315,13 @@ TEST_F(TransportClientSocketPoolTest, IPv6NoIPv4AddressesToFallbackTo) {
MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET);
// Resolve an AddressList with only IPv6 addresses.
- host_resolver_->rules()
- ->AddIPLiteralRule("*", "2:abcd::3:4:ff,3:abcd::3:4:ff", std::string());
+ host_resolver_->rules()->AddIPLiteralRule(
+ "*", "2:abcd::3:4:ff,3:abcd::3:4:ff", std::string());
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("a", params_, LOW, callback.callback(), &pool,
- BoundNetLog());
+ int rv =
+ handle.Init("a", params_, LOW, callback.callback(), &pool, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());
@@ -1355,8 +1353,8 @@ TEST_F(TransportClientSocketPoolTest, IPv4HasNoFallback) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- int rv = handle.Init("a", params_, LOW, callback.callback(), &pool,
- BoundNetLog());
+ int rv =
+ handle.Init("a", params_, LOW, callback.callback(), &pool, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());
EXPECT_FALSE(handle.socket());

Powered by Google App Engine
This is Rietveld 408576698