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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 // Called when request |id| has been cancelled. A request is "cancelled" | 125 // Called when request |id| has been cancelled. A request is "cancelled" |
126 // if either the HostResolver is destroyed while a resolution is in | 126 // if either the HostResolver is destroyed while a resolution is in |
127 // progress, or HostResolver::CancelRequest() is called. | 127 // progress, or HostResolver::CancelRequest() is called. |
128 virtual void OnCancelResolution(int id, const RequestInfo& info) = 0; | 128 virtual void OnCancelResolution(int id, const RequestInfo& info) = 0; |
129 }; | 129 }; |
130 | 130 |
131 // Opaque type used to cancel a request. | 131 // Opaque type used to cancel a request. |
132 typedef void* RequestHandle; | 132 typedef void* RequestHandle; |
133 | 133 |
| 134 // This value can be passed into CreateSystemHostResolver as the |
| 135 // |max_concurrent_resolves| parameter. It will select a default level of |
| 136 // concurrency. |
| 137 static const size_t kDefaultParallelism = 0; |
| 138 |
134 // Resolves the given hostname (or IP address literal), filling out the | 139 // Resolves the given hostname (or IP address literal), filling out the |
135 // |addresses| object upon success. The |info.port| parameter will be set as | 140 // |addresses| object upon success. The |info.port| parameter will be set as |
136 // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if | 141 // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if |
137 // successful or an error code upon failure. | 142 // successful or an error code upon failure. |
138 // | 143 // |
139 // When callback is null, the operation completes synchronously. | 144 // When callback is null, the operation completes synchronously. |
140 // | 145 // |
141 // When callback is non-null, the operation may be performed asynchronously. | 146 // When callback is non-null, the operation may be performed asynchronously. |
142 // If the operation cannnot be completed synchronously, ERR_IO_PENDING will | 147 // If the operation cannnot be completed synchronously, ERR_IO_PENDING will |
143 // be returned and the real result code will be passed to the completion | 148 // be returned and the real result code will be passed to the completion |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 236 |
232 // Completion callback for when request to |resolver_| completes. | 237 // Completion callback for when request to |resolver_| completes. |
233 net::CompletionCallbackImpl<SingleRequestHostResolver> callback_; | 238 net::CompletionCallbackImpl<SingleRequestHostResolver> callback_; |
234 | 239 |
235 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); | 240 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); |
236 }; | 241 }; |
237 | 242 |
238 // Creates a HostResolver implementation that queries the underlying system. | 243 // Creates a HostResolver implementation that queries the underlying system. |
239 // (Except if a unit-test has changed the global HostResolverProc using | 244 // (Except if a unit-test has changed the global HostResolverProc using |
240 // ScopedHostResolverProc to intercept requests to the system). | 245 // ScopedHostResolverProc to intercept requests to the system). |
241 HostResolver* CreateSystemHostResolver(); | 246 // |max_concurrent_resolves| is how many resolve requests will be allowed to |
| 247 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a |
| 248 // default value. |
| 249 HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves); |
242 | 250 |
243 } // namespace net | 251 } // namespace net |
244 | 252 |
245 #endif // NET_BASE_HOST_RESOLVER_H_ | 253 #endif // NET_BASE_HOST_RESOLVER_H_ |
OLD | NEW |