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 23 matching lines...) Expand all Loading... |
34 // goes out of scope). | 34 // goes out of scope). |
35 class HostResolver : public base::RefCountedThreadSafe<HostResolver> { | 35 class HostResolver : public base::RefCountedThreadSafe<HostResolver> { |
36 public: | 36 public: |
37 // The parameters for doing a Resolve(). |hostname| and |port| are required, | 37 // The parameters for doing a Resolve(). |hostname| and |port| are required, |
38 // the rest are optional (and have reasonable defaults). | 38 // the rest are optional (and have reasonable defaults). |
39 class RequestInfo { | 39 class RequestInfo { |
40 public: | 40 public: |
41 RequestInfo(const std::string& hostname, int port) | 41 RequestInfo(const std::string& hostname, int port) |
42 : hostname_(hostname), | 42 : hostname_(hostname), |
43 address_family_(ADDRESS_FAMILY_UNSPECIFIED), | 43 address_family_(ADDRESS_FAMILY_UNSPECIFIED), |
44 host_resolver_flags_(0), | |
45 port_(port), | 44 port_(port), |
46 allow_cached_response_(true), | 45 allow_cached_response_(true), |
47 is_speculative_(false), | 46 is_speculative_(false), |
48 priority_(MEDIUM) {} | 47 priority_(MEDIUM) {} |
49 | 48 |
50 int port() const { return port_; } | 49 int port() const { return port_; } |
51 void set_port(int port) { | 50 void set_port(int port) { |
52 port_ = port; | 51 port_ = port; |
53 } | 52 } |
54 | 53 |
55 const std::string& hostname() const { return hostname_; } | 54 const std::string& hostname() const { return hostname_; } |
56 void set_hostname(const std::string& hostname) { | 55 void set_hostname(const std::string& hostname) { |
57 hostname_ = hostname; | 56 hostname_ = hostname; |
58 } | 57 } |
59 | 58 |
60 AddressFamily address_family() const { return address_family_; } | 59 AddressFamily address_family() const { return address_family_; } |
61 void set_address_family(AddressFamily address_family) { | 60 void set_address_family(AddressFamily address_family) { |
62 address_family_ = address_family; | 61 address_family_ = address_family; |
63 } | 62 } |
64 | 63 |
65 HostResolverFlags host_resolver_flags() const { | |
66 return host_resolver_flags_; | |
67 } | |
68 void set_host_resolver_flags(HostResolverFlags host_resolver_flags) { | |
69 host_resolver_flags_ = host_resolver_flags; | |
70 } | |
71 | |
72 bool allow_cached_response() const { return allow_cached_response_; } | 64 bool allow_cached_response() const { return allow_cached_response_; } |
73 void set_allow_cached_response(bool b) { allow_cached_response_ = b; } | 65 void set_allow_cached_response(bool b) { allow_cached_response_ = b; } |
74 | 66 |
75 bool is_speculative() const { return is_speculative_; } | 67 bool is_speculative() const { return is_speculative_; } |
76 void set_is_speculative(bool b) { is_speculative_ = b; } | 68 void set_is_speculative(bool b) { is_speculative_ = b; } |
77 | 69 |
78 RequestPriority priority() const { return priority_; } | 70 RequestPriority priority() const { return priority_; } |
79 void set_priority(RequestPriority priority) { priority_ = priority; } | 71 void set_priority(RequestPriority priority) { priority_ = priority; } |
80 | 72 |
81 const GURL& referrer() const { return referrer_; } | 73 const GURL& referrer() const { return referrer_; } |
82 void set_referrer(const GURL& referrer) { referrer_ = referrer; } | 74 void set_referrer(const GURL& referrer) { referrer_ = referrer; } |
83 | 75 |
84 private: | 76 private: |
85 // The hostname to resolve. | 77 // The hostname to resolve. |
86 std::string hostname_; | 78 std::string hostname_; |
87 | 79 |
88 // The address family to restrict results to. | 80 // The address family to restrict results to. |
89 AddressFamily address_family_; | 81 AddressFamily address_family_; |
90 | 82 |
91 // Flags for the address. | |
92 HostResolverFlags host_resolver_flags_; | |
93 | |
94 // The port number to set in the result's sockaddrs. | 83 // The port number to set in the result's sockaddrs. |
95 int port_; | 84 int port_; |
96 | 85 |
97 // Whether it is ok to return a result from the host cache. | 86 // Whether it is ok to return a result from the host cache. |
98 bool allow_cached_response_; | 87 bool allow_cached_response_; |
99 | 88 |
100 // Whether this request was started by the DNS prefetcher. | 89 // Whether this request was started by the DNS prefetcher. |
101 bool is_speculative_; | 90 bool is_speculative_; |
102 | 91 |
103 // The priority for the request. | 92 // The priority for the request. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // (Except if a unit-test has changed the global HostResolverProc using | 226 // (Except if a unit-test has changed the global HostResolverProc using |
238 // ScopedHostResolverProc to intercept requests to the system). | 227 // ScopedHostResolverProc to intercept requests to the system). |
239 // |network_change_notifier| must outlive HostResolver. It can optionally be | 228 // |network_change_notifier| must outlive HostResolver. It can optionally be |
240 // NULL, in which case HostResolver will not respond to network changes. | 229 // NULL, in which case HostResolver will not respond to network changes. |
241 HostResolver* CreateSystemHostResolver( | 230 HostResolver* CreateSystemHostResolver( |
242 NetworkChangeNotifier* network_change_notifier); | 231 NetworkChangeNotifier* network_change_notifier); |
243 | 232 |
244 } // namespace net | 233 } // namespace net |
245 | 234 |
246 #endif // NET_BASE_HOST_RESOLVER_H_ | 235 #endif // NET_BASE_HOST_RESOLVER_H_ |
OLD | NEW |