OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_IMPL_H_ | 5 #ifndef NET_BASE_HOST_RESOLVER_IMPL_H_ |
6 #define NET_BASE_HOST_RESOLVER_IMPL_H_ | 6 #define NET_BASE_HOST_RESOLVER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // HostResolver methods: | 82 // HostResolver methods: |
83 virtual int Resolve(const RequestInfo& info, | 83 virtual int Resolve(const RequestInfo& info, |
84 AddressList* addresses, | 84 AddressList* addresses, |
85 CompletionCallback* callback, | 85 CompletionCallback* callback, |
86 RequestHandle* out_req, | 86 RequestHandle* out_req, |
87 const BoundNetLog& net_log); | 87 const BoundNetLog& net_log); |
88 virtual void CancelRequest(RequestHandle req); | 88 virtual void CancelRequest(RequestHandle req); |
89 virtual void AddObserver(HostResolver::Observer* observer); | 89 virtual void AddObserver(HostResolver::Observer* observer); |
90 virtual void RemoveObserver(HostResolver::Observer* observer); | 90 virtual void RemoveObserver(HostResolver::Observer* observer); |
91 | 91 |
92 virtual void SetDefaultAddressFamily(AddressFamily address_family) { | 92 // Set address family, and disable IPv6 probe support. |
93 default_address_family_ = address_family; | 93 virtual void SetDefaultAddressFamily(AddressFamily address_family); |
94 } | 94 |
| 95 // Continuously observe whether IPv6 is supported, and set the allowable |
| 96 // address family to IPv4 iff IPv6 is not supported. |
| 97 void ProbeIPv6Support(); |
95 | 98 |
96 virtual HostResolverImpl* GetAsHostResolverImpl() { return this; } | 99 virtual HostResolverImpl* GetAsHostResolverImpl() { return this; } |
97 | 100 |
98 // TODO(eroman): hack for http://crbug.com/15513 | 101 // TODO(eroman): hack for http://crbug.com/15513 |
99 void Shutdown(); | 102 void Shutdown(); |
100 | 103 |
101 // Returns the cache this resolver uses, or NULL if caching is disabled. | 104 // Returns the cache this resolver uses, or NULL if caching is disabled. |
102 HostCache* cache() { return cache_.get(); } | 105 HostCache* cache() { return cache_.get(); } |
103 | 106 |
104 // Clears the request trace log. | 107 // Clears the request trace log. |
(...skipping 18 matching lines...) Expand all Loading... |
123 // before we start dropping requests. Dropped | 126 // before we start dropping requests. Dropped |
124 // requests fail with | 127 // requests fail with |
125 // ERR_HOST_RESOLVER_QUEUE_TOO_LARGE. | 128 // ERR_HOST_RESOLVER_QUEUE_TOO_LARGE. |
126 void SetPoolConstraints(JobPoolIndex pool_index, | 129 void SetPoolConstraints(JobPoolIndex pool_index, |
127 size_t max_outstanding_jobs, | 130 size_t max_outstanding_jobs, |
128 size_t max_pending_requests); | 131 size_t max_pending_requests); |
129 | 132 |
130 private: | 133 private: |
131 class Job; | 134 class Job; |
132 class JobPool; | 135 class JobPool; |
| 136 class IPv6ProbeJob; |
133 class Request; | 137 class Request; |
134 class RequestsTrace; | 138 class RequestsTrace; |
135 typedef std::vector<Request*> RequestsList; | 139 typedef std::vector<Request*> RequestsList; |
136 typedef HostCache::Key Key; | 140 typedef HostCache::Key Key; |
137 typedef std::map<Key, scoped_refptr<Job> > JobMap; | 141 typedef std::map<Key, scoped_refptr<Job> > JobMap; |
138 typedef std::vector<HostResolver::Observer*> ObserversList; | 142 typedef std::vector<HostResolver::Observer*> ObserversList; |
139 | 143 |
140 // If any completion callbacks are pending when the resolver is destroyed, | 144 // If any completion callbacks are pending when the resolver is destroyed, |
141 // the host resolutions are cancelled, and the completion callbacks will not | 145 // the host resolutions are cancelled, and the completion callbacks will not |
142 // be called. | 146 // be called. |
(...skipping 29 matching lines...) Expand all Loading... |
172 int error); | 176 int error); |
173 | 177 |
174 // Called when a request has been cancelled. | 178 // Called when a request has been cancelled. |
175 void OnCancelRequest(const BoundNetLog& net_log, | 179 void OnCancelRequest(const BoundNetLog& net_log, |
176 int request_id, | 180 int request_id, |
177 const RequestInfo& info); | 181 const RequestInfo& info); |
178 | 182 |
179 // NetworkChangeNotifier::Observer methods: | 183 // NetworkChangeNotifier::Observer methods: |
180 virtual void OnIPAddressChanged(); | 184 virtual void OnIPAddressChanged(); |
181 | 185 |
| 186 // Notify IPv6ProbeJob not to call back, and discard reference to the job. |
| 187 void DiscardIPv6ProbeJob(); |
| 188 |
| 189 // Callback from IPv6 probe activity. |
| 190 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); |
| 191 |
182 // Returns true if the constraints for |pool| are met, and a new job can be | 192 // Returns true if the constraints for |pool| are met, and a new job can be |
183 // created for this pool. | 193 // created for this pool. |
184 bool CanCreateJobForPool(const JobPool& pool) const; | 194 bool CanCreateJobForPool(const JobPool& pool) const; |
185 | 195 |
186 // Returns the index of the pool that request |req| maps to. | 196 // Returns the index of the pool that request |req| maps to. |
187 static JobPoolIndex GetJobPoolIndexForRequest(const Request* req); | 197 static JobPoolIndex GetJobPoolIndexForRequest(const Request* req); |
188 | 198 |
189 JobPool* GetPoolForRequest(const Request* req) { | 199 JobPool* GetPoolForRequest(const Request* req) { |
190 return job_pools_[GetJobPoolIndexForRequest(req)]; | 200 return job_pools_[GetJobPoolIndexForRequest(req)]; |
191 } | 201 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // Address family to use when the request doesn't specify one. | 250 // Address family to use when the request doesn't specify one. |
241 AddressFamily default_address_family_; | 251 AddressFamily default_address_family_; |
242 | 252 |
243 // TODO(eroman): hack for http://crbug.com/15513 | 253 // TODO(eroman): hack for http://crbug.com/15513 |
244 bool shutdown_; | 254 bool shutdown_; |
245 | 255 |
246 NetworkChangeNotifier* const network_change_notifier_; | 256 NetworkChangeNotifier* const network_change_notifier_; |
247 | 257 |
248 scoped_refptr<RequestsTrace> requests_trace_; | 258 scoped_refptr<RequestsTrace> requests_trace_; |
249 | 259 |
| 260 // Indicate if probing is done after each network change event to set address |
| 261 // family. |
| 262 // When false, explicit setting of address family is used. |
| 263 bool ipv6_probe_monitoring_; |
| 264 |
| 265 // The last un-cancelled IPv6ProbeJob (if any). |
| 266 scoped_refptr<IPv6ProbeJob> ipv6_probe_job_; |
| 267 |
250 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 268 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
251 }; | 269 }; |
252 | 270 |
253 } // namespace net | 271 } // namespace net |
254 | 272 |
255 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 273 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |