Index: net/socket/transport_client_socket_pool_test_util.cc |
diff --git a/net/socket/transport_client_socket_pool_test_util.cc b/net/socket/transport_client_socket_pool_test_util.cc |
index 82ed8e6a78ef11151acc555cbedf3244b3594e9d..352fd878fe516da09d663e36853ec702b3e139e9 100644 |
--- a/net/socket/transport_client_socket_pool_test_util.cc |
+++ b/net/socket/transport_client_socket_pool_test_util.cc |
@@ -69,6 +69,11 @@ class MockConnectClientSocket : public StreamSocket { |
bool WasNpnNegotiated() const override { return false; } |
NextProto GetNegotiatedProtocol() const override { return kProtoUnknown; } |
bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } |
+ void GetConnectionAttempts(ConnectionAttempts* out) const override { |
+ out->clear(); |
+ } |
+ void ClearConnectionAttempts() override {} |
+ void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} |
// Socket implementation. |
int Read(IOBuffer* buf, |
@@ -125,6 +130,13 @@ class MockFailingClientSocket : public StreamSocket { |
bool WasNpnNegotiated() const override { return false; } |
NextProto GetNegotiatedProtocol() const override { return kProtoUnknown; } |
bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } |
+ void GetConnectionAttempts(ConnectionAttempts* out) const override { |
+ out->clear(); |
+ for (const auto& addr : addrlist_) |
+ out->push_back(ConnectionAttempt(addr, ERR_CONNECTION_FAILED)); |
+ } |
+ void ClearConnectionAttempts() override {} |
+ void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} |
// Socket implementation. |
int Read(IOBuffer* buf, |
@@ -196,9 +208,16 @@ class MockTriggerableClientSocket : public StreamSocket { |
static scoped_ptr<StreamSocket> MakeMockStalledClientSocket( |
const AddressList& addrlist, |
- net::NetLog* net_log) { |
+ net::NetLog* net_log, |
+ bool failing) { |
scoped_ptr<MockTriggerableClientSocket> socket( |
new MockTriggerableClientSocket(addrlist, true, net_log)); |
+ if (failing) { |
+ DCHECK_LE(1u, addrlist.size()); |
+ ConnectionAttempts attempts; |
+ attempts.push_back(ConnectionAttempt(addrlist[0], ERR_CONNECTION_FAILED)); |
+ socket->AddConnectionAttempts(attempts); |
+ } |
return socket.Pass(); |
} |
@@ -236,6 +255,14 @@ class MockTriggerableClientSocket : public StreamSocket { |
bool WasNpnNegotiated() const override { return false; } |
NextProto GetNegotiatedProtocol() const override { return kProtoUnknown; } |
bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } |
+ void GetConnectionAttempts(ConnectionAttempts* out) const override { |
+ *out = connection_attempts_; |
+ } |
+ void ClearConnectionAttempts() override { connection_attempts_.clear(); } |
+ void AddConnectionAttempts(const ConnectionAttempts& attempts) override { |
+ connection_attempts_.insert(connection_attempts_.begin(), attempts.begin(), |
+ attempts.end()); |
+ } |
// Socket implementation. |
int Read(IOBuffer* buf, |
@@ -264,6 +291,7 @@ class MockTriggerableClientSocket : public StreamSocket { |
BoundNetLog net_log_; |
CompletionCallback callback_; |
bool use_tcp_fastopen_; |
+ ConnectionAttempts connection_attempts_; |
base::WeakPtrFactory<MockTriggerableClientSocket> weak_factory_; |
@@ -364,8 +392,11 @@ MockTransportClientSocketFactory::CreateTransportClientSocket( |
return MockTriggerableClientSocket::MakeMockDelayedClientSocket( |
addresses, false, delay_, net_log_); |
case MOCK_STALLED_CLIENT_SOCKET: |
- return MockTriggerableClientSocket::MakeMockStalledClientSocket(addresses, |
- net_log_); |
+ return MockTriggerableClientSocket::MakeMockStalledClientSocket( |
+ addresses, net_log_, false); |
+ case MOCK_STALLED_FAILING_CLIENT_SOCKET: |
+ return MockTriggerableClientSocket::MakeMockStalledClientSocket( |
+ addresses, net_log_, true); |
case MOCK_TRIGGERABLE_CLIENT_SOCKET: { |
scoped_ptr<MockTriggerableClientSocket> rv( |
new MockTriggerableClientSocket(addresses, true, net_log_)); |