OLD | NEW |
1 // Copyright (c) 2009 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" |
11 #include "net/base/host_resolver_impl.h" | 11 #include "net/base/host_resolver_impl.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 event_.Wait(); | 159 event_.Wait(); |
160 return ResolveUsingPrevious(host, address_family, addrlist); | 160 return ResolveUsingPrevious(host, address_family, addrlist); |
161 } | 161 } |
162 | 162 |
163 private: | 163 private: |
164 ~WaitingHostResolverProc() {} | 164 ~WaitingHostResolverProc() {} |
165 | 165 |
166 base::WaitableEvent event_; | 166 base::WaitableEvent event_; |
167 }; | 167 }; |
168 | 168 |
169 // This class sets the HostResolverProc for a particular scope. If there are | 169 // This class sets the default HostResolverProc for a particular scope. The |
170 // multiple ScopedDefaultHostResolverProc in existence, then the last one | 170 // chain of resolver procs starting at |proc| is placed in front of any existing |
171 // allocated will be used. However, if it does not provide a matching rule, | 171 // default resolver proc(s). This means that if multiple |
172 // then it should delegate to the previously set HostResolverProc. | 172 // ScopedDefaultHostResolverProcs are declared, then resolving will start with |
| 173 // the procs given to the last-allocated one, then fall back to the procs given |
| 174 // to the previously-allocated one, and so forth. |
173 // | 175 // |
174 // NOTE: Only use this as a catch-all safety net. Individual tests should use | 176 // NOTE: Only use this as a catch-all safety net. Individual tests should use |
175 // MockHostResolver. | 177 // MockHostResolver. |
176 class ScopedDefaultHostResolverProc { | 178 class ScopedDefaultHostResolverProc { |
177 public: | 179 public: |
178 ScopedDefaultHostResolverProc() {} | 180 ScopedDefaultHostResolverProc() {} |
179 explicit ScopedDefaultHostResolverProc(HostResolverProc* proc); | 181 explicit ScopedDefaultHostResolverProc(HostResolverProc* proc); |
180 | 182 |
181 ~ScopedDefaultHostResolverProc(); | 183 ~ScopedDefaultHostResolverProc(); |
182 | 184 |
183 void Init(HostResolverProc* proc); | 185 void Init(HostResolverProc* proc); |
184 | 186 |
185 private: | 187 private: |
186 scoped_refptr<HostResolverProc> current_proc_; | 188 scoped_refptr<HostResolverProc> current_proc_; |
187 scoped_refptr<HostResolverProc> previous_proc_; | 189 scoped_refptr<HostResolverProc> previous_proc_; |
188 }; | 190 }; |
189 | 191 |
190 } // namespace net | 192 } // namespace net |
191 | 193 |
192 #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ | 194 #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ |
OLD | NEW |