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 { |
51 public: | 52 public: |
52 // The index into |job_pools_| for the various job pools. Pools with a higher | 53 // The index into |job_pools_| for the various job pools. Pools with a higher |
53 // index have lower priority. | 54 // index have lower priority. |
54 // | 55 // |
55 // Note: This is currently unused, since there is a single pool | 56 // Note: This is currently unused, since there is a single pool |
56 // for all requests. | 57 // for all requests. |
57 enum JobPoolIndex { | 58 enum JobPoolIndex { |
58 POOL_NORMAL = 0, | 59 POOL_NORMAL = 0, |
59 POOL_COUNT, | 60 POOL_COUNT, |
60 }; | 61 }; |
(...skipping 19 matching lines...) Expand all Loading... |
80 | 81 |
81 // HostResolver methods: | 82 // HostResolver methods: |
82 virtual int Resolve(const RequestInfo& info, | 83 virtual int Resolve(const RequestInfo& info, |
83 AddressList* addresses, | 84 AddressList* addresses, |
84 CompletionCallback* callback, | 85 CompletionCallback* callback, |
85 RequestHandle* out_req, | 86 RequestHandle* out_req, |
86 const BoundNetLog& net_log); | 87 const BoundNetLog& net_log); |
87 virtual void CancelRequest(RequestHandle req); | 88 virtual void CancelRequest(RequestHandle req); |
88 virtual void AddObserver(HostResolver::Observer* observer); | 89 virtual void AddObserver(HostResolver::Observer* observer); |
89 virtual void RemoveObserver(HostResolver::Observer* observer); | 90 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 |
183 // Notify IPv6ProbeJob not to call back, and discard reference to the job. | 186 // Notify IPv6ProbeJob not to call back, and discard reference to the job. |
184 void DiscardIPv6ProbeJob(); | 187 void DiscardIPv6ProbeJob(); |
185 | 188 |
186 // Callback from IPv6 probe activity. | 189 // Callback from IPv6 probe activity. |
187 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); | 190 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); |
188 | 191 |
189 // 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 |
190 // created for this pool. | 193 // created for this pool. |
191 bool CanCreateJobForPool(const JobPool& pool) const; | 194 bool CanCreateJobForPool(const JobPool& pool) const; |
192 | 195 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 264 |
262 // The last un-cancelled IPv6ProbeJob (if any). | 265 // The last un-cancelled IPv6ProbeJob (if any). |
263 scoped_refptr<IPv6ProbeJob> ipv6_probe_job_; | 266 scoped_refptr<IPv6ProbeJob> ipv6_probe_job_; |
264 | 267 |
265 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 268 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
266 }; | 269 }; |
267 | 270 |
268 } // namespace net | 271 } // namespace net |
269 | 272 |
270 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 273 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |