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

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 7349023: Changed SPDY's ip connection pooling logic to only add the used IP, (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
« no previous file with comments | « no previous file | net/socket/ssl_client_socket_pool_unittest.cc » ('j') | net/spdy/spdy_session_pool.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction_unittest.cc
===================================================================
--- net/http/http_network_transaction_unittest.cc (revision 92863)
+++ net/http/http_network_transaction_unittest.cc (working copy)
@@ -8702,6 +8702,37 @@
}
}
+void IPPoolingPreloadHostCache(MockCachingHostResolver* host_resolver,
+ SpdySessionPoolPeer* pool_peer) {
+ const int kTestPort = 443;
+ struct TestHosts {
+ std::string name;
+ std::string iplist;
+ } test_hosts[] = {
+ { "www.google.com", "127.0.0.1"},
+ };
wtc 2011/07/19 22:12:36 The need to preload this entry, with the magic hos
ramant (doing other things) 2011/07/25 23:36:06 Done.
+
+ // Preload cache entries into HostCache.
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) {
+ host_resolver->rules()->AddIPLiteralRule(test_hosts[i].name,
+ test_hosts[i].iplist, "");
wtc 2011/07/19 22:12:36 Align this line with the argument on the previous
ramant (doing other things) 2011/07/25 23:36:06 Done.
+
+ AddressList addresses;
+ // This test requires that the HostResolver cache be populated. Normal
wtc 2011/07/19 22:12:36 By "This test", which test are you referring to?
ramant (doing other things) 2011/07/25 23:36:06 Done.
+ // code would have done this already, but we do it manually.
+ HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort));
+ host_resolver->Resolve(
+ info, &addresses, NULL, NULL, BoundNetLog());
+
+ // Setup a HostPortProxyPair
+ HostPortProxyPair pair = HostPortProxyPair(
+ HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct());
+
+ const addrinfo* address = addresses.head();
+ pool_peer->AddAlias(address, pair);
+ }
+}
+
TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) {
HttpStreamFactory::set_use_alternate_protocols(true);
HttpStreamFactory::set_next_protos(kExpectedNPNString);
@@ -8780,6 +8811,8 @@
AddressList ignored;
host_resolver.Resolve(resolve_info, &ignored, NULL, NULL, BoundNetLog());
+ IPPoolingPreloadHostCache(&host_resolver, &pool_peer);
+
HttpRequestInfo request2;
request2.method = "GET";
request2.url = GURL("https://www.gmail.com/");
@@ -8839,6 +8872,10 @@
return host_resolver_.RemoveObserver(observer);
}
+ MockCachingHostResolver* GetMockHostResolver() {
+ return &host_resolver_;
+ }
+
private:
MockCachingHostResolver host_resolver_;
const HostPortPair host_port_;
@@ -8928,6 +8965,8 @@
request2.load_flags = 0;
HttpNetworkTransaction trans2(session);
+ IPPoolingPreloadHostCache(host_resolver.GetMockHostResolver(), &pool_peer);
+
rv = trans2.Start(&request2, &callback, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(OK, callback.WaitForResult());
« no previous file with comments | « no previous file | net/socket/ssl_client_socket_pool_unittest.cc » ('j') | net/spdy/spdy_session_pool.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698