| 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 #include <map> | 10 #include <map> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 RuleBasedHostResolverProc* rules() { return rules_; } | 58 RuleBasedHostResolverProc* rules() { return rules_; } |
| 59 | 59 |
| 60 // Controls whether resolutions complete synchronously or asynchronously. | 60 // Controls whether resolutions complete synchronously or asynchronously. |
| 61 void set_synchronous_mode(bool is_synchronous) { | 61 void set_synchronous_mode(bool is_synchronous) { |
| 62 synchronous_mode_ = is_synchronous; | 62 synchronous_mode_ = is_synchronous; |
| 63 } | 63 } |
| 64 | 64 |
| 65 // HostResolver methods: | 65 // HostResolver methods: |
| 66 virtual int Resolve(const RequestInfo& info, | 66 virtual int Resolve(const RequestInfo& info, |
| 67 AddressList* addresses, | 67 AddressList* addresses, |
| 68 OldCompletionCallback* callback, | 68 const CompletionCallback& callback, |
| 69 RequestHandle* out_req, | 69 RequestHandle* out_req, |
| 70 const BoundNetLog& net_log) OVERRIDE; | 70 const BoundNetLog& net_log) OVERRIDE; |
| 71 virtual int ResolveFromCache(const RequestInfo& info, | 71 virtual int ResolveFromCache(const RequestInfo& info, |
| 72 AddressList* addresses, | 72 AddressList* addresses, |
| 73 const BoundNetLog& net_log) OVERRIDE; | 73 const BoundNetLog& net_log) OVERRIDE; |
| 74 virtual void CancelRequest(RequestHandle req) OVERRIDE; | 74 virtual void CancelRequest(RequestHandle req) OVERRIDE; |
| 75 virtual HostCache* GetHostCache() OVERRIDE; | 75 virtual HostCache* GetHostCache() OVERRIDE; |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 explicit MockHostResolverBase(bool use_caching); | 78 explicit MockHostResolverBase(bool use_caching); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 // Create rules that map all requests to localhost. | 174 // Create rules that map all requests to localhost. |
| 175 RuleBasedHostResolverProc* CreateCatchAllHostResolverProc(); | 175 RuleBasedHostResolverProc* CreateCatchAllHostResolverProc(); |
| 176 | 176 |
| 177 // HangingHostResolver never completes its |Resolve| request. | 177 // HangingHostResolver never completes its |Resolve| request. |
| 178 class HangingHostResolver : public HostResolver { | 178 class HangingHostResolver : public HostResolver { |
| 179 public: | 179 public: |
| 180 virtual int Resolve(const RequestInfo& info, | 180 virtual int Resolve(const RequestInfo& info, |
| 181 AddressList* addresses, | 181 AddressList* addresses, |
| 182 OldCompletionCallback* callback, | 182 const CompletionCallback& callback, |
| 183 RequestHandle* out_req, | 183 RequestHandle* out_req, |
| 184 const BoundNetLog& net_log) OVERRIDE; | 184 const BoundNetLog& net_log) OVERRIDE; |
| 185 virtual int ResolveFromCache(const RequestInfo& info, | 185 virtual int ResolveFromCache(const RequestInfo& info, |
| 186 AddressList* addresses, | 186 AddressList* addresses, |
| 187 const BoundNetLog& net_log) OVERRIDE; | 187 const BoundNetLog& net_log) OVERRIDE; |
| 188 virtual void CancelRequest(RequestHandle req) OVERRIDE {} | 188 virtual void CancelRequest(RequestHandle req) OVERRIDE {} |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 // This class sets the default HostResolverProc for a particular scope. The | 191 // This class sets the default HostResolverProc for a particular scope. The |
| 192 // chain of resolver procs starting at |proc| is placed in front of any existing | 192 // chain of resolver procs starting at |proc| is placed in front of any existing |
| (...skipping 14 matching lines...) Expand all Loading... |
| 207 void Init(HostResolverProc* proc); | 207 void Init(HostResolverProc* proc); |
| 208 | 208 |
| 209 private: | 209 private: |
| 210 scoped_refptr<HostResolverProc> current_proc_; | 210 scoped_refptr<HostResolverProc> current_proc_; |
| 211 scoped_refptr<HostResolverProc> previous_proc_; | 211 scoped_refptr<HostResolverProc> previous_proc_; |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 } // namespace net | 214 } // namespace net |
| 215 | 215 |
| 216 #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ | 216 #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ |
| OLD | NEW |