Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: net/base/host_resolver.h

Issue 6969077: net: Add NET_API to net/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_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/memory/scoped_ptr.h" 11 #include "base/memory/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/net_api.h"
16 #include "net/base/request_priority.h" 17 #include "net/base/request_priority.h"
17 18
18 namespace net { 19 namespace net {
19 20
20 class AddressList; 21 class AddressList;
21 class BoundNetLog; 22 class BoundNetLog;
22 class HostResolverImpl; 23 class HostResolverImpl;
23 class HostResolverProc; 24 class HostResolverProc;
24 class NetLog; 25 class NetLog;
25 26
26 // This class represents the task of resolving hostnames (or IP address 27 // This class represents the task of resolving hostnames (or IP address
27 // literal) to an AddressList object. 28 // literal) to an AddressList object.
28 // 29 //
29 // HostResolver can handle multiple requests at a time, so when cancelling a 30 // HostResolver can handle multiple requests at a time, so when cancelling a
30 // request the RequestHandle that was returned by Resolve() needs to be 31 // request the RequestHandle that was returned by Resolve() needs to be
31 // given. A simpler alternative for consumers that only have 1 outstanding 32 // given. A simpler alternative for consumers that only have 1 outstanding
32 // request at a time is to create a SingleRequestHostResolver wrapper around 33 // request at a time is to create a SingleRequestHostResolver wrapper around
33 // HostResolver (which will automatically cancel the single request when it 34 // HostResolver (which will automatically cancel the single request when it
34 // goes out of scope). 35 // goes out of scope).
35 class HostResolver { 36 class NET_API HostResolver {
36 public: 37 public:
37 // The parameters for doing a Resolve(). A hostname and port are required, 38 // The parameters for doing a Resolve(). A hostname and port are required,
38 // the rest are optional (and have reasonable defaults). 39 // the rest are optional (and have reasonable defaults).
39 class RequestInfo { 40 class NET_API RequestInfo {
40 public: 41 public:
41 explicit RequestInfo(const HostPortPair& host_port_pair); 42 explicit RequestInfo(const HostPortPair& host_port_pair);
42 43
43 const HostPortPair& host_port_pair() const { return host_port_pair_; } 44 const HostPortPair& host_port_pair() const { return host_port_pair_; }
44 void set_host_port_pair(const HostPortPair& host_port_pair) { 45 void set_host_port_pair(const HostPortPair& host_port_pair) {
45 host_port_pair_ = host_port_pair; 46 host_port_pair_ = host_port_pair;
46 } 47 }
47 48
48 int port() const { return host_port_pair_.port(); } 49 int port() const { return host_port_pair_.port(); }
49 const std::string& hostname() const { return host_port_pair_.host(); } 50 const std::string& hostname() const { return host_port_pair_.host(); }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 235
235 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); 236 DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver);
236 }; 237 };
237 238
238 // Creates a HostResolver implementation that queries the underlying system. 239 // Creates a HostResolver implementation that queries the underlying system.
239 // (Except if a unit-test has changed the global HostResolverProc using 240 // (Except if a unit-test has changed the global HostResolverProc using
240 // ScopedHostResolverProc to intercept requests to the system). 241 // ScopedHostResolverProc to intercept requests to the system).
241 // |max_concurrent_resolves| is how many resolve requests will be allowed to 242 // |max_concurrent_resolves| is how many resolve requests will be allowed to
242 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a 243 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a
243 // default value. 244 // default value.
244 HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves, 245 NET_API HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves,
245 NetLog* net_log); 246 NetLog* net_log);
246 247
247 } // namespace net 248 } // namespace net
248 249
249 #endif // NET_BASE_HOST_RESOLVER_H_ 250 #endif // NET_BASE_HOST_RESOLVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698