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 #ifndef NET_BASE_MOCK_HOST_RESOLVER_H_ | 5 #ifndef NET_BASE_MOCK_HOST_RESOLVER_H_ |
6 #define NET_BASE_MOCK_HOST_RESOLVER_H_ | 6 #define NET_BASE_MOCK_HOST_RESOLVER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/waitable_event.h" | 10 #include "base/waitable_event.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Any hostname matching the given pattern will be replaced with the given | 100 // Any hostname matching the given pattern will be replaced with the given |
101 // replacement value. Usually, replacement should be an IP address literal. | 101 // replacement value. Usually, replacement should be an IP address literal. |
102 void AddRule(const std::string& host_pattern, | 102 void AddRule(const std::string& host_pattern, |
103 const std::string& replacement); | 103 const std::string& replacement); |
104 | 104 |
105 // Same as AddRule(), but further restricts to |address_family|. | 105 // Same as AddRule(), but further restricts to |address_family|. |
106 void AddRuleForAddressFamily(const std::string& host_pattern, | 106 void AddRuleForAddressFamily(const std::string& host_pattern, |
107 AddressFamily address_family, | 107 AddressFamily address_family, |
108 const std::string& replacement); | 108 const std::string& replacement); |
109 | 109 |
110 // Same as AddRule(), but the replacement is expected to be an IPV6 literal. | 110 // Same as AddRule(), but the replacement is expected to be an IPV4 literal. |
111 // You should use this in place of AddRule(), since the system's host resolver | 111 // This can be used in place of AddRule() to bypass the system's host |
112 // may not support IPv6 literals on all systems. Whereas this variant | 112 // resolver. |ipv4_literal| must be an IPv4 literal, typically taking the form |
113 // constructs the socket address directly so it will always work. | 113 // of "[0-255].[0-255].[0-255].[0-255]". |
| 114 // If |canonical-name| is non-empty, it is copied to the resulting AddressList |
| 115 // but does not impact DNS resolution. |
| 116 void AddIPv4Rule(const std::string& host_pattern, |
| 117 const std::string& ipv4_literal, |
| 118 const std::string& canonical_name); |
| 119 |
| 120 // Same as AddRule(), but |ipv6_literal| is expected to be an IPV6 literal, |
| 121 // without enclosing brackets. You should use this in place of AddRule(), |
| 122 // since the system's host resolver may not support IPv6 literals on all |
| 123 // systems. This variant constructs the socket address directly so it will |
| 124 // always work. |
| 125 // If |canonical-name| is non-empty, it is copied to the resulting AddressList |
| 126 // but does not impact DNS resolution. |
114 void AddIPv6Rule(const std::string& host_pattern, | 127 void AddIPv6Rule(const std::string& host_pattern, |
115 const std::string& ipv6_literal); | 128 const std::string& ipv6_literal, |
| 129 const std::string& canonical_name); |
116 | 130 |
117 void AddRuleWithLatency(const std::string& host_pattern, | 131 void AddRuleWithLatency(const std::string& host_pattern, |
118 const std::string& replacement, | 132 const std::string& replacement, |
119 int latency_ms); | 133 int latency_ms); |
120 | 134 |
121 // Make sure that |host| will not be re-mapped or even processed by underlying | 135 // Make sure that |host| will not be re-mapped or even processed by underlying |
122 // host resolver procedures. It can also be a pattern. | 136 // host resolver procedures. It can also be a pattern. |
123 void AllowDirectLookup(const std::string& host); | 137 void AllowDirectLookup(const std::string& host); |
124 | 138 |
125 // Simulate a lookup failure for |host| (it also can be a pattern). | 139 // Simulate a lookup failure for |host| (it also can be a pattern). |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void Init(HostResolverProc* proc); | 199 void Init(HostResolverProc* proc); |
186 | 200 |
187 private: | 201 private: |
188 scoped_refptr<HostResolverProc> current_proc_; | 202 scoped_refptr<HostResolverProc> current_proc_; |
189 scoped_refptr<HostResolverProc> previous_proc_; | 203 scoped_refptr<HostResolverProc> previous_proc_; |
190 }; | 204 }; |
191 | 205 |
192 } // namespace net | 206 } // namespace net |
193 | 207 |
194 #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ | 208 #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ |
OLD | NEW |