| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_impl.h" | 5 #include "net/base/host_resolver_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/stringprintf.h" |
| 13 #include "net/base/address_list.h" | 14 #include "net/base/address_list.h" |
| 14 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 15 #include "net/base/mock_host_resolver.h" | 16 #include "net/base/mock_host_resolver.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/base/net_log_unittest.h" | 18 #include "net/base/net_log_unittest.h" |
| 18 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| 19 #include "net/base/sys_addrinfo.h" | 20 #include "net/base/sys_addrinfo.h" |
| 20 #include "net/base/test_completion_callback.h" | 21 #include "net/base/test_completion_callback.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 class EchoingHostResolverProc : public HostResolverProc { | 131 class EchoingHostResolverProc : public HostResolverProc { |
| 131 public: | 132 public: |
| 132 EchoingHostResolverProc() : HostResolverProc(NULL) {} | 133 EchoingHostResolverProc() : HostResolverProc(NULL) {} |
| 133 | 134 |
| 134 virtual int Resolve(const std::string& hostname, | 135 virtual int Resolve(const std::string& hostname, |
| 135 AddressFamily address_family, | 136 AddressFamily address_family, |
| 136 HostResolverFlags host_resolver_flags, | 137 HostResolverFlags host_resolver_flags, |
| 137 AddressList* addrlist, | 138 AddressList* addrlist, |
| 138 int* os_error) { | 139 int* os_error) { |
| 139 // Encode the request's hostname and address_family in the output address. | 140 // Encode the request's hostname and address_family in the output address. |
| 140 std::string ip_literal = StringPrintf("192.%d.%d.%d", | 141 std::string ip_literal = base::StringPrintf("192.%d.%d.%d", |
| 141 static_cast<int>(hostname.size()), | 142 static_cast<int>(hostname.size()), |
| 142 static_cast<int>(hostname[0]), | 143 static_cast<int>(hostname[0]), |
| 143 static_cast<int>(address_family)); | 144 static_cast<int>(address_family)); |
| 144 | 145 |
| 145 return SystemHostResolverProc(ip_literal, | 146 return SystemHostResolverProc(ip_literal, |
| 146 ADDRESS_FAMILY_UNSPECIFIED, | 147 ADDRESS_FAMILY_UNSPECIFIED, |
| 147 host_resolver_flags, | 148 host_resolver_flags, |
| 148 addrlist, os_error); | 149 addrlist, os_error); |
| 149 } | 150 } |
| 150 }; | 151 }; |
| (...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 EXPECT_EQ("192.1.98.2", NetAddressToString(addrlist[1].head())); | 1641 EXPECT_EQ("192.1.98.2", NetAddressToString(addrlist[1].head())); |
| 1641 EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[2].head())); | 1642 EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[2].head())); |
| 1642 EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[3].head())); | 1643 EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[3].head())); |
| 1643 } | 1644 } |
| 1644 | 1645 |
| 1645 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. | 1646 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. |
| 1646 | 1647 |
| 1647 } // namespace | 1648 } // namespace |
| 1648 | 1649 |
| 1649 } // namespace net | 1650 } // namespace net |
| OLD | NEW |