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

Unified Diff: net/base/mock_host_resolver.cc

Issue 303022: Disable IPv6 results for the PAC bindings:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
Index: net/base/mock_host_resolver.cc
===================================================================
--- net/base/mock_host_resolver.cc (revision 29686)
+++ net/base/mock_host_resolver.cc (working copy)
@@ -110,15 +110,18 @@
ResolverType resolver_type;
std::string host_pattern;
+ AddressFamily address_family;
std::string replacement;
int latency_ms; // In milliseconds.
Rule(ResolverType resolver_type,
const std::string& host_pattern,
+ AddressFamily address_family,
const std::string& replacement,
int latency_ms)
: resolver_type(resolver_type),
host_pattern(host_pattern),
+ address_family(address_family),
replacement(replacement),
latency_ms(latency_ms) {}
};
@@ -132,14 +135,24 @@
void RuleBasedHostResolverProc::AddRule(const std::string& host_pattern,
const std::string& replacement) {
+ AddRuleForFamily(host_pattern, ADDRESS_FAMILY_UNSPECIFIED, replacement);
+}
+
+void RuleBasedHostResolverProc::AddRuleForFamily(
+ const std::string& host_pattern,
+ AddressFamily address_family,
+ const std::string& replacement) {
DCHECK(!replacement.empty());
- Rule rule(Rule::kResolverTypeSystem, host_pattern, replacement, 0);
+ Rule rule(Rule::kResolverTypeSystem, host_pattern,
+ address_family, replacement, 0);
rules_.push_back(rule);
}
+
wtc 2009/10/22 21:53:54 Nit: delete one blank line here.
void RuleBasedHostResolverProc::AddIPv6Rule(const std::string& host_pattern,
const std::string& ipv6_literal) {
- Rule rule(Rule::kResolverTypeIPV6Literal, host_pattern, ipv6_literal, 0);
+ Rule rule(Rule::kResolverTypeIPV6Literal, host_pattern,
+ ADDRESS_FAMILY_UNSPECIFIED, ipv6_literal, 0);
wtc 2009/10/22 21:53:54 Why do you pass ADDRESS_FAMILY_UNSPECIFIED here? I
rules_.push_back(rule);
}
@@ -148,19 +161,22 @@
const std::string& replacement,
int latency_ms) {
DCHECK(!replacement.empty());
- Rule rule(Rule::kResolverTypeSystem, host_pattern, replacement, latency_ms);
+ Rule rule(Rule::kResolverTypeSystem, host_pattern,
+ ADDRESS_FAMILY_UNSPECIFIED, replacement, latency_ms);
rules_.push_back(rule);
}
void RuleBasedHostResolverProc::AllowDirectLookup(
const std::string& host_pattern) {
- Rule rule(Rule::kResolverTypeSystem, host_pattern, "", 0);
+ Rule rule(Rule::kResolverTypeSystem, host_pattern,
+ ADDRESS_FAMILY_UNSPECIFIED, "", 0);
rules_.push_back(rule);
}
void RuleBasedHostResolverProc::AddSimulatedFailure(
const std::string& host_pattern) {
- Rule rule(Rule::kResolverTypeFail, host_pattern, "", 0);
+ Rule rule(Rule::kResolverTypeFail, host_pattern,
+ ADDRESS_FAMILY_UNSPECIFIED, "", 0);
rules_.push_back(rule);
}
@@ -169,7 +185,11 @@
AddressList* addrlist) {
RuleList::iterator r;
for (r = rules_.begin(); r != rules_.end(); ++r) {
- if (MatchPattern(host, r->host_pattern)) {
+ bool matches_address_family =
+ r->address_family == ADDRESS_FAMILY_UNSPECIFIED ||
+ r->address_family == address_family;
+
+ if (matches_address_family && MatchPattern(host, r->host_pattern)) {
if (r->latency_ms != 0)
PlatformThread::Sleep(r->latency_ms);

Powered by Google App Engine
This is Rietveld 408576698