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

Side by Side Diff: net/base/host_resolver.h

Issue 10831277: [net] Change factory methods for HostResolver and HostCache to return a scoped_ptr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_HOST_RESOLVER_H_ 5 #ifndef NET_BASE_HOST_RESOLVER_H_
6 #define NET_BASE_HOST_RESOLVER_H_ 6 #define NET_BASE_HOST_RESOLVER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h"
10 #include "net/base/address_family.h" 11 #include "net/base/address_family.h"
11 #include "net/base/completion_callback.h" 12 #include "net/base/completion_callback.h"
12 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
13 #include "net/base/net_export.h" 14 #include "net/base/net_export.h"
14 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
15 #include "net/base/request_priority.h" 16 #include "net/base/request_priority.h"
16 17
17 namespace base { 18 namespace base {
18 class Value; 19 class Value;
19 } 20 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // Whether this request was started by the DNS prefetcher. 89 // Whether this request was started by the DNS prefetcher.
89 bool is_speculative_; 90 bool is_speculative_;
90 91
91 // The priority for the request. 92 // The priority for the request.
92 RequestPriority priority_; 93 RequestPriority priority_;
93 }; 94 };
94 95
95 // Opaque type used to cancel a request. 96 // Opaque type used to cancel a request.
96 typedef void* RequestHandle; 97 typedef void* RequestHandle;
97 98
98 // This value can be passed into CreateSystemHostResolver as the 99 // This value can be passed into CreateSystemResolver as the
99 // |max_concurrent_resolves| parameter. It will select a default level of 100 // |max_concurrent_resolves| parameter. It will select a default level of
100 // concurrency. 101 // concurrency.
101 static const size_t kDefaultParallelism = 0; 102 static const size_t kDefaultParallelism = 0;
102 103
103 // This value can be passed into CreateSystemHostResolver as the 104 // This value can be passed into CreateSystemResolver as the
104 // |max_retry_attempts| parameter. This is the maximum number of times we 105 // |max_retry_attempts| parameter.
105 // will retry for host resolution.
106 static const size_t kDefaultRetryAttempts = -1; 106 static const size_t kDefaultRetryAttempts = -1;
107 107
108 // If any completion callbacks are pending when the resolver is destroyed, 108 // If any completion callbacks are pending when the resolver is destroyed,
109 // the host resolutions are cancelled, and the completion callbacks will not 109 // the host resolutions are cancelled, and the completion callbacks will not
110 // be called. 110 // be called.
111 virtual ~HostResolver(); 111 virtual ~HostResolver();
112 112
113 // Resolves the given hostname (or IP address literal), filling out the 113 // Resolves the given hostname (or IP address literal), filling out the
114 // |addresses| object upon success. The |info.port| parameter will be set as 114 // |addresses| object upon success. The |info.port| parameter will be set as
115 // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if 115 // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 // Returns the HostResolverCache |this| uses, or NULL if there isn't one. 162 // Returns the HostResolverCache |this| uses, or NULL if there isn't one.
163 // Used primarily to clear the cache and for getting debug information. 163 // Used primarily to clear the cache and for getting debug information.
164 virtual HostCache* GetHostCache(); 164 virtual HostCache* GetHostCache();
165 165
166 // Returns the current DNS configuration |this| is using, as a Value, or NULL 166 // Returns the current DNS configuration |this| is using, as a Value, or NULL
167 // if it's configured to always use the system host resolver. Caller takes 167 // if it's configured to always use the system host resolver. Caller takes
168 // ownership of the returned Value. 168 // ownership of the returned Value.
169 virtual base::Value* GetDnsConfigAsValue() const; 169 virtual base::Value* GetDnsConfigAsValue() const;
170 170
171 // Creates a HostResolver implementation that queries the underlying system.
172 // (Except if a unit-test has changed the global HostResolverProc using
173 // ScopedHostResolverProc to intercept requests to the system).
174 // |max_concurrent_resolves| is how many resolve requests will be allowed to
175 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a
176 // default value.
177 // |max_retry_attempts| is the maximum number of times we will retry for host
178 // resolution. Pass HostResolver::kDefaultRetryAttempts to choose a default
179 // value.
180 // |enable_caching| controls whether a HostCache is used.
181 // |enable_async| controls whether a DnsClient is used.
182 static scoped_ptr<HostResolver> CreateSystemResolver(
183 size_t max_concurrent_resolves,
darin (slow to review) 2012/10/09 17:38:34 an Options struct containing these four fields wou
szym 2012/10/09 21:40:43 Done.
184 size_t max_retry_attempts,
185 bool enable_caching,
186 bool enable_async,
187 NetLog* net_log);
188
189 // As above, but uses default parameters.
190 static scoped_ptr<HostResolver> CreateDefaultResolver(NetLog* net_log);
191
171 protected: 192 protected:
172 HostResolver(); 193 HostResolver();
173 194
174 private: 195 private:
175 DISALLOW_COPY_AND_ASSIGN(HostResolver); 196 DISALLOW_COPY_AND_ASSIGN(HostResolver);
176 }; 197 };
177 198
178 // Creates a HostResolver implementation that queries the underlying system.
179 // (Except if a unit-test has changed the global HostResolverProc using
180 // ScopedHostResolverProc to intercept requests to the system).
181 // |max_concurrent_resolves| is how many resolve requests will be allowed to
182 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a
183 // default value.
184 // |max_retry_attempts| is the maximum number of times we will retry for host
185 // resolution. Pass HostResolver::kDefaultRetryAttempts to choose a default
186 // value.
187 // The created HostResolver uses an instance of DnsConfigService to retrieve
188 // system DNS configuration.
189 // This resolver should not be used in test context. Instead, use
190 // MockHostResolver from net/base/mock_host_resolver.h.
191 NET_EXPORT HostResolver* CreateSystemHostResolver(
192 size_t max_concurrent_resolves,
193 size_t max_retry_attempts,
194 NetLog* net_log);
195
196 // As above, but the created HostResolver does not use a cache.
197 NET_EXPORT HostResolver* CreateNonCachingSystemHostResolver(
198 size_t max_concurrent_resolves,
199 size_t max_retry_attempts,
200 NetLog* net_log);
201
202 // As above, but the HostResolver will use the asynchronous DNS client in
203 // DnsTransaction, which will be configured using DnsConfigService to match
204 // the system DNS settings. If the client fails, the resolver falls back to
205 // the global HostResolverProc.
206 NET_EXPORT HostResolver* CreateAsyncHostResolver(size_t max_concurrent_resolves,
207 size_t max_retry_attempts,
208 NetLog* net_log);
209 } // namespace net 199 } // namespace net
210 200
211 #endif // NET_BASE_HOST_RESOLVER_H_ 201 #endif // NET_BASE_HOST_RESOLVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698