| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 DCHECK_EQ(OK, rv); | 122 DCHECK_EQ(OK, rv); |
| 123 AddRule(hostname, ADDRESS_FAMILY_UNSPECIFIED, result); | 123 AddRule(hostname, ADDRESS_FAMILY_UNSPECIFIED, result); |
| 124 AddRule(hostname, ADDRESS_FAMILY_IPV4, result); | 124 AddRule(hostname, ADDRESS_FAMILY_IPV4, result); |
| 125 AddRule(hostname, ADDRESS_FAMILY_IPV6, result); | 125 AddRule(hostname, ADDRESS_FAMILY_IPV6, result); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual int Resolve(const std::string& hostname, | 128 virtual int Resolve(const std::string& hostname, |
| 129 AddressFamily address_family, | 129 AddressFamily address_family, |
| 130 HostResolverFlags host_resolver_flags, | 130 HostResolverFlags host_resolver_flags, |
| 131 AddressList* addrlist, | 131 AddressList* addrlist, |
| 132 int* os_error) OVERRIDE { | 132 int* os_error) override { |
| 133 base::AutoLock lock(lock_); | 133 base::AutoLock lock(lock_); |
| 134 capture_list_.push_back(ResolveKey(hostname, address_family)); | 134 capture_list_.push_back(ResolveKey(hostname, address_family)); |
| 135 ++num_requests_waiting_; | 135 ++num_requests_waiting_; |
| 136 requests_waiting_.Broadcast(); | 136 requests_waiting_.Broadcast(); |
| 137 while (!num_slots_available_) | 137 while (!num_slots_available_) |
| 138 slots_available_.Wait(); | 138 slots_available_.Wait(); |
| 139 DCHECK_GT(num_requests_waiting_, 0u); | 139 DCHECK_GT(num_requests_waiting_, 0u); |
| 140 --num_slots_available_; | 140 --num_slots_available_; |
| 141 --num_requests_waiting_; | 141 --num_requests_waiting_; |
| 142 if (rules_.empty()) { | 142 if (rules_.empty()) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 int total_attempts_resolved() { return total_attempts_resolved_; } | 358 int total_attempts_resolved() { return total_attempts_resolved_; } |
| 359 | 359 |
| 360 // Returns the first attempt that that has resolved the host. | 360 // Returns the first attempt that that has resolved the host. |
| 361 int resolved_attempt_number() { return resolved_attempt_number_; } | 361 int resolved_attempt_number() { return resolved_attempt_number_; } |
| 362 | 362 |
| 363 // HostResolverProc methods. | 363 // HostResolverProc methods. |
| 364 virtual int Resolve(const std::string& host, | 364 virtual int Resolve(const std::string& host, |
| 365 AddressFamily address_family, | 365 AddressFamily address_family, |
| 366 HostResolverFlags host_resolver_flags, | 366 HostResolverFlags host_resolver_flags, |
| 367 AddressList* addrlist, | 367 AddressList* addrlist, |
| 368 int* os_error) OVERRIDE { | 368 int* os_error) override { |
| 369 bool wait_for_right_attempt_to_complete = true; | 369 bool wait_for_right_attempt_to_complete = true; |
| 370 { | 370 { |
| 371 base::AutoLock auto_lock(lock_); | 371 base::AutoLock auto_lock(lock_); |
| 372 ++current_attempt_number_; | 372 ++current_attempt_number_; |
| 373 if (current_attempt_number_ == attempt_number_to_resolve_) { | 373 if (current_attempt_number_ == attempt_number_to_resolve_) { |
| 374 resolved_attempt_number_ = current_attempt_number_; | 374 resolved_attempt_number_ = current_attempt_number_; |
| 375 wait_for_right_attempt_to_complete = false; | 375 wait_for_right_attempt_to_complete = false; |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 return test->CreateRequest(hostname); | 453 return test->CreateRequest(hostname); |
| 454 } | 454 } |
| 455 ScopedVector<Request>& requests() { return test->requests_; } | 455 ScopedVector<Request>& requests() { return test->requests_; } |
| 456 | 456 |
| 457 void DeleteResolver() { test->resolver_.reset(); } | 457 void DeleteResolver() { test->resolver_.reset(); } |
| 458 | 458 |
| 459 HostResolverImplTest* test; | 459 HostResolverImplTest* test; |
| 460 }; | 460 }; |
| 461 | 461 |
| 462 // testing::Test implementation: | 462 // testing::Test implementation: |
| 463 virtual void SetUp() OVERRIDE { | 463 virtual void SetUp() override { |
| 464 CreateResolver(); | 464 CreateResolver(); |
| 465 } | 465 } |
| 466 | 466 |
| 467 virtual void TearDown() OVERRIDE { | 467 virtual void TearDown() override { |
| 468 if (resolver_.get()) | 468 if (resolver_.get()) |
| 469 EXPECT_EQ(0u, resolver_->num_running_dispatcher_jobs_for_tests()); | 469 EXPECT_EQ(0u, resolver_->num_running_dispatcher_jobs_for_tests()); |
| 470 EXPECT_FALSE(proc_->HasBlockedRequests()); | 470 EXPECT_FALSE(proc_->HasBlockedRequests()); |
| 471 } | 471 } |
| 472 | 472 |
| 473 virtual void CreateResolverWithLimitsAndParams( | 473 virtual void CreateResolverWithLimitsAndParams( |
| 474 size_t max_concurrent_resolves, | 474 size_t max_concurrent_resolves, |
| 475 const HostResolverImpl::ProcTaskParams& params) { | 475 const HostResolverImpl::ProcTaskParams& params) { |
| 476 HostResolverImpl::Options options = DefaultOptions(); | 476 HostResolverImpl::Options options = DefaultOptions(); |
| 477 options.max_concurrent_resolves = max_concurrent_resolves; | 477 options.max_concurrent_resolves = max_concurrent_resolves; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 725 |
| 726 proc_->SignalAll(); | 726 proc_->SignalAll(); |
| 727 | 727 |
| 728 size_t num_requests = requests_.size(); | 728 size_t num_requests = requests_.size(); |
| 729 EXPECT_EQ(OK, requests_[num_requests - 1]->WaitForResult()); | 729 EXPECT_EQ(OK, requests_[num_requests - 1]->WaitForResult()); |
| 730 EXPECT_EQ(OK, requests_[num_requests - 2]->result()); | 730 EXPECT_EQ(OK, requests_[num_requests - 2]->result()); |
| 731 } | 731 } |
| 732 | 732 |
| 733 TEST_F(HostResolverImplTest, CancelWithinCallback) { | 733 TEST_F(HostResolverImplTest, CancelWithinCallback) { |
| 734 struct MyHandler : public Handler { | 734 struct MyHandler : public Handler { |
| 735 virtual void Handle(Request* req) OVERRIDE { | 735 virtual void Handle(Request* req) override { |
| 736 // Port 80 is the first request that the callback will be invoked for. | 736 // Port 80 is the first request that the callback will be invoked for. |
| 737 // While we are executing within that callback, cancel the other requests | 737 // While we are executing within that callback, cancel the other requests |
| 738 // in the job and start another request. | 738 // in the job and start another request. |
| 739 if (req->index() == 0) { | 739 if (req->index() == 0) { |
| 740 // Once "a:80" completes, it will cancel "a:81" and "a:82". | 740 // Once "a:80" completes, it will cancel "a:81" and "a:82". |
| 741 requests()[1]->Cancel(); | 741 requests()[1]->Cancel(); |
| 742 requests()[2]->Cancel(); | 742 requests()[2]->Cancel(); |
| 743 } | 743 } |
| 744 } | 744 } |
| 745 }; | 745 }; |
| 746 set_handler(new MyHandler()); | 746 set_handler(new MyHandler()); |
| 747 | 747 |
| 748 for (size_t i = 0; i < 4; ++i) { | 748 for (size_t i = 0; i < 4; ++i) { |
| 749 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("a", 80 + i)->Resolve()) << i; | 749 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("a", 80 + i)->Resolve()) << i; |
| 750 } | 750 } |
| 751 | 751 |
| 752 proc_->SignalMultiple(2u); // One for "a". One for "finalrequest". | 752 proc_->SignalMultiple(2u); // One for "a". One for "finalrequest". |
| 753 | 753 |
| 754 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 754 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
| 755 | 755 |
| 756 Request* final_request = CreateRequest("finalrequest", 70); | 756 Request* final_request = CreateRequest("finalrequest", 70); |
| 757 EXPECT_EQ(ERR_IO_PENDING, final_request->Resolve()); | 757 EXPECT_EQ(ERR_IO_PENDING, final_request->Resolve()); |
| 758 EXPECT_EQ(OK, final_request->WaitForResult()); | 758 EXPECT_EQ(OK, final_request->WaitForResult()); |
| 759 EXPECT_TRUE(requests_[3]->completed()); | 759 EXPECT_TRUE(requests_[3]->completed()); |
| 760 } | 760 } |
| 761 | 761 |
| 762 TEST_F(HostResolverImplTest, DeleteWithinCallback) { | 762 TEST_F(HostResolverImplTest, DeleteWithinCallback) { |
| 763 struct MyHandler : public Handler { | 763 struct MyHandler : public Handler { |
| 764 virtual void Handle(Request* req) OVERRIDE { | 764 virtual void Handle(Request* req) override { |
| 765 EXPECT_EQ("a", req->info().hostname()); | 765 EXPECT_EQ("a", req->info().hostname()); |
| 766 EXPECT_EQ(80, req->info().port()); | 766 EXPECT_EQ(80, req->info().port()); |
| 767 | 767 |
| 768 DeleteResolver(); | 768 DeleteResolver(); |
| 769 | 769 |
| 770 // Quit after returning from OnCompleted (to give it a chance at | 770 // Quit after returning from OnCompleted (to give it a chance at |
| 771 // incorrectly running the cancelled tasks). | 771 // incorrectly running the cancelled tasks). |
| 772 base::MessageLoop::current()->PostTask(FROM_HERE, | 772 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 773 base::MessageLoop::QuitClosure()); | 773 base::MessageLoop::QuitClosure()); |
| 774 } | 774 } |
| 775 }; | 775 }; |
| 776 set_handler(new MyHandler()); | 776 set_handler(new MyHandler()); |
| 777 | 777 |
| 778 for (size_t i = 0; i < 4; ++i) { | 778 for (size_t i = 0; i < 4; ++i) { |
| 779 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("a", 80 + i)->Resolve()) << i; | 779 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("a", 80 + i)->Resolve()) << i; |
| 780 } | 780 } |
| 781 | 781 |
| 782 proc_->SignalMultiple(1u); // One for "a". | 782 proc_->SignalMultiple(1u); // One for "a". |
| 783 | 783 |
| 784 // |MyHandler| will send quit message once all the requests have finished. | 784 // |MyHandler| will send quit message once all the requests have finished. |
| 785 base::MessageLoop::current()->Run(); | 785 base::MessageLoop::current()->Run(); |
| 786 } | 786 } |
| 787 | 787 |
| 788 TEST_F(HostResolverImplTest, DeleteWithinAbortedCallback) { | 788 TEST_F(HostResolverImplTest, DeleteWithinAbortedCallback) { |
| 789 struct MyHandler : public Handler { | 789 struct MyHandler : public Handler { |
| 790 virtual void Handle(Request* req) OVERRIDE { | 790 virtual void Handle(Request* req) override { |
| 791 EXPECT_EQ("a", req->info().hostname()); | 791 EXPECT_EQ("a", req->info().hostname()); |
| 792 EXPECT_EQ(80, req->info().port()); | 792 EXPECT_EQ(80, req->info().port()); |
| 793 | 793 |
| 794 DeleteResolver(); | 794 DeleteResolver(); |
| 795 | 795 |
| 796 // Quit after returning from OnCompleted (to give it a chance at | 796 // Quit after returning from OnCompleted (to give it a chance at |
| 797 // incorrectly running the cancelled tasks). | 797 // incorrectly running the cancelled tasks). |
| 798 base::MessageLoop::current()->PostTask(FROM_HERE, | 798 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 799 base::MessageLoop::QuitClosure()); | 799 base::MessageLoop::QuitClosure()); |
| 800 } | 800 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 820 EXPECT_EQ(ERR_NETWORK_CHANGED, requests_[0]->result()); | 820 EXPECT_EQ(ERR_NETWORK_CHANGED, requests_[0]->result()); |
| 821 EXPECT_EQ(ERR_IO_PENDING, requests_[1]->result()); | 821 EXPECT_EQ(ERR_IO_PENDING, requests_[1]->result()); |
| 822 EXPECT_EQ(ERR_IO_PENDING, requests_[2]->result()); | 822 EXPECT_EQ(ERR_IO_PENDING, requests_[2]->result()); |
| 823 EXPECT_EQ(ERR_IO_PENDING, requests_[3]->result()); | 823 EXPECT_EQ(ERR_IO_PENDING, requests_[3]->result()); |
| 824 // Clean up. | 824 // Clean up. |
| 825 proc_->SignalMultiple(requests_.size()); | 825 proc_->SignalMultiple(requests_.size()); |
| 826 } | 826 } |
| 827 | 827 |
| 828 TEST_F(HostResolverImplTest, StartWithinCallback) { | 828 TEST_F(HostResolverImplTest, StartWithinCallback) { |
| 829 struct MyHandler : public Handler { | 829 struct MyHandler : public Handler { |
| 830 virtual void Handle(Request* req) OVERRIDE { | 830 virtual void Handle(Request* req) override { |
| 831 if (req->index() == 0) { | 831 if (req->index() == 0) { |
| 832 // On completing the first request, start another request for "a". | 832 // On completing the first request, start another request for "a". |
| 833 // Since caching is disabled, this will result in another async request. | 833 // Since caching is disabled, this will result in another async request. |
| 834 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("a", 70)->Resolve()); | 834 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("a", 70)->Resolve()); |
| 835 } | 835 } |
| 836 } | 836 } |
| 837 }; | 837 }; |
| 838 set_handler(new MyHandler()); | 838 set_handler(new MyHandler()); |
| 839 | 839 |
| 840 // Turn off caching for this host resolver. | 840 // Turn off caching for this host resolver. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 851 | 851 |
| 852 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 852 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
| 853 ASSERT_EQ(5u, requests_.size()); | 853 ASSERT_EQ(5u, requests_.size()); |
| 854 EXPECT_EQ(OK, requests_.back()->WaitForResult()); | 854 EXPECT_EQ(OK, requests_.back()->WaitForResult()); |
| 855 | 855 |
| 856 EXPECT_EQ(2u, proc_->GetCaptureList().size()); | 856 EXPECT_EQ(2u, proc_->GetCaptureList().size()); |
| 857 } | 857 } |
| 858 | 858 |
| 859 TEST_F(HostResolverImplTest, BypassCache) { | 859 TEST_F(HostResolverImplTest, BypassCache) { |
| 860 struct MyHandler : public Handler { | 860 struct MyHandler : public Handler { |
| 861 virtual void Handle(Request* req) OVERRIDE { | 861 virtual void Handle(Request* req) override { |
| 862 if (req->index() == 0) { | 862 if (req->index() == 0) { |
| 863 // On completing the first request, start another request for "a". | 863 // On completing the first request, start another request for "a". |
| 864 // Since caching is enabled, this should complete synchronously. | 864 // Since caching is enabled, this should complete synchronously. |
| 865 std::string hostname = req->info().hostname(); | 865 std::string hostname = req->info().hostname(); |
| 866 EXPECT_EQ(OK, CreateRequest(hostname, 70)->Resolve()); | 866 EXPECT_EQ(OK, CreateRequest(hostname, 70)->Resolve()); |
| 867 EXPECT_EQ(OK, CreateRequest(hostname, 75)->ResolveFromCache()); | 867 EXPECT_EQ(OK, CreateRequest(hostname, 75)->ResolveFromCache()); |
| 868 | 868 |
| 869 // Ok good. Now make sure that if we ask to bypass the cache, it can no | 869 // Ok good. Now make sure that if we ask to bypass the cache, it can no |
| 870 // longer service the request synchronously. | 870 // longer service the request synchronously. |
| 871 HostResolver::RequestInfo info(HostPortPair(hostname, 71)); | 871 HostResolver::RequestInfo info(HostPortPair(hostname, 71)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 EXPECT_FALSE(requests_[2]->completed()); | 949 EXPECT_FALSE(requests_[2]->completed()); |
| 950 | 950 |
| 951 EXPECT_EQ(OK, requests_[2]->WaitForResult()); | 951 EXPECT_EQ(OK, requests_[2]->WaitForResult()); |
| 952 EXPECT_EQ(OK, requests_[1]->result()); | 952 EXPECT_EQ(OK, requests_[1]->result()); |
| 953 } | 953 } |
| 954 | 954 |
| 955 // Tests that a new Request made from the callback of a previously aborted one | 955 // Tests that a new Request made from the callback of a previously aborted one |
| 956 // will not be aborted. | 956 // will not be aborted. |
| 957 TEST_F(HostResolverImplTest, AbortOnlyExistingRequestsOnIPAddressChange) { | 957 TEST_F(HostResolverImplTest, AbortOnlyExistingRequestsOnIPAddressChange) { |
| 958 struct MyHandler : public Handler { | 958 struct MyHandler : public Handler { |
| 959 virtual void Handle(Request* req) OVERRIDE { | 959 virtual void Handle(Request* req) override { |
| 960 // Start new request for a different hostname to ensure that the order | 960 // Start new request for a different hostname to ensure that the order |
| 961 // of jobs in HostResolverImpl is not stable. | 961 // of jobs in HostResolverImpl is not stable. |
| 962 std::string hostname; | 962 std::string hostname; |
| 963 if (req->index() == 0) | 963 if (req->index() == 0) |
| 964 hostname = "zzz"; | 964 hostname = "zzz"; |
| 965 else if (req->index() == 1) | 965 else if (req->index() == 1) |
| 966 hostname = "aaa"; | 966 hostname = "aaa"; |
| 967 else if (req->index() == 2) | 967 else if (req->index() == 2) |
| 968 hostname = "eee"; | 968 hostname = "eee"; |
| 969 else | 969 else |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 return config; | 1332 return config; |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 // Specialized fixture for tests of DnsTask. | 1335 // Specialized fixture for tests of DnsTask. |
| 1336 class HostResolverImplDnsTest : public HostResolverImplTest { | 1336 class HostResolverImplDnsTest : public HostResolverImplTest { |
| 1337 public: | 1337 public: |
| 1338 HostResolverImplDnsTest() : dns_client_(NULL) {} | 1338 HostResolverImplDnsTest() : dns_client_(NULL) {} |
| 1339 | 1339 |
| 1340 protected: | 1340 protected: |
| 1341 // testing::Test implementation: | 1341 // testing::Test implementation: |
| 1342 virtual void SetUp() OVERRIDE { | 1342 virtual void SetUp() override { |
| 1343 AddDnsRule("nx", dns_protocol::kTypeA, MockDnsClientRule::FAIL, false); | 1343 AddDnsRule("nx", dns_protocol::kTypeA, MockDnsClientRule::FAIL, false); |
| 1344 AddDnsRule("nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); | 1344 AddDnsRule("nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); |
| 1345 AddDnsRule("ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1345 AddDnsRule("ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
| 1346 AddDnsRule("ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); | 1346 AddDnsRule("ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); |
| 1347 AddDnsRule("4ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1347 AddDnsRule("4ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
| 1348 AddDnsRule("4ok", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, false); | 1348 AddDnsRule("4ok", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, false); |
| 1349 AddDnsRule("6ok", dns_protocol::kTypeA, MockDnsClientRule::EMPTY, false); | 1349 AddDnsRule("6ok", dns_protocol::kTypeA, MockDnsClientRule::EMPTY, false); |
| 1350 AddDnsRule("6ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); | 1350 AddDnsRule("6ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); |
| 1351 AddDnsRule("4nx", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1351 AddDnsRule("4nx", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
| 1352 AddDnsRule("4nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); | 1352 AddDnsRule("4nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1374 AddDnsRule("4slow_6timeout", dns_protocol::kTypeA, | 1374 AddDnsRule("4slow_6timeout", dns_protocol::kTypeA, |
| 1375 MockDnsClientRule::OK, true); | 1375 MockDnsClientRule::OK, true); |
| 1376 AddDnsRule("4slow_6timeout", dns_protocol::kTypeAAAA, | 1376 AddDnsRule("4slow_6timeout", dns_protocol::kTypeAAAA, |
| 1377 MockDnsClientRule::TIMEOUT, false); | 1377 MockDnsClientRule::TIMEOUT, false); |
| 1378 CreateResolver(); | 1378 CreateResolver(); |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 // HostResolverImplTest implementation: | 1381 // HostResolverImplTest implementation: |
| 1382 virtual void CreateResolverWithLimitsAndParams( | 1382 virtual void CreateResolverWithLimitsAndParams( |
| 1383 size_t max_concurrent_resolves, | 1383 size_t max_concurrent_resolves, |
| 1384 const HostResolverImpl::ProcTaskParams& params) OVERRIDE { | 1384 const HostResolverImpl::ProcTaskParams& params) override { |
| 1385 HostResolverImpl::Options options = DefaultOptions(); | 1385 HostResolverImpl::Options options = DefaultOptions(); |
| 1386 options.max_concurrent_resolves = max_concurrent_resolves; | 1386 options.max_concurrent_resolves = max_concurrent_resolves; |
| 1387 resolver_.reset(new HostResolverImpl(options, NULL)); | 1387 resolver_.reset(new HostResolverImpl(options, NULL)); |
| 1388 resolver_->set_proc_params_for_test(params); | 1388 resolver_->set_proc_params_for_test(params); |
| 1389 // Disable IPv6 support probing. | 1389 // Disable IPv6 support probing. |
| 1390 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); | 1390 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); |
| 1391 dns_client_ = new MockDnsClient(DnsConfig(), dns_rules_); | 1391 dns_client_ = new MockDnsClient(DnsConfig(), dns_rules_); |
| 1392 resolver_->SetDnsClient(scoped_ptr<DnsClient>(dns_client_)); | 1392 resolver_->SetDnsClient(scoped_ptr<DnsClient>(dns_client_)); |
| 1393 } | 1393 } |
| 1394 | 1394 |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 | 2098 |
| 2099 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 2099 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
| 2100 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); | 2100 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); |
| 2101 EXPECT_EQ(OK, requests_[1]->WaitForResult()); | 2101 EXPECT_EQ(OK, requests_[1]->WaitForResult()); |
| 2102 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); | 2102 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); |
| 2103 EXPECT_EQ(OK, requests_[2]->WaitForResult()); | 2103 EXPECT_EQ(OK, requests_[2]->WaitForResult()); |
| 2104 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); | 2104 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); |
| 2105 } | 2105 } |
| 2106 | 2106 |
| 2107 } // namespace net | 2107 } // namespace net |
| OLD | NEW |