| 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 29 matching lines...) Expand all Loading... |
| 40 // callbacks of each waiting request are run on the origin thread. | 40 // callbacks of each waiting request are run on the origin thread. |
| 41 // | 41 // |
| 42 // Thread safety: This class is not threadsafe, and must only be called | 42 // Thread safety: This class is not threadsafe, and must only be called |
| 43 // from one thread! | 43 // from one thread! |
| 44 // | 44 // |
| 45 // The HostResolverImpl enforces |max_jobs_| as the maximum number of concurrent | 45 // The HostResolverImpl enforces |max_jobs_| as the maximum number of concurrent |
| 46 // threads. | 46 // threads. |
| 47 // | 47 // |
| 48 // Requests are ordered in the queue based on their priority. | 48 // Requests are ordered in the queue based on their priority. |
| 49 | 49 |
| 50 class HostResolverImpl : public HostResolver, | 50 class HostResolverImpl : public HostResolver { |
| 51 public NetworkChangeNotifier::Observer { | |
| 52 public: | 51 public: |
| 53 // The index into |job_pools_| for the various job pools. Pools with a higher | 52 // The index into |job_pools_| for the various job pools. Pools with a higher |
| 54 // index have lower priority. | 53 // index have lower priority. |
| 55 // | 54 // |
| 56 // Note: This is currently unused, since there is a single pool | 55 // Note: This is currently unused, since there is a single pool |
| 57 // for all requests. | 56 // for all requests. |
| 58 enum JobPoolIndex { | 57 enum JobPoolIndex { |
| 59 POOL_NORMAL = 0, | 58 POOL_NORMAL = 0, |
| 60 POOL_COUNT, | 59 POOL_COUNT, |
| 61 }; | 60 }; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 81 | 80 |
| 82 // HostResolver methods: | 81 // HostResolver methods: |
| 83 virtual int Resolve(const RequestInfo& info, | 82 virtual int Resolve(const RequestInfo& info, |
| 84 AddressList* addresses, | 83 AddressList* addresses, |
| 85 CompletionCallback* callback, | 84 CompletionCallback* callback, |
| 86 RequestHandle* out_req, | 85 RequestHandle* out_req, |
| 87 const BoundNetLog& net_log); | 86 const BoundNetLog& net_log); |
| 88 virtual void CancelRequest(RequestHandle req); | 87 virtual void CancelRequest(RequestHandle req); |
| 89 virtual void AddObserver(HostResolver::Observer* observer); | 88 virtual void AddObserver(HostResolver::Observer* observer); |
| 90 virtual void RemoveObserver(HostResolver::Observer* observer); | 89 virtual void RemoveObserver(HostResolver::Observer* observer); |
| 90 virtual void Flush(); |
| 91 | 91 |
| 92 // Set address family, and disable IPv6 probe support. | 92 // Set address family, and disable IPv6 probe support. |
| 93 virtual void SetDefaultAddressFamily(AddressFamily address_family); | 93 virtual void SetDefaultAddressFamily(AddressFamily address_family); |
| 94 | 94 |
| 95 // Continuously observe whether IPv6 is supported, and set the allowable | 95 // Continuously observe whether IPv6 is supported, and set the allowable |
| 96 // address family to IPv4 iff IPv6 is not supported. | 96 // address family to IPv4 iff IPv6 is not supported. |
| 97 void ProbeIPv6Support(); | 97 void ProbeIPv6Support(); |
| 98 | 98 |
| 99 virtual HostResolverImpl* GetAsHostResolverImpl() { return this; } | 99 virtual HostResolverImpl* GetAsHostResolverImpl() { return this; } |
| 100 | 100 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void OnFinishRequest(const BoundNetLog& net_log, | 173 void OnFinishRequest(const BoundNetLog& net_log, |
| 174 int request_id, | 174 int request_id, |
| 175 const RequestInfo& info, | 175 const RequestInfo& info, |
| 176 int error); | 176 int error); |
| 177 | 177 |
| 178 // Called when a request has been cancelled. | 178 // Called when a request has been cancelled. |
| 179 void OnCancelRequest(const BoundNetLog& net_log, | 179 void OnCancelRequest(const BoundNetLog& net_log, |
| 180 int request_id, | 180 int request_id, |
| 181 const RequestInfo& info); | 181 const RequestInfo& info); |
| 182 | 182 |
| 183 // NetworkChangeNotifier::Observer methods: | |
| 184 virtual void OnIPAddressChanged(); | |
| 185 | |
| 186 // Notify IPv6ProbeJob not to call back, and discard reference to the job. | 183 // Notify IPv6ProbeJob not to call back, and discard reference to the job. |
| 187 void DiscardIPv6ProbeJob(); | 184 void DiscardIPv6ProbeJob(); |
| 188 | 185 |
| 189 // Callback from IPv6 probe activity. | 186 // Callback from IPv6 probe activity. |
| 190 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); | 187 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); |
| 191 | 188 |
| 192 // Returns true if the constraints for |pool| are met, and a new job can be | 189 // Returns true if the constraints for |pool| are met, and a new job can be |
| 193 // created for this pool. | 190 // created for this pool. |
| 194 bool CanCreateJobForPool(const JobPool& pool) const; | 191 bool CanCreateJobForPool(const JobPool& pool) const; |
| 195 | 192 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 261 |
| 265 // The last un-cancelled IPv6ProbeJob (if any). | 262 // The last un-cancelled IPv6ProbeJob (if any). |
| 266 scoped_refptr<IPv6ProbeJob> ipv6_probe_job_; | 263 scoped_refptr<IPv6ProbeJob> ipv6_probe_job_; |
| 267 | 264 |
| 268 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 265 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
| 269 }; | 266 }; |
| 270 | 267 |
| 271 } // namespace net | 268 } // namespace net |
| 272 | 269 |
| 273 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 270 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |