Chromium Code Reviews| 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()); |