| 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> | |
| 8 #include <memory> | 7 #include <memory> |
| 9 #include <string> | 8 #include <string> |
| 10 #include <tuple> | 9 #include <tuple> |
| 11 #include <vector> | 10 #include <vector> |
| 12 | 11 |
| 13 #include "base/bind.h" | 12 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 15 #include "base/location.h" | 14 #include "base/location.h" |
| 16 #include "base/macros.h" | 15 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 18 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 19 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 20 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 21 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/stl_util.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "base/synchronization/condition_variable.h" | 24 #include "base/synchronization/condition_variable.h" |
| 25 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
| 26 #include "base/test/test_timeouts.h" | 26 #include "base/test/test_timeouts.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 29 #include "net/base/address_list.h" | 29 #include "net/base/address_list.h" |
| 30 #include "net/base/ip_address.h" | 30 #include "net/base/ip_address.h" |
| 31 #include "net/base/mock_network_change_notifier.h" | 31 #include "net/base/mock_network_change_notifier.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 DISALLOW_COPY_AND_ASSIGN(MockHostResolverProc); | 197 DISALLOW_COPY_AND_ASSIGN(MockHostResolverProc); |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 bool AddressListContains(const AddressList& list, | 200 bool AddressListContains(const AddressList& list, |
| 201 const std::string& address, | 201 const std::string& address, |
| 202 uint16_t port) { | 202 uint16_t port) { |
| 203 IPAddress ip; | 203 IPAddress ip; |
| 204 bool rv = ip.AssignFromIPLiteral(address); | 204 bool rv = ip.AssignFromIPLiteral(address); |
| 205 DCHECK(rv); | 205 DCHECK(rv); |
| 206 return std::find(list.begin(), | 206 return base::ContainsValue(list, IPEndPoint(ip, port)); |
| 207 list.end(), | |
| 208 IPEndPoint(ip, port)) != list.end(); | |
| 209 } | 207 } |
| 210 | 208 |
| 211 // A wrapper for requests to a HostResolver. | 209 // A wrapper for requests to a HostResolver. |
| 212 class Request { | 210 class Request { |
| 213 public: | 211 public: |
| 214 // Base class of handlers to be executed on completion of requests. | 212 // Base class of handlers to be executed on completion of requests. |
| 215 struct Handler { | 213 struct Handler { |
| 216 virtual ~Handler() {} | 214 virtual ~Handler() {} |
| 217 virtual void Handle(Request* request) = 0; | 215 virtual void Handle(Request* request) = 0; |
| 218 }; | 216 }; |
| (...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2605 EXPECT_EQ(1, count2); | 2603 EXPECT_EQ(1, count2); |
| 2606 | 2604 |
| 2607 // Make another request to make sure both callbacks were cleared. | 2605 // Make another request to make sure both callbacks were cleared. |
| 2608 req = CreateRequest("just.testing", 80); | 2606 req = CreateRequest("just.testing", 80); |
| 2609 EXPECT_THAT(req->Resolve(), IsOk()); | 2607 EXPECT_THAT(req->Resolve(), IsOk()); |
| 2610 EXPECT_EQ(2, count1); | 2608 EXPECT_EQ(2, count1); |
| 2611 EXPECT_EQ(1, count2); | 2609 EXPECT_EQ(1, count2); |
| 2612 } | 2610 } |
| 2613 | 2611 |
| 2614 } // namespace net | 2612 } // namespace net |
| OLD | NEW |