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