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

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

Issue 368001: Second patch in making destructors of refcounted objects private. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/ref_counted.h" 10 #include "base/ref_counted.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // Called when request |id| has been cancelled. A request is "cancelled" 98 // Called when request |id| has been cancelled. A request is "cancelled"
99 // if either the HostResolver is destroyed while a resolution is in 99 // if either the HostResolver is destroyed while a resolution is in
100 // progress, or HostResolver::CancelRequest() is called. 100 // progress, or HostResolver::CancelRequest() is called.
101 virtual void OnCancelResolution(int id, const RequestInfo& info) = 0; 101 virtual void OnCancelResolution(int id, const RequestInfo& info) = 0;
102 }; 102 };
103 103
104 // Opaque type used to cancel a request. 104 // Opaque type used to cancel a request.
105 typedef void* RequestHandle; 105 typedef void* RequestHandle;
106 106
107 // If any completion callbacks are pending when the resolver is destroyed,
108 // the host resolutions are cancelled, and the completion callbacks will not
109 // be called.
110 virtual ~HostResolver() {}
111
112 // Resolves the given hostname (or IP address literal), filling out the 107 // Resolves the given hostname (or IP address literal), filling out the
113 // |addresses| object upon success. The |info.port| parameter will be set as 108 // |addresses| object upon success. The |info.port| parameter will be set as
114 // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if 109 // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if
115 // successful or an error code upon failure. 110 // successful or an error code upon failure.
116 // 111 //
117 // When callback is null, the operation completes synchronously. 112 // When callback is null, the operation completes synchronously.
118 // 113 //
119 // When callback is non-null, the operation may be performed asynchronously. 114 // When callback is non-null, the operation may be performed asynchronously.
120 // If the operation cannnot be completed synchronously, ERR_IO_PENDING will 115 // If the operation cannnot be completed synchronously, ERR_IO_PENDING will
121 // be returned and the real result code will be passed to the completion 116 // be returned and the real result code will be passed to the completion
(...skipping 28 matching lines...) Expand all
150 // TODO(eroman): temp hack for http://crbug.com/18373 145 // TODO(eroman): temp hack for http://crbug.com/18373
151 virtual void Shutdown() = 0; 146 virtual void Shutdown() = 0;
152 147
153 // Sets the default AddressFamily to use when requests have left it 148 // Sets the default AddressFamily to use when requests have left it
154 // unspecified. For example, this could be used to restrict resolution 149 // unspecified. For example, this could be used to restrict resolution
155 // results to AF_INET by passing in ADDRESS_FAMILY_IPV4, or to 150 // results to AF_INET by passing in ADDRESS_FAMILY_IPV4, or to
156 // AF_INET6 by passing in ADDRESS_FAMILY_IPV6. 151 // AF_INET6 by passing in ADDRESS_FAMILY_IPV6.
157 virtual void SetDefaultAddressFamily(AddressFamily address_family) {} 152 virtual void SetDefaultAddressFamily(AddressFamily address_family) {}
158 153
159 protected: 154 protected:
155 friend class base::RefCountedThreadSafe<HostResolver>;
156
160 HostResolver() { } 157 HostResolver() { }
161 158
159 // If any completion callbacks are pending when the resolver is destroyed,
160 // the host resolutions are cancelled, and the completion callbacks will not
161 // be called.
162 virtual ~HostResolver() {}
163
162 private: 164 private:
163 DISALLOW_COPY_AND_ASSIGN(HostResolver); 165 DISALLOW_COPY_AND_ASSIGN(HostResolver);
164 }; 166 };
165 167
166 // This class represents the task of resolving a hostname (or IP address 168 // This class represents the task of resolving a hostname (or IP address
167 // literal) to an AddressList object. It wraps HostResolver to resolve only a 169 // literal) to an AddressList object. It wraps HostResolver to resolve only a
168 // single hostname at a time and cancels this request when going out of scope. 170 // single hostname at a time and cancels this request when going out of scope.
169 class SingleRequestHostResolver { 171 class SingleRequestHostResolver {
170 public: 172 public:
171 explicit SingleRequestHostResolver(HostResolver* resolver); 173 explicit SingleRequestHostResolver(HostResolver* resolver);
(...skipping 29 matching lines...) Expand all
201 }; 203 };
202 204
203 // Creates a HostResolver implementation that queries the underlying system. 205 // Creates a HostResolver implementation that queries the underlying system.
204 // (Except if a unit-test has changed the global HostResolverProc using 206 // (Except if a unit-test has changed the global HostResolverProc using
205 // ScopedHostResolverProc to intercept requests to the system). 207 // ScopedHostResolverProc to intercept requests to the system).
206 HostResolver* CreateSystemHostResolver(); 208 HostResolver* CreateSystemHostResolver();
207 209
208 } // namespace net 210 } // namespace net
209 211
210 #endif // NET_BASE_HOST_RESOLVER_H_ 212 #endif // NET_BASE_HOST_RESOLVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698