| OLD | NEW |
| 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_SINGLE_REQUEST_HOST_RESOLVER_H_ | 5 #ifndef NET_DNS_SINGLE_REQUEST_HOST_RESOLVER_H_ |
| 6 #define NET_DNS_SINGLE_REQUEST_HOST_RESOLVER_H_ | 6 #define NET_DNS_SINGLE_REQUEST_HOST_RESOLVER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
| 10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // |resolver| must remain valid for the lifetime of |this|. | 24 // |resolver| must remain valid for the lifetime of |this|. |
| 25 explicit SingleRequestHostResolver(HostResolver* resolver); | 25 explicit SingleRequestHostResolver(HostResolver* resolver); |
| 26 | 26 |
| 27 // If a completion callback is pending when the resolver is destroyed, the | 27 // If a completion callback is pending when the resolver is destroyed, the |
| 28 // host resolution is cancelled, and the completion callback will not be | 28 // host resolution is cancelled, and the completion callback will not be |
| 29 // called. | 29 // called. |
| 30 ~SingleRequestHostResolver(); | 30 ~SingleRequestHostResolver(); |
| 31 | 31 |
| 32 // Resolves the given hostname (or IP address literal), filling out the | 32 // Resolves the given hostname (or IP address literal), filling out the |
| 33 // |addresses| object upon success. See HostResolver::Resolve() for details. | 33 // |addresses| object upon success. See HostResolver::Resolve() for details. |
| 34 // Note, |addresses| can be null if the caller does not care about the return |
| 35 // resolution result, and only wishes to perform the resolution. |
| 34 int Resolve(const HostResolver::RequestInfo& info, | 36 int Resolve(const HostResolver::RequestInfo& info, |
| 35 RequestPriority priority, | 37 RequestPriority priority, |
| 36 AddressList* addresses, | 38 AddressList* addresses, |
| 37 const CompletionCallback& callback, | 39 const CompletionCallback& callback, |
| 38 const BoundNetLog& net_log); | 40 const BoundNetLog& net_log); |
| 39 | 41 |
| 40 // Cancels the in-progress request, if any. This prevents the callback | 42 // Cancels the in-progress request, if any. This prevents the callback |
| 41 // from being invoked. Resolve() can be called again after cancelling. | 43 // from being invoked. Resolve() can be called again after cancelling. |
| 42 void Cancel(); | 44 void Cancel(); |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 // Callback for when the request to |resolver_| completes, so we dispatch | 47 // Callback for when the request to |resolver_| completes, so we dispatch |
| 46 // to the user's callback. | 48 // to the user's callback. |
| 47 void OnResolveCompletion(int result); | 49 void OnResolveCompletion(int result); |
| 48 | 50 |
| 49 // The actual host resolver that will handle the request. | 51 // The actual host resolver that will handle the request. |
| 50 HostResolver* const resolver_; | 52 HostResolver* const resolver_; |
| 51 | 53 |
| 52 // The current request (if any). | 54 // The current request (if any). |
| 53 HostResolver::RequestHandle cur_request_; | 55 HostResolver::RequestHandle cur_request_; |
| 54 CompletionCallback cur_request_callback_; | 56 CompletionCallback cur_request_callback_; |
| 55 | 57 |
| 56 // Completion callback for when request to |resolver_| completes. | 58 // Completion callback for when request to |resolver_| completes. |
| 57 CompletionCallback callback_; | 59 CompletionCallback callback_; |
| 58 | 60 |
| 61 std::unique_ptr<AddressList> default_addresses_; |
| 62 |
| 59 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); | 63 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); |
| 60 }; | 64 }; |
| 61 | 65 |
| 62 } // namespace net | 66 } // namespace net |
| 63 | 67 |
| 64 #endif // NET_DNS_SINGLE_REQUEST_HOST_RESOLVER_H_ | 68 #endif // NET_DNS_SINGLE_REQUEST_HOST_RESOLVER_H_ |
| OLD | NEW |