summaryrefslogtreecommitdiffstats
path: root/net/proxy
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 22:04:32 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 22:04:32 +0000
commitb59ff376c5d5b950774fcbe65727611d51832b75 (patch)
treea37598ddd4e9ec0530d5820bcce1f47bafa89289 /net/proxy
parent89d70652ad0bb9e7f419c17516fad279d8a4db32 (diff)
downloadchromium_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/proxy')
-rw-r--r--net/proxy/proxy_resolver_perftest.cc4
-rw-r--r--net/proxy/proxy_resolver_v8.h2
-rw-r--r--net/proxy/proxy_resolver_v8_unittest.cc14
-rw-r--r--net/proxy/proxy_script_fetcher_unittest.cc2
4 files changed, 13 insertions, 9 deletions
diff --git a/net/proxy/proxy_resolver_perftest.cc b/net/proxy/proxy_resolver_perftest.cc
index 22f2350..7c74e72 100644
--- a/net/proxy/proxy_resolver_perftest.cc
+++ b/net/proxy/proxy_resolver_perftest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/perftimer.h"
+#include "net/base/mock_host_resolver.h"
#include "net/proxy/proxy_resolver_v8.h"
#include "net/url_request/url_request_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -186,7 +187,8 @@ TEST(ProxyResolverPerfTest, ProxyResolverMac) {
TEST(ProxyResolverPerfTest, ProxyResolverV8) {
net::ProxyResolverV8::JSBindings* js_bindings =
- net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, NULL);
+ net::ProxyResolverV8::CreateDefaultBindings(
+ new net::MockHostResolver, NULL);
net::ProxyResolverV8 resolver(js_bindings);
PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8");
diff --git a/net/proxy/proxy_resolver_v8.h b/net/proxy/proxy_resolver_v8.h
index 3bf2bec..6fbc968 100644
--- a/net/proxy/proxy_resolver_v8.h
+++ b/net/proxy/proxy_resolver_v8.h
@@ -56,7 +56,7 @@ class ProxyResolverV8 : public ProxyResolver {
// Creates a default javascript bindings implementation that will:
// - Send script error messages to LOG(INFO)
// - Send script alert()s to LOG(INFO)
- // - Use the provided host mapper to service dnsResolve().
+ // - Use the provided host resolver to service dnsResolve().
//
// For clients that need more control (for example, sending the script output
// to a UI widget), use the ProxyResolverV8(JSBindings*) and specify your
diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc
index 7fab7d7..86544d5 100644
--- a/net/proxy/proxy_resolver_v8_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_unittest.cc
@@ -6,7 +6,7 @@
#include "base/string_util.h"
#include "base/path_service.h"
#include "googleurl/src/gurl.h"
-#include "net/base/host_resolver.h"
+#include "net/base/mock_host_resolver.h"
#include "net/base/net_errors.h"
#include "net/proxy/proxy_resolver_v8.h"
#include "net/proxy/proxy_info.h"
@@ -379,7 +379,8 @@ TEST(ProxyResolverV8Test, V8Bindings) {
TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) {
// Get a hold of a DefaultJSBindings* (it is a hidden impl class).
scoped_ptr<net::ProxyResolverV8::JSBindings> bindings(
- net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, NULL));
+ net::ProxyResolverV8::CreateDefaultBindings(
+ new net::MockHostResolver, NULL));
// Considered an error.
EXPECT_EQ("", bindings->DnsResolve(""));
@@ -411,7 +412,7 @@ TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) {
// THIS TEST IS CURRENTLY FLAWED.
//
// Since we are running in unit-test mode, the HostResolve is using a
- // mock HostMapper, which will always return 127.0.0.1, without going
+ // mock HostResolverProc, which will always return 127.0.0.1, without going
// through the real codepaths.
//
// It is important that these tests be run with the real thing, since we
@@ -430,10 +431,11 @@ TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) {
TEST(ProxyResolverV8DefaultBindingsTest, MyIpAddress) {
// Get a hold of a DefaultJSBindings* (it is a hidden impl class).
scoped_ptr<net::ProxyResolverV8::JSBindings> bindings(
- net::ProxyResolverV8::CreateDefaultBindings(new net::HostResolver, NULL));
+ net::ProxyResolverV8::CreateDefaultBindings(
+ new net::MockHostResolver, NULL));
- // Our ip address is always going to be 127.0.0.1, since we are using a
- // mock host mapper when running in unit-test mode.
+ // Our IP address is always going to be 127.0.0.1, since we are using a
+ // mock host resolver.
std::string my_ip_address = bindings->MyIpAddress();
EXPECT_EQ("127.0.0.1", my_ip_address);
diff --git a/net/proxy/proxy_script_fetcher_unittest.cc b/net/proxy/proxy_script_fetcher_unittest.cc
index 8a7cfb5..8a8030b 100644
--- a/net/proxy/proxy_script_fetcher_unittest.cc
+++ b/net/proxy/proxy_script_fetcher_unittest.cc
@@ -30,7 +30,7 @@ class RequestContext : public URLRequestContext {
public:
RequestContext() {
net::ProxyConfig no_proxy;
- host_resolver_ = new net::HostResolver;
+ host_resolver_ = net::CreateSystemHostResolver();
proxy_service_ = net::ProxyService::CreateFixed(no_proxy);
http_transaction_factory_ =