diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 03:44:18 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 03:44:18 +0000 |
commit | 86a782ce247e94a7b4da42f79603ba372870cbfc (patch) | |
tree | 9773ae2e6b57df3e3c5536e7a52fc45211461de8 | |
parent | a14c261b32f0915842c305dfbc958c49af6905da (diff) | |
download | chromium_src-86a782ce247e94a7b4da42f79603ba372870cbfc.zip chromium_src-86a782ce247e94a7b4da42f79603ba372870cbfc.tar.gz chromium_src-86a782ce247e94a7b4da42f79603ba372870cbfc.tar.bz2 |
Flag myIpAddress requests for chromeos
This is a follow-up to https://codereview.chromium.org/238433003
We need to differentiate between myIpAddress requests and other
localhost requests so that local web servers and tests work correctly.
BUG=387109
Review URL: https://codereview.chromium.org/355953002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280230 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chromeos/network/host_resolver_impl_chromeos.cc | 2 | ||||
-rw-r--r-- | chromeos/network/host_resolver_impl_chromeos_unittest.cc | 1 | ||||
-rw-r--r-- | net/dns/host_resolver.cc | 3 | ||||
-rw-r--r-- | net/dns/host_resolver.h | 7 | ||||
-rw-r--r-- | net/proxy/proxy_resolver_v8_tracing.cc | 7 |
5 files changed, 17 insertions, 3 deletions
diff --git a/chromeos/network/host_resolver_impl_chromeos.cc b/chromeos/network/host_resolver_impl_chromeos.cc index ad946e5..ebeb27aa 100644 --- a/chromeos/network/host_resolver_impl_chromeos.cc +++ b/chromeos/network/host_resolver_impl_chromeos.cc @@ -162,7 +162,7 @@ bool HostResolverImplChromeOS::ResolveLocalIPAddress( const RequestInfo& info, net::AddressList* addresses) { DCHECK(thread_checker_.CalledOnValidThread()); - if (info.hostname() != net::GetHostName() || ipv4_address_.empty()) + if (!info.is_my_ip_address() || ipv4_address_.empty()) return false; // Use IPConfig data for localhost address lookup. diff --git a/chromeos/network/host_resolver_impl_chromeos_unittest.cc b/chromeos/network/host_resolver_impl_chromeos_unittest.cc index 535eec9..e27175ed 100644 --- a/chromeos/network/host_resolver_impl_chromeos_unittest.cc +++ b/chromeos/network/host_resolver_impl_chromeos_unittest.cc @@ -156,6 +156,7 @@ TEST_F(HostResolverImplChromeOSTest, Resolve) { net::HostResolver::RequestInfo info( net::HostPortPair(net::GetHostName(), 80)); info.set_address_family(net::ADDRESS_FAMILY_IPV4); + info.set_is_my_ip_address(true); EXPECT_EQ(net::OK, CallResolve(info)); ASSERT_EQ(1u, addresses_.size()); std::string expected = base::StringPrintf("%s:%d", kTestIPv4Address, 0); diff --git a/net/dns/host_resolver.cc b/net/dns/host_resolver.cc index 147a5a6e..3b6ea04 100644 --- a/net/dns/host_resolver.cc +++ b/net/dns/host_resolver.cc @@ -94,7 +94,8 @@ HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair) address_family_(ADDRESS_FAMILY_UNSPECIFIED), host_resolver_flags_(0), allow_cached_response_(true), - is_speculative_(false) {} + is_speculative_(false), + is_my_ip_address_(false) {} HostResolver::~HostResolver() { } diff --git a/net/dns/host_resolver.h b/net/dns/host_resolver.h index 5216329..5b3b3c7 100644 --- a/net/dns/host_resolver.h +++ b/net/dns/host_resolver.h @@ -88,6 +88,9 @@ class NET_EXPORT HostResolver { bool is_speculative() const { return is_speculative_; } void set_is_speculative(bool b) { is_speculative_ = b; } + bool is_my_ip_address() const { return is_my_ip_address_; } + void set_is_my_ip_address(bool b) { is_my_ip_address_ = b; } + private: // The hostname to resolve, and the port to use in resulting sockaddrs. HostPortPair host_port_pair_; @@ -103,6 +106,10 @@ class NET_EXPORT HostResolver { // Whether this request was started by the DNS prefetcher. bool is_speculative_; + + // Indicates a request for myIpAddress (to differentiate from other requests + // for localhost, currently used by Chrome OS). + bool is_my_ip_address_; }; // Opaque type used to cancel a request. diff --git a/net/proxy/proxy_resolver_v8_tracing.cc b/net/proxy/proxy_resolver_v8_tracing.cc index f772dc1..9be256a4 100644 --- a/net/proxy/proxy_resolver_v8_tracing.cc +++ b/net/proxy/proxy_resolver_v8_tracing.cc @@ -973,7 +973,12 @@ HostResolver::RequestInfo ProxyResolverV8Tracing::Job::MakeDnsRequestInfo( } HostResolver::RequestInfo info(host_port); - + // Flag myIpAddress requests. + if (op == MY_IP_ADDRESS || op == MY_IP_ADDRESS_EX) { + // TODO: Provide a RequestInfo construction mechanism that does not + // require a hostname and sets is_my_ip_address to true instead of this. + info.set_is_my_ip_address(true); + } // The non-ex flavors are limited to IPv4 results. if (op == MY_IP_ADDRESS || op == DNS_RESOLVE) { info.set_address_family(ADDRESS_FAMILY_IPV4); |