OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 }; | 88 }; |
89 | 89 |
90 // Same as MockHostResolver, except internally it uses a host-cache. | 90 // Same as MockHostResolver, except internally it uses a host-cache. |
91 // | 91 // |
92 // Note that tests are advised to use MockHostResolver instead, since it is | 92 // Note that tests are advised to use MockHostResolver instead, since it is |
93 // more predictable. (MockHostResolver also can be put into synchronous | 93 // more predictable. (MockHostResolver also can be put into synchronous |
94 // operation mode in case that is what you needed from the caching version). | 94 // operation mode in case that is what you needed from the caching version). |
95 class MockCachingHostResolver : public MockHostResolverBase { | 95 class MockCachingHostResolver : public MockHostResolverBase { |
96 public: | 96 public: |
97 MockCachingHostResolver() : MockHostResolverBase(true /*use_caching*/) {} | 97 MockCachingHostResolver() : MockHostResolverBase(true /*use_caching*/) {} |
98 ~MockCachingHostResolver() {} | 98 virtual ~MockCachingHostResolver() {} |
99 }; | 99 }; |
100 | 100 |
101 // RuleBasedHostResolverProc applies a set of rules to map a host string to | 101 // RuleBasedHostResolverProc applies a set of rules to map a host string to |
102 // a replacement host string. It then uses the system host resolver to return | 102 // a replacement host string. It then uses the system host resolver to return |
103 // a socket address. Generally the replacement should be an IPv4 literal so | 103 // a socket address. Generally the replacement should be an IPv4 literal so |
104 // there is no network dependency. | 104 // there is no network dependency. |
105 class NET_TEST RuleBasedHostResolverProc : public HostResolverProc { | 105 class NET_TEST RuleBasedHostResolverProc : public HostResolverProc { |
106 public: | 106 public: |
107 explicit RuleBasedHostResolverProc(HostResolverProc* previous); | 107 explicit RuleBasedHostResolverProc(HostResolverProc* previous); |
108 | 108 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 virtual int Resolve(const std::string& host, | 140 virtual int Resolve(const std::string& host, |
141 AddressFamily address_family, | 141 AddressFamily address_family, |
142 HostResolverFlags host_resolver_flags, | 142 HostResolverFlags host_resolver_flags, |
143 AddressList* addrlist, | 143 AddressList* addrlist, |
144 int* os_error); | 144 int* os_error); |
145 | 145 |
146 private: | 146 private: |
147 struct Rule; | 147 struct Rule; |
148 typedef std::list<Rule> RuleList; | 148 typedef std::list<Rule> RuleList; |
149 | 149 |
150 ~RuleBasedHostResolverProc(); | 150 virtual ~RuleBasedHostResolverProc(); |
151 | 151 |
152 RuleList rules_; | 152 RuleList rules_; |
153 }; | 153 }; |
154 | 154 |
155 // Using WaitingHostResolverProc you can simulate very long lookups. | 155 // Using WaitingHostResolverProc you can simulate very long lookups. |
156 class NET_TEST WaitingHostResolverProc : public HostResolverProc { | 156 class NET_TEST WaitingHostResolverProc : public HostResolverProc { |
157 public: | 157 public: |
158 explicit WaitingHostResolverProc(HostResolverProc* previous); | 158 explicit WaitingHostResolverProc(HostResolverProc* previous); |
159 | 159 |
160 void Signal(); | 160 void Signal(); |
(...skipping 30 matching lines...) Expand all Loading... |
191 void Init(HostResolverProc* proc); | 191 void Init(HostResolverProc* proc); |
192 | 192 |
193 private: | 193 private: |
194 scoped_refptr<HostResolverProc> current_proc_; | 194 scoped_refptr<HostResolverProc> current_proc_; |
195 scoped_refptr<HostResolverProc> previous_proc_; | 195 scoped_refptr<HostResolverProc> previous_proc_; |
196 }; | 196 }; |
197 | 197 |
198 } // namespace net | 198 } // namespace net |
199 | 199 |
200 #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ | 200 #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ |
OLD | NEW |