Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: net/dns/mock_host_resolver.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_DNS_MOCK_HOST_RESOLVER_H_ 5 #ifndef NET_DNS_MOCK_HOST_RESOLVER_H_
6 #define NET_DNS_MOCK_HOST_RESOLVER_H_ 6 #define NET_DNS_MOCK_HOST_RESOLVER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 // Controls whether resolutions complete synchronously or asynchronously. 63 // Controls whether resolutions complete synchronously or asynchronously.
64 void set_synchronous_mode(bool is_synchronous) { 64 void set_synchronous_mode(bool is_synchronous) {
65 synchronous_mode_ = is_synchronous; 65 synchronous_mode_ = is_synchronous;
66 } 66 }
67 67
68 // Asynchronous requests are automatically resolved by default. 68 // Asynchronous requests are automatically resolved by default.
69 // If set_ondemand_mode() is set then Resolve() returns IO_PENDING and 69 // If set_ondemand_mode() is set then Resolve() returns IO_PENDING and
70 // ResolveAllPending() must be explicitly invoked to resolve all requests 70 // ResolveAllPending() must be explicitly invoked to resolve all requests
71 // that are pending. 71 // that are pending.
72 void set_ondemand_mode(bool is_ondemand) { 72 void set_ondemand_mode(bool is_ondemand) { ondemand_mode_ = is_ondemand; }
73 ondemand_mode_ = is_ondemand;
74 }
75 73
76 // HostResolver methods: 74 // HostResolver methods:
77 virtual int Resolve(const RequestInfo& info, 75 virtual int Resolve(const RequestInfo& info,
78 RequestPriority priority, 76 RequestPriority priority,
79 AddressList* addresses, 77 AddressList* addresses,
80 const CompletionCallback& callback, 78 const CompletionCallback& callback,
81 RequestHandle* out_req, 79 RequestHandle* out_req,
82 const BoundNetLog& net_log) OVERRIDE; 80 const BoundNetLog& net_log) OVERRIDE;
83 virtual int ResolveFromCache(const RequestInfo& info, 81 virtual int ResolveFromCache(const RequestInfo& info,
84 AddressList* addresses, 82 AddressList* addresses,
85 const BoundNetLog& net_log) OVERRIDE; 83 const BoundNetLog& net_log) OVERRIDE;
86 virtual void CancelRequest(RequestHandle req) OVERRIDE; 84 virtual void CancelRequest(RequestHandle req) OVERRIDE;
87 virtual HostCache* GetHostCache() OVERRIDE; 85 virtual HostCache* GetHostCache() OVERRIDE;
88 86
89 // Resolves all pending requests. It is only valid to invoke this if 87 // Resolves all pending requests. It is only valid to invoke this if
90 // set_ondemand_mode was set before. The requests are resolved asynchronously, 88 // set_ondemand_mode was set before. The requests are resolved asynchronously,
91 // after this call returns. 89 // after this call returns.
92 void ResolveAllPending(); 90 void ResolveAllPending();
93 91
94 // Returns true if there are pending requests that can be resolved by invoking 92 // Returns true if there are pending requests that can be resolved by invoking
95 // ResolveAllPending(). 93 // ResolveAllPending().
96 bool has_pending_requests() const { return !requests_.empty(); } 94 bool has_pending_requests() const { return !requests_.empty(); }
97 95
98 // The number of times that Resolve() has been called. 96 // The number of times that Resolve() has been called.
99 size_t num_resolve() const { 97 size_t num_resolve() const { return num_resolve_; }
100 return num_resolve_;
101 }
102 98
103 // The number of times that ResolveFromCache() has been called. 99 // The number of times that ResolveFromCache() has been called.
104 size_t num_resolve_from_cache() const { 100 size_t num_resolve_from_cache() const { return num_resolve_from_cache_; }
105 return num_resolve_from_cache_;
106 }
107 101
108 // Returns the RequestPriority of the last call to Resolve() (or 102 // Returns the RequestPriority of the last call to Resolve() (or
109 // DEFAULT_PRIORITY if Resolve() hasn't been called yet). 103 // DEFAULT_PRIORITY if Resolve() hasn't been called yet).
110 RequestPriority last_request_priority() const { 104 RequestPriority last_request_priority() const {
111 return last_request_priority_; 105 return last_request_priority_;
112 } 106 }
113 107
114 protected: 108 protected:
115 explicit MockHostResolverBase(bool use_caching); 109 explicit MockHostResolverBase(bool use_caching);
116 110
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // RuleBasedHostResolverProc applies a set of rules to map a host string to 155 // RuleBasedHostResolverProc applies a set of rules to map a host string to
162 // a replacement host string. It then uses the system host resolver to return 156 // a replacement host string. It then uses the system host resolver to return
163 // a socket address. Generally the replacement should be an IPv4 literal so 157 // a socket address. Generally the replacement should be an IPv4 literal so
164 // there is no network dependency. 158 // there is no network dependency.
165 class RuleBasedHostResolverProc : public HostResolverProc { 159 class RuleBasedHostResolverProc : public HostResolverProc {
166 public: 160 public:
167 explicit RuleBasedHostResolverProc(HostResolverProc* previous); 161 explicit RuleBasedHostResolverProc(HostResolverProc* previous);
168 162
169 // Any hostname matching the given pattern will be replaced with the given 163 // Any hostname matching the given pattern will be replaced with the given
170 // replacement value. Usually, replacement should be an IP address literal. 164 // replacement value. Usually, replacement should be an IP address literal.
171 void AddRule(const std::string& host_pattern, 165 void AddRule(const std::string& host_pattern, const std::string& replacement);
172 const std::string& replacement);
173 166
174 // Same as AddRule(), but further restricts to |address_family|. 167 // Same as AddRule(), but further restricts to |address_family|.
175 void AddRuleForAddressFamily(const std::string& host_pattern, 168 void AddRuleForAddressFamily(const std::string& host_pattern,
176 AddressFamily address_family, 169 AddressFamily address_family,
177 const std::string& replacement); 170 const std::string& replacement);
178 171
179 // Same as AddRule(), but the replacement is expected to be an IPv4 or IPv6 172 // Same as AddRule(), but the replacement is expected to be an IPv4 or IPv6
180 // literal. This can be used in place of AddRule() to bypass the system's 173 // literal. This can be used in place of AddRule() to bypass the system's
181 // host resolver (the address list will be constructed manually). 174 // host resolver (the address list will be constructed manually).
182 // If |canonical_name| is non-empty, it is copied to the resulting AddressList 175 // If |canonical_name| is non-empty, it is copied to the resulting AddressList
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void Init(HostResolverProc* proc); 247 void Init(HostResolverProc* proc);
255 248
256 private: 249 private:
257 scoped_refptr<HostResolverProc> current_proc_; 250 scoped_refptr<HostResolverProc> current_proc_;
258 scoped_refptr<HostResolverProc> previous_proc_; 251 scoped_refptr<HostResolverProc> previous_proc_;
259 }; 252 };
260 253
261 } // namespace net 254 } // namespace net
262 255
263 #endif // NET_DNS_MOCK_HOST_RESOLVER_H_ 256 #endif // NET_DNS_MOCK_HOST_RESOLVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698