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

Unified Diff: net/base/mock_host_resolver.cc

Issue 3231005: Fix remaining localhost resolution issues. (Closed)
Patch Set: Fix mock resolver to ignore network config-induced host resolver flags when using default flags. Created 10 years, 3 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
« net/base/host_resolver_proc.cc ('K') | « net/base/host_resolver_proc.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mock_host_resolver.cc
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index 2baeb26a20656a97a9164b45092617203b138ed5..8c2a9a406f4300a1d74256d6dc627fba69ac03f8 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -156,8 +156,10 @@ void RuleBasedHostResolverProc::AddRuleForAddressFamily(
AddressFamily address_family,
const std::string& replacement) {
DCHECK(!replacement.empty());
- Rule rule(Rule::kResolverTypeSystem, host_pattern,
- address_family, 0, replacement, "", 0);
+ HostResolverFlags flags = HOST_RESOLVER_LOOPBACK_ONLY |
+ HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6;
+ Rule rule(Rule::kResolverTypeSystem, host_pattern, address_family, flags,
+ replacement, "", 0);
rules_.push_back(rule);
}
@@ -169,13 +171,12 @@ void RuleBasedHostResolverProc::AddIPLiteralRule(
// consequently we do not support remapping them.
IPAddressNumber ip_number;
DCHECK(!ParseIPLiteralToNumber(host_pattern, &ip_number));
- Rule rule(Rule::kResolverTypeIPLiteral,
- host_pattern,
- ADDRESS_FAMILY_UNSPECIFIED,
- canonical_name.empty() ? 0 : HOST_RESOLVER_CANONNAME,
- ip_literal,
- canonical_name,
- 0);
+ HostResolverFlags flags = HOST_RESOLVER_LOOPBACK_ONLY |
+ HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6;
+ if (!canonical_name.empty())
+ flags |= HOST_RESOLVER_CANONNAME;
+ Rule rule(Rule::kResolverTypeIPLiteral, host_pattern,
+ ADDRESS_FAMILY_UNSPECIFIED, flags, ip_literal, canonical_name, 0);
rules_.push_back(rule);
}
@@ -184,22 +185,28 @@ void RuleBasedHostResolverProc::AddRuleWithLatency(
const std::string& replacement,
int latency_ms) {
DCHECK(!replacement.empty());
- Rule rule(Rule::kResolverTypeSystem, host_pattern,
- ADDRESS_FAMILY_UNSPECIFIED, 0, replacement, "", latency_ms);
+ HostResolverFlags flags = HOST_RESOLVER_LOOPBACK_ONLY |
+ HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6;
+ Rule rule(Rule::kResolverTypeSystem, host_pattern, ADDRESS_FAMILY_UNSPECIFIED,
+ flags, replacement, "", latency_ms);
rules_.push_back(rule);
}
void RuleBasedHostResolverProc::AllowDirectLookup(
const std::string& host_pattern) {
- Rule rule(Rule::kResolverTypeSystem, host_pattern,
- ADDRESS_FAMILY_UNSPECIFIED, 0, "", "", 0);
+ HostResolverFlags flags = HOST_RESOLVER_LOOPBACK_ONLY |
+ HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6;
+ Rule rule(Rule::kResolverTypeSystem, host_pattern, ADDRESS_FAMILY_UNSPECIFIED,
+ flags, "", "", 0);
rules_.push_back(rule);
}
void RuleBasedHostResolverProc::AddSimulatedFailure(
const std::string& host_pattern) {
- Rule rule(Rule::kResolverTypeFail, host_pattern,
- ADDRESS_FAMILY_UNSPECIFIED, 0, "", "", 0);
+ HostResolverFlags flags = HOST_RESOLVER_LOOPBACK_ONLY |
+ HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6;
+ Rule rule(Rule::kResolverTypeFail, host_pattern, ADDRESS_FAMILY_UNSPECIFIED,
+ flags, "", "", 0);
rules_.push_back(rule);
}
« net/base/host_resolver_proc.cc ('K') | « net/base/host_resolver_proc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698