| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/dns/host_resolver_impl.h" | 5 #include "net/dns/host_resolver_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 AddDnsRule("4nx", dns_protocol::kTypeA, MockDnsClientRule::OK); | 1270 AddDnsRule("4nx", dns_protocol::kTypeA, MockDnsClientRule::OK); |
| 1271 AddDnsRule("4nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL_ASYNC); | 1271 AddDnsRule("4nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL_ASYNC); |
| 1272 CreateResolver(); | 1272 CreateResolver(); |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 void CreateResolver() { | 1275 void CreateResolver() { |
| 1276 resolver_.reset(new HostResolverImpl(HostCache::CreateDefaultCache(), | 1276 resolver_.reset(new HostResolverImpl(HostCache::CreateDefaultCache(), |
| 1277 DefaultLimits(), | 1277 DefaultLimits(), |
| 1278 DefaultParams(proc_.get()), | 1278 DefaultParams(proc_.get()), |
| 1279 NULL)); | 1279 NULL)); |
| 1280 // Disable IPv6 support probing. |
| 1281 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); |
| 1280 resolver_->SetDnsClient(CreateMockDnsClient(DnsConfig(), dns_rules_)); | 1282 resolver_->SetDnsClient(CreateMockDnsClient(DnsConfig(), dns_rules_)); |
| 1281 } | 1283 } |
| 1282 | 1284 |
| 1283 // Adds a rule to |dns_rules_|. Must be followed by |CreateResolver| to apply. | 1285 // Adds a rule to |dns_rules_|. Must be followed by |CreateResolver| to apply. |
| 1284 void AddDnsRule(const std::string& prefix, | 1286 void AddDnsRule(const std::string& prefix, |
| 1285 uint16 qtype, | 1287 uint16 qtype, |
| 1286 MockDnsClientRule::Result result) { | 1288 MockDnsClientRule::Result result) { |
| 1287 dns_rules_.push_back(MockDnsClientRule(prefix, qtype, result)); | 1289 dns_rules_.push_back(MockDnsClientRule(prefix, qtype, result)); |
| 1288 } | 1290 } |
| 1289 | 1291 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 ChangeDnsConfig(config); | 1643 ChangeDnsConfig(config); |
| 1642 req = CreateRequest(info); | 1644 req = CreateRequest(info); |
| 1643 // Expect synchronous resolution from DnsHosts. | 1645 // Expect synchronous resolution from DnsHosts. |
| 1644 EXPECT_EQ(OK, req->Resolve()); | 1646 EXPECT_EQ(OK, req->Resolve()); |
| 1645 | 1647 |
| 1646 EXPECT_EQ(saw_ipv4, req->HasAddress("127.0.0.1", 80)); | 1648 EXPECT_EQ(saw_ipv4, req->HasAddress("127.0.0.1", 80)); |
| 1647 EXPECT_EQ(saw_ipv6, req->HasAddress("::1", 80)); | 1649 EXPECT_EQ(saw_ipv6, req->HasAddress("::1", 80)); |
| 1648 } | 1650 } |
| 1649 | 1651 |
| 1650 } // namespace net | 1652 } // namespace net |
| OLD | NEW |