OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/base/host_resolver.h" | 5 #include "net/base/host_resolver.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <ws2tcpip.h> | 8 #include <ws2tcpip.h> |
9 #include <wspiapi.h> | 9 #include <wspiapi.h> |
10 #elif defined(OS_POSIX) | 10 #elif defined(OS_POSIX) |
11 #include <netdb.h> | 11 #include <netdb.h> |
12 #endif | 12 #endif |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
18 #include "base/ref_counted.h" | 18 #include "base/ref_counted.h" |
19 #include "net/base/address_list.h" | 19 #include "net/base/address_list.h" |
20 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
21 #include "net/base/dns_resolution_observer.h" | |
22 #include "net/base/host_resolver_unittest.h" | 21 #include "net/base/host_resolver_unittest.h" |
23 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
25 | 24 |
26 using net::RuleBasedHostMapper; | 25 using net::RuleBasedHostMapper; |
27 using net::ScopedHostMapper; | 26 using net::ScopedHostMapper; |
28 using net::WaitingHostMapper; | 27 using net::WaitingHostMapper; |
29 | 28 |
30 // TODO(eroman): | 29 // TODO(eroman): |
31 // - Test mixing async with sync (in particular how does sync update the | 30 // - Test mixing async with sync (in particular how does sync update the |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 const net::HostResolver::RequestInfo& b) { | 689 const net::HostResolver::RequestInfo& b) { |
691 return a.hostname() == b.hostname() && | 690 return a.hostname() == b.hostname() && |
692 a.port() == b.port() && | 691 a.port() == b.port() && |
693 a.allow_cached_response() == b.allow_cached_response() && | 692 a.allow_cached_response() == b.allow_cached_response() && |
694 a.is_speculative() == b.is_speculative() && | 693 a.is_speculative() == b.is_speculative() && |
695 a.referrer() == b.referrer(); | 694 a.referrer() == b.referrer(); |
696 } | 695 } |
697 | 696 |
698 // Observer that just makes note of how it was called. The test code can then | 697 // Observer that just makes note of how it was called. The test code can then |
699 // inspect to make sure it was called with the right parameters. | 698 // inspect to make sure it was called with the right parameters. |
700 class CapturingObserver : public net::DnsResolutionObserver { | 699 class CapturingObserver : public net::HostResolver::Observer { |
701 public: | 700 public: |
702 // DnsResolutionObserver methods: | 701 // DnsResolutionObserver methods: |
703 virtual void OnStartResolution(int id, | 702 virtual void OnStartResolution(int id, |
704 const net::HostResolver::RequestInfo& info) { | 703 const net::HostResolver::RequestInfo& info) { |
705 start_log.push_back(StartEntry(id, info)); | 704 start_log.push_back(StartEntry(id, info)); |
706 } | 705 } |
707 | 706 |
708 virtual void OnFinishResolutionWithStatus( | 707 virtual void OnFinishResolutionWithStatus( |
709 int id, | 708 int id, |
710 bool was_resolved, | 709 bool was_resolved, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 // Resolve "host3" | 783 // Resolve "host3" |
785 net::HostResolver::RequestInfo info3("host3", 70); | 784 net::HostResolver::RequestInfo info3("host3", 70); |
786 host_resolver.Resolve(info3, &addrlist, NULL, NULL); | 785 host_resolver.Resolve(info3, &addrlist, NULL, NULL); |
787 | 786 |
788 // No effect this time, since observer was removed. | 787 // No effect this time, since observer was removed. |
789 EXPECT_EQ(2U, observer.start_log.size()); | 788 EXPECT_EQ(2U, observer.start_log.size()); |
790 EXPECT_EQ(2U, observer.finish_log.size()); | 789 EXPECT_EQ(2U, observer.finish_log.size()); |
791 } | 790 } |
792 | 791 |
793 } // namespace | 792 } // namespace |
OLD | NEW |