OLD | NEW |
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // called. | 178 // called. |
179 ~SingleRequestHostResolver(); | 179 ~SingleRequestHostResolver(); |
180 | 180 |
181 // Resolves the given hostname (or IP address literal), filling out the | 181 // Resolves the given hostname (or IP address literal), filling out the |
182 // |addresses| object upon success. See HostResolver::Resolve() for details. | 182 // |addresses| object upon success. See HostResolver::Resolve() for details. |
183 int Resolve(const HostResolver::RequestInfo& info, | 183 int Resolve(const HostResolver::RequestInfo& info, |
184 AddressList* addresses, | 184 AddressList* addresses, |
185 CompletionCallback* callback, | 185 CompletionCallback* callback, |
186 LoadLog* load_log); | 186 LoadLog* load_log); |
187 | 187 |
| 188 // Cancels the in-progress request, if any. This prevents the callback |
| 189 // from being invoked. Resolve() can be called again after cancelling. |
| 190 void Cancel(); |
| 191 |
188 private: | 192 private: |
189 // Callback for when the request to |resolver_| completes, so we dispatch | 193 // Callback for when the request to |resolver_| completes, so we dispatch |
190 // to the user's callback. | 194 // to the user's callback. |
191 void OnResolveCompletion(int result); | 195 void OnResolveCompletion(int result); |
192 | 196 |
193 // The actual host resolver that will handle the request. | 197 // The actual host resolver that will handle the request. |
194 scoped_refptr<HostResolver> resolver_; | 198 scoped_refptr<HostResolver> resolver_; |
195 | 199 |
196 // The current request (if any). | 200 // The current request (if any). |
197 HostResolver::RequestHandle cur_request_; | 201 HostResolver::RequestHandle cur_request_; |
198 CompletionCallback* cur_request_callback_; | 202 CompletionCallback* cur_request_callback_; |
199 | 203 |
200 // Completion callback for when request to |resolver_| completes. | 204 // Completion callback for when request to |resolver_| completes. |
201 net::CompletionCallbackImpl<SingleRequestHostResolver> callback_; | 205 net::CompletionCallbackImpl<SingleRequestHostResolver> callback_; |
202 | 206 |
203 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); | 207 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); |
204 }; | 208 }; |
205 | 209 |
206 // Creates a HostResolver implementation that queries the underlying system. | 210 // Creates a HostResolver implementation that queries the underlying system. |
207 // (Except if a unit-test has changed the global HostResolverProc using | 211 // (Except if a unit-test has changed the global HostResolverProc using |
208 // ScopedHostResolverProc to intercept requests to the system). | 212 // ScopedHostResolverProc to intercept requests to the system). |
209 HostResolver* CreateSystemHostResolver(); | 213 HostResolver* CreateSystemHostResolver(); |
210 | 214 |
211 } // namespace net | 215 } // namespace net |
212 | 216 |
213 #endif // NET_BASE_HOST_RESOLVER_H_ | 217 #endif // NET_BASE_HOST_RESOLVER_H_ |
OLD | NEW |