summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 19:12:41 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 19:12:41 +0000
commitd27ab3ee72bb5dc3c39f385dec7724c769562a0d (patch)
treeee0dc8d6d2d5c416513ec253b7d63cd99c47f2e8 /net/socket
parent861495631d353725531bc476a6c60510029f447f (diff)
downloadchromium_src-d27ab3ee72bb5dc3c39f385dec7724c769562a0d.zip
chromium_src-d27ab3ee72bb5dc3c39f385dec7724c769562a0d.tar.gz
chromium_src-d27ab3ee72bb5dc3c39f385dec7724c769562a0d.tar.bz2
Fix transaction hang when downloading certain FTP files.
TEST=Covered by net_unittests. http://crbug.com/19855 Review URL: http://codereview.chromium.org/174428 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/socket_test_util.cc21
-rw-r--r--net/socket/socket_test_util.h11
2 files changed, 29 insertions, 3 deletions
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index b1af59f..4b6a3ad 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -290,17 +290,32 @@ void MockClientSocketFactory::ResetNextMockIndexes() {
mock_ssl_sockets_.ResetNextIndex();
}
+ClientSocket* MockClientSocketFactory::GetMockTCPClientSocket(int index) const {
+ return tcp_client_sockets_[index];
+}
+
+SSLClientSocket* MockClientSocketFactory::GetMockSSLClientSocket(
+ int index) const {
+ return ssl_client_sockets_[index];
+}
+
ClientSocket* MockClientSocketFactory::CreateTCPClientSocket(
const AddressList& addresses) {
- return new MockTCPClientSocket(addresses, mock_sockets_.GetNext());
+ ClientSocket* socket =
+ new MockTCPClientSocket(addresses, mock_sockets_.GetNext());
+ tcp_client_sockets_.push_back(socket);
+ return socket;
}
SSLClientSocket* MockClientSocketFactory::CreateSSLClientSocket(
ClientSocket* transport_socket,
const std::string& hostname,
const SSLConfig& ssl_config) {
- return new MockSSLClientSocket(transport_socket, hostname, ssl_config,
- mock_ssl_sockets_.GetNext());
+ SSLClientSocket* socket =
+ new MockSSLClientSocket(transport_socket, hostname, ssl_config,
+ mock_ssl_sockets_.GetNext());
+ ssl_client_sockets_.push_back(socket);
+ return socket;
}
int TestSocketRequest::WaitForResult() {
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 76d4df1f..75f3a37 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -200,6 +200,13 @@ class MockClientSocketFactory : public ClientSocketFactory {
void AddMockSSLSocket(MockSSLSocket* socket);
void ResetNextMockIndexes();
+ // Return |index|-th ClientSocket (starting from 0) that the factory created.
+ ClientSocket* GetMockTCPClientSocket(int index) const;
+
+ // Return |index|-th SSLClientSocket (starting from 0) that the factory
+ // created.
+ SSLClientSocket* GetMockSSLClientSocket(int index) const;
+
// ClientSocketFactory
virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses);
virtual SSLClientSocket* CreateSSLClientSocket(
@@ -210,6 +217,10 @@ class MockClientSocketFactory : public ClientSocketFactory {
private:
MockSocketArray<MockSocket> mock_sockets_;
MockSocketArray<MockSSLSocket> mock_ssl_sockets_;
+
+ // Store pointers to handed out sockets in case the test wants to get them.
+ std::vector<ClientSocket*> tcp_client_sockets_;
+ std::vector<SSLClientSocket*> ssl_client_sockets_;
};
class MockClientSocket : public net::SSLClientSocket {