| 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_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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 HostResolverImpl(HostResolverProc* resolver_proc, | 80 HostResolverImpl(HostResolverProc* resolver_proc, |
| 81 HostCache* cache, | 81 HostCache* cache, |
| 82 size_t max_jobs, | 82 size_t max_jobs, |
| 83 NetLog* net_log); | 83 NetLog* net_log); |
| 84 | 84 |
| 85 // If any completion callbacks are pending when the resolver is destroyed, | 85 // If any completion callbacks are pending when the resolver is destroyed, |
| 86 // the host resolutions are cancelled, and the completion callbacks will not | 86 // the host resolutions are cancelled, and the completion callbacks will not |
| 87 // be called. | 87 // be called. |
| 88 virtual ~HostResolverImpl(); | 88 virtual ~HostResolverImpl(); |
| 89 | 89 |
| 90 // HostResolver methods: | |
| 91 virtual int Resolve(const RequestInfo& info, | |
| 92 AddressList* addresses, | |
| 93 CompletionCallback* callback, | |
| 94 RequestHandle* out_req, | |
| 95 const BoundNetLog& source_net_log); | |
| 96 virtual void CancelRequest(RequestHandle req); | |
| 97 virtual void AddObserver(HostResolver::Observer* observer); | |
| 98 virtual void RemoveObserver(HostResolver::Observer* observer); | |
| 99 | |
| 100 // Set address family, and disable IPv6 probe support. | |
| 101 virtual void SetDefaultAddressFamily(AddressFamily address_family); | |
| 102 virtual AddressFamily GetDefaultAddressFamily() const; | |
| 103 | |
| 104 // Continuously observe whether IPv6 is supported, and set the allowable | 90 // Continuously observe whether IPv6 is supported, and set the allowable |
| 105 // address family to IPv4 iff IPv6 is not supported. | 91 // address family to IPv4 iff IPv6 is not supported. |
| 106 void ProbeIPv6Support(); | 92 void ProbeIPv6Support(); |
| 107 | 93 |
| 108 virtual HostResolverImpl* GetAsHostResolverImpl(); | |
| 109 | |
| 110 // TODO(eroman): hack for http://crbug.com/15513 | |
| 111 virtual void Shutdown(); | |
| 112 | |
| 113 // Returns the cache this resolver uses, or NULL if caching is disabled. | 94 // Returns the cache this resolver uses, or NULL if caching is disabled. |
| 114 HostCache* cache() { return cache_.get(); } | 95 HostCache* cache() { return cache_.get(); } |
| 115 | 96 |
| 116 // Applies a set of constraints for requests that belong to the specified | 97 // Applies a set of constraints for requests that belong to the specified |
| 117 // pool. NOTE: Don't call this after requests have been already been started. | 98 // pool. NOTE: Don't call this after requests have been already been started. |
| 118 // | 99 // |
| 119 // |pool_index| -- Specifies which pool these constraints should be applied | 100 // |pool_index| -- Specifies which pool these constraints should be applied |
| 120 // to. | 101 // to. |
| 121 // |max_outstanding_jobs| -- How many concurrent jobs are allowed for this | 102 // |max_outstanding_jobs| -- How many concurrent jobs are allowed for this |
| 122 // pool. | 103 // pool. |
| 123 // |max_pending_requests| -- How many requests can be enqueued for this pool | 104 // |max_pending_requests| -- How many requests can be enqueued for this pool |
| 124 // before we start dropping requests. Dropped | 105 // before we start dropping requests. Dropped |
| 125 // requests fail with | 106 // requests fail with |
| 126 // ERR_HOST_RESOLVER_QUEUE_TOO_LARGE. | 107 // ERR_HOST_RESOLVER_QUEUE_TOO_LARGE. |
| 127 void SetPoolConstraints(JobPoolIndex pool_index, | 108 void SetPoolConstraints(JobPoolIndex pool_index, |
| 128 size_t max_outstanding_jobs, | 109 size_t max_outstanding_jobs, |
| 129 size_t max_pending_requests); | 110 size_t max_pending_requests); |
| 130 | 111 |
| 112 // HostResolver methods: |
| 113 virtual int Resolve(const RequestInfo& info, |
| 114 AddressList* addresses, |
| 115 CompletionCallback* callback, |
| 116 RequestHandle* out_req, |
| 117 const BoundNetLog& source_net_log); |
| 118 virtual void CancelRequest(RequestHandle req); |
| 119 virtual void AddObserver(HostResolver::Observer* observer); |
| 120 virtual void RemoveObserver(HostResolver::Observer* observer); |
| 121 |
| 122 // Set address family, and disable IPv6 probe support. |
| 123 virtual void SetDefaultAddressFamily(AddressFamily address_family); |
| 124 virtual AddressFamily GetDefaultAddressFamily() const; |
| 125 |
| 126 virtual HostResolverImpl* GetAsHostResolverImpl(); |
| 127 |
| 128 // TODO(eroman): hack for http://crbug.com/15513 |
| 129 virtual void Shutdown(); |
| 130 |
| 131 private: | 131 private: |
| 132 class Job; | 132 class Job; |
| 133 class JobPool; | 133 class JobPool; |
| 134 class IPv6ProbeJob; | 134 class IPv6ProbeJob; |
| 135 class Request; | 135 class Request; |
| 136 typedef std::vector<Request*> RequestsList; | 136 typedef std::vector<Request*> RequestsList; |
| 137 typedef HostCache::Key Key; | 137 typedef HostCache::Key Key; |
| 138 typedef std::map<Key, scoped_refptr<Job> > JobMap; | 138 typedef std::map<Key, scoped_refptr<Job> > JobMap; |
| 139 typedef std::vector<HostResolver::Observer*> ObserversList; | 139 typedef std::vector<HostResolver::Observer*> ObserversList; |
| 140 | 140 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 const RequestInfo& info, | 178 const RequestInfo& info, |
| 179 int net_error, | 179 int net_error, |
| 180 int os_error); | 180 int os_error); |
| 181 | 181 |
| 182 // Called when a request has been cancelled. | 182 // Called when a request has been cancelled. |
| 183 void OnCancelRequest(const BoundNetLog& source_net_log, | 183 void OnCancelRequest(const BoundNetLog& source_net_log, |
| 184 const BoundNetLog& request_net_log, | 184 const BoundNetLog& request_net_log, |
| 185 int request_id, | 185 int request_id, |
| 186 const RequestInfo& info); | 186 const RequestInfo& info); |
| 187 | 187 |
| 188 // NetworkChangeNotifier::Observer methods: | |
| 189 virtual void OnIPAddressChanged(); | |
| 190 | |
| 191 // Notify IPv6ProbeJob not to call back, and discard reference to the job. | 188 // Notify IPv6ProbeJob not to call back, and discard reference to the job. |
| 192 void DiscardIPv6ProbeJob(); | 189 void DiscardIPv6ProbeJob(); |
| 193 | 190 |
| 194 // Callback from IPv6 probe activity. | 191 // Callback from IPv6 probe activity. |
| 195 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); | 192 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); |
| 196 | 193 |
| 197 // Returns true if the constraints for |pool| are met, and a new job can be | 194 // Returns true if the constraints for |pool| are met, and a new job can be |
| 198 // created for this pool. | 195 // created for this pool. |
| 199 bool CanCreateJobForPool(const JobPool& pool) const; | 196 bool CanCreateJobForPool(const JobPool& pool) const; |
| 200 | 197 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 219 | 216 |
| 220 // Adds a pending request |req| to |pool|. | 217 // Adds a pending request |req| to |pool|. |
| 221 int EnqueueRequest(JobPool* pool, Request* req); | 218 int EnqueueRequest(JobPool* pool, Request* req); |
| 222 | 219 |
| 223 // Cancels all jobs. | 220 // Cancels all jobs. |
| 224 void CancelAllJobs(); | 221 void CancelAllJobs(); |
| 225 | 222 |
| 226 // Aborts all in progress jobs (but might start new ones). | 223 // Aborts all in progress jobs (but might start new ones). |
| 227 void AbortAllInProgressJobs(); | 224 void AbortAllInProgressJobs(); |
| 228 | 225 |
| 226 // NetworkChangeNotifier::Observer methods: |
| 227 virtual void OnIPAddressChanged(); |
| 228 |
| 229 // Cache of host resolution results. | 229 // Cache of host resolution results. |
| 230 scoped_ptr<HostCache> cache_; | 230 scoped_ptr<HostCache> cache_; |
| 231 | 231 |
| 232 // Map from hostname to outstanding job. | 232 // Map from hostname to outstanding job. |
| 233 JobMap jobs_; | 233 JobMap jobs_; |
| 234 | 234 |
| 235 // Maximum number of concurrent jobs allowed, across all pools. | 235 // Maximum number of concurrent jobs allowed, across all pools. |
| 236 size_t max_jobs_; | 236 size_t max_jobs_; |
| 237 | 237 |
| 238 // The information to track pending requests for a JobPool, as well as | 238 // The information to track pending requests for a JobPool, as well as |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 HostResolverFlags additional_resolver_flags_; | 276 HostResolverFlags additional_resolver_flags_; |
| 277 | 277 |
| 278 NetLog* net_log_; | 278 NetLog* net_log_; |
| 279 | 279 |
| 280 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 280 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 } // namespace net | 283 } // namespace net |
| 284 | 284 |
| 285 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 285 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |