OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 #include "net/base/address_family.h" | 13 #include "net/base/address_family.h" |
14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
15 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
16 #include "net/base/request_priority.h" | 16 #include "net/base/request_priority.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 class AddressList; | 20 class AddressList; |
21 class BoundNetLog; | 21 class BoundNetLog; |
22 class HostResolverImpl; | 22 class HostResolverImpl; |
| 23 class HostResolverProc; |
23 class NetLog; | 24 class NetLog; |
24 | 25 |
25 // This class represents the task of resolving hostnames (or IP address | 26 // This class represents the task of resolving hostnames (or IP address |
26 // literal) to an AddressList object. | 27 // literal) to an AddressList object. |
27 // | 28 // |
28 // HostResolver can handle multiple requests at a time, so when cancelling a | 29 // HostResolver can handle multiple requests at a time, so when cancelling a |
29 // request the RequestHandle that was returned by Resolve() needs to be | 30 // request the RequestHandle that was returned by Resolve() needs to be |
30 // given. A simpler alternative for consumers that only have 1 outstanding | 31 // given. A simpler alternative for consumers that only have 1 outstanding |
31 // request at a time is to create a SingleRequestHostResolver wrapper around | 32 // request at a time is to create a SingleRequestHostResolver wrapper around |
32 // HostResolver (which will automatically cancel the single request when it | 33 // HostResolver (which will automatically cancel the single request when it |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // The current request (if any). | 224 // The current request (if any). |
224 HostResolver::RequestHandle cur_request_; | 225 HostResolver::RequestHandle cur_request_; |
225 CompletionCallback* cur_request_callback_; | 226 CompletionCallback* cur_request_callback_; |
226 | 227 |
227 // Completion callback for when request to |resolver_| completes. | 228 // Completion callback for when request to |resolver_| completes. |
228 net::CompletionCallbackImpl<SingleRequestHostResolver> callback_; | 229 net::CompletionCallbackImpl<SingleRequestHostResolver> callback_; |
229 | 230 |
230 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); | 231 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); |
231 }; | 232 }; |
232 | 233 |
233 // Creates a HostResolver implementation that queries the underlying system. | 234 // Creates a HostResolver implementation using |resolver_proc| as resolver, |
234 // (Except if a unit-test has changed the global HostResolverProc using | 235 // (which if NULL, will default to getaddrinfo() wrapper) that queries the |
235 // ScopedHostResolverProc to intercept requests to the system). | 236 // underlying system, |max_concurrent_resolves| is how many resolve |
236 // |max_concurrent_resolves| is how many resolve requests will be allowed to | 237 // requests will be allowed to run in parallel. Pass |
237 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a | 238 // HostResolver::kDefaultParallelism to choose a default value. |
238 // default value. | |
239 HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves, | 239 HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves, |
| 240 HostResolverProc* resolver_proc, |
240 NetLog* net_log); | 241 NetLog* net_log); |
241 | 242 |
242 } // namespace net | 243 } // namespace net |
243 | 244 |
244 #endif // NET_BASE_HOST_RESOLVER_H_ | 245 #endif // NET_BASE_HOST_RESOLVER_H_ |
OLD | NEW |