diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 22:04:32 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-15 22:04:32 +0000 |
commit | b59ff376c5d5b950774fcbe65727611d51832b75 (patch) | |
tree | a37598ddd4e9ec0530d5820bcce1f47bafa89289 /net/http/http_network_layer_unittest.cc | |
parent | 89d70652ad0bb9e7f419c17516fad279d8a4db32 (diff) | |
download | chromium_src-b59ff376c5d5b950774fcbe65727611d51832b75.zip chromium_src-b59ff376c5d5b950774fcbe65727611d51832b75.tar.gz chromium_src-b59ff376c5d5b950774fcbe65727611d51832b75.tar.bz2 |
Refactorings surrounding HostResolver:
(1) Extract HostResolver to an interface.
The existing concrete implementation is now named HostResolverImpl. This makes it possible to create mocks with more complex behavior (i.e. choose via rules if response will be sync vs async).
(2) Transform HostMapper into HostResolverProc.
Conceptually HostResolverProc maps a hostname to a socket address, whereas HostMapper mapped a hostname to another hostname (so you were still at the mercy of the system's host resolver). With HostResolverProc you can specify the exact AddressList, making it possible to run tests requiring IPv6 socketaddrs on systems (like WinXP) that don't actually support it.
(3) Add a MockHostResolver implementation of HostResolver.
This replaces the [ScopedHostMapper + RuleBasedHostMapper + HostResolver] combo. It is less clunky and a bit more expressive.
BUG=http://crbug.com/16452
R=willchan
TEST=existing
Review URL: http://codereview.chromium.org/149511
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20795 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_layer_unittest.cc')
-rw-r--r-- | net/http/http_network_layer_unittest.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc index 9fd35ea..b61ca3d 100644 --- a/net/http/http_network_layer_unittest.cc +++ b/net/http/http_network_layer_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/base/host_resolver.h" +#include "net/base/mock_host_resolver.h" #include "net/http/http_network_layer.h" #include "net/http/http_transaction_unittest.h" #include "net/proxy/proxy_service.h" @@ -16,7 +16,7 @@ class HttpNetworkLayerTest : public PlatformTest { TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull()); net::HttpNetworkLayer factory( - NULL, new net::HostResolver, proxy_service.get()); + NULL, new net::MockHostResolver, proxy_service.get()); scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); } @@ -24,7 +24,7 @@ TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { TEST_F(HttpNetworkLayerTest, Suspend) { scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull()); net::HttpNetworkLayer factory( - NULL, new net::HostResolver, proxy_service.get()); + NULL, new net::MockHostResolver, proxy_service.get()); scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction()); trans.reset(); @@ -56,7 +56,7 @@ TEST_F(HttpNetworkLayerTest, GET) { mock_socket_factory.AddMockSocket(&data); scoped_ptr<net::ProxyService> proxy_service(net::ProxyService::CreateNull()); - net::HttpNetworkLayer factory(&mock_socket_factory, new net::HostResolver, + net::HttpNetworkLayer factory(&mock_socket_factory, new net::MockHostResolver, proxy_service.get()); TestCompletionCallback callback; |