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

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

Issue 12518036: net: move host_resolver files from net/base to net/dns (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_BASE_SINGLE_REQUEST_HOST_RESOLVER_H_
6 #define NET_BASE_SINGLE_REQUEST_HOST_RESOLVER_H_
7
8 #include "net/base/host_resolver.h"
9
10 namespace net {
11
12 // This class represents the task of resolving a hostname (or IP address
13 // literal) to an AddressList object. It wraps HostResolver to resolve only a
14 // single hostname at a time and cancels this request when going out of scope.
15 class NET_EXPORT SingleRequestHostResolver {
16 public:
17 // |resolver| must remain valid for the lifetime of |this|.
18 explicit SingleRequestHostResolver(HostResolver* resolver);
19
20 // If a completion callback is pending when the resolver is destroyed, the
21 // host resolution is cancelled, and the completion callback will not be
22 // called.
23 ~SingleRequestHostResolver();
24
25 // Resolves the given hostname (or IP address literal), filling out the
26 // |addresses| object upon success. See HostResolver::Resolve() for details.
27 int Resolve(const HostResolver::RequestInfo& info,
28 AddressList* addresses,
29 const CompletionCallback& callback,
30 const BoundNetLog& net_log);
31
32 // Cancels the in-progress request, if any. This prevents the callback
33 // from being invoked. Resolve() can be called again after cancelling.
34 void Cancel();
35
36 private:
37 // Callback for when the request to |resolver_| completes, so we dispatch
38 // to the user's callback.
39 void OnResolveCompletion(int result);
40
41 // The actual host resolver that will handle the request.
42 HostResolver* const resolver_;
43
44 // The current request (if any).
45 HostResolver::RequestHandle cur_request_;
46 CompletionCallback cur_request_callback_;
47
48 // Completion callback for when request to |resolver_| completes.
49 CompletionCallback callback_;
50
51 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver);
52 };
53
54 } // namespace net
55
56 #endif // NET_BASE_SINGLE_REQUEST_HOST_RESOLVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698