summaryrefslogtreecommitdiffstats
path: root/net/http/http_network_transaction_unittest.cc
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 17:17:26 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 17:17:26 +0000
commita796bcec176ca3875a55346800b3a60a83e2dd89 (patch)
tree2533c17673ff50f4f101e803c2dff3bf8f5cbf7b /net/http/http_network_transaction_unittest.cc
parent35818452760c23c570b7947e00a3b38e733ce58e (diff)
downloadchromium_src-a796bcec176ca3875a55346800b3a60a83e2dd89.zip
chromium_src-a796bcec176ca3875a55346800b3a60a83e2dd89.tar.gz
chromium_src-a796bcec176ca3875a55346800b3a60a83e2dd89.tar.bz2
Implement SOCKSClientSocketPool
This is the first layered pool, so there are several infrastructure changes in this change as well. Add a ConnectionTimeout method to pools so that layered pools can timeout each phase. Add a name method to pools to support per pool UMA histograms. Change SOCKS sockets to take a ClientSocketHandle instead of a ClientSocket BUG=30357 (blocks an SSL Pool) TEST=existing unit tests Review URL: http://codereview.chromium.org/668097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42231 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_transaction_unittest.cc')
-rw-r--r--net/http/http_network_transaction_unittest.cc34
1 files changed, 26 insertions, 8 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index caf03fd..b25dcfb 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -182,9 +182,14 @@ std::string MockGetHostName() {
return "WTC-WIN7";
}
-class CaptureGroupNameSocketPool : public TCPClientSocketPool {
+template<typename EmulatedClientSocketPool, typename SocketSourceType>
+class CaptureGroupNameSocketPool : public EmulatedClientSocketPool {
public:
- CaptureGroupNameSocketPool() : TCPClientSocketPool(0, 0, NULL, NULL, NULL) {}
+ CaptureGroupNameSocketPool(HttpNetworkSession* session,
+ SocketSourceType* socket_source)
+ : EmulatedClientSocketPool(0, 0, "CaptureGroupNameTestPool",
+ session->host_resolver(), socket_source,
+ NULL) {}
const std::string last_group_name_received() const {
return last_group_name_;
}
@@ -216,11 +221,18 @@ class CaptureGroupNameSocketPool : public TCPClientSocketPool {
const ClientSocketHandle* handle) const {
return LOAD_STATE_IDLE;
}
+ virtual base::TimeDelta ConnectionTimeout() const {
+ return base::TimeDelta();
+ }
private:
std::string last_group_name_;
};
+typedef CaptureGroupNameSocketPool<TCPClientSocketPool, ClientSocketFactory>
+ CaptureGroupNameTCPSocketPool;
+typedef CaptureGroupNameSocketPool<SOCKSClientSocketPool, TCPClientSocketPool>
+ CaptureGroupNameSOCKSSocketPool;
//-----------------------------------------------------------------------------
TEST_F(HttpNetworkTransactionTest, Basic) {
@@ -3654,11 +3666,16 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForProxyConnections) {
SessionDependencies session_deps(
CreateFixedProxyService(tests[i].proxy_server));
- scoped_refptr<CaptureGroupNameSocketPool> conn_pool(
- new CaptureGroupNameSocketPool());
-
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
- session->tcp_socket_pool_ = conn_pool.get();
+
+ scoped_refptr<CaptureGroupNameTCPSocketPool> tcp_conn_pool(
+ new CaptureGroupNameTCPSocketPool(session.get(),
+ session->socket_factory()));
+ session->tcp_socket_pool_ = tcp_conn_pool.get();
+ scoped_refptr<CaptureGroupNameSOCKSSocketPool> socks_conn_pool(
+ new CaptureGroupNameSOCKSSocketPool(session.get(),
+ tcp_conn_pool.get()));
+ session->socks_socket_pool_ = socks_conn_pool.get();
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
@@ -3671,8 +3688,9 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForProxyConnections) {
// We do not complete this request, the dtor will clean the transaction up.
EXPECT_EQ(ERR_IO_PENDING, trans->Start(&request, &callback, NULL));
- EXPECT_EQ(tests[i].expected_group_name,
- conn_pool->last_group_name_received());
+ std::string allgroups = tcp_conn_pool->last_group_name_received() +
+ socks_conn_pool->last_group_name_received();
+ EXPECT_EQ(tests[i].expected_group_name, allgroups);
}
}