OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DNS_HOST_RESOLVER_IMPL_H_ | 5 #ifndef NET_DNS_HOST_RESOLVER_IMPL_H_ |
6 #define NET_DNS_HOST_RESOLVER_IMPL_H_ | 6 #define NET_DNS_HOST_RESOLVER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Options.GetDispatcherLimits() determines the maximum number of jobs that | 104 // Options.GetDispatcherLimits() determines the maximum number of jobs that |
105 // the resolver will run at once. This upper-bounds the total number of | 105 // the resolver will run at once. This upper-bounds the total number of |
106 // outstanding DNS transactions (not counting retransmissions and retries). | 106 // outstanding DNS transactions (not counting retransmissions and retries). |
107 // | 107 // |
108 // |net_log| must remain valid for the life of the HostResolverImpl. | 108 // |net_log| must remain valid for the life of the HostResolverImpl. |
109 HostResolverImpl(const Options& options, NetLog* net_log); | 109 HostResolverImpl(const Options& options, NetLog* net_log); |
110 | 110 |
111 // If any completion callbacks are pending when the resolver is destroyed, | 111 // If any completion callbacks are pending when the resolver is destroyed, |
112 // the host resolutions are cancelled, and the completion callbacks will not | 112 // the host resolutions are cancelled, and the completion callbacks will not |
113 // be called. | 113 // be called. |
114 virtual ~HostResolverImpl(); | 114 ~HostResolverImpl() override; |
115 | 115 |
116 // Configures maximum number of Jobs in the queue. Exposed for testing. | 116 // Configures maximum number of Jobs in the queue. Exposed for testing. |
117 // Only allowed when the queue is empty. | 117 // Only allowed when the queue is empty. |
118 void SetMaxQueuedJobs(size_t value); | 118 void SetMaxQueuedJobs(size_t value); |
119 | 119 |
120 // Set the DnsClient to be used for resolution. In case of failure, the | 120 // Set the DnsClient to be used for resolution. In case of failure, the |
121 // HostResolverProc from ProcTaskParams will be queried. If the DnsClient is | 121 // HostResolverProc from ProcTaskParams will be queried. If the DnsClient is |
122 // not pre-configured with a valid DnsConfig, a new config is fetched from | 122 // not pre-configured with a valid DnsConfig, a new config is fetched from |
123 // NetworkChangeNotifier. | 123 // NetworkChangeNotifier. |
124 void SetDnsClient(scoped_ptr<DnsClient> dns_client); | 124 void SetDnsClient(scoped_ptr<DnsClient> dns_client); |
125 | 125 |
126 // HostResolver methods: | 126 // HostResolver methods: |
127 virtual int Resolve(const RequestInfo& info, | 127 int Resolve(const RequestInfo& info, |
128 RequestPriority priority, | 128 RequestPriority priority, |
129 AddressList* addresses, | 129 AddressList* addresses, |
130 const CompletionCallback& callback, | 130 const CompletionCallback& callback, |
131 RequestHandle* out_req, | 131 RequestHandle* out_req, |
132 const BoundNetLog& source_net_log) override; | 132 const BoundNetLog& source_net_log) override; |
133 virtual int ResolveFromCache(const RequestInfo& info, | 133 int ResolveFromCache(const RequestInfo& info, |
134 AddressList* addresses, | 134 AddressList* addresses, |
135 const BoundNetLog& source_net_log) override; | 135 const BoundNetLog& source_net_log) override; |
136 virtual void CancelRequest(RequestHandle req) override; | 136 void CancelRequest(RequestHandle req) override; |
137 virtual void SetDefaultAddressFamily(AddressFamily address_family) override; | 137 void SetDefaultAddressFamily(AddressFamily address_family) override; |
138 virtual AddressFamily GetDefaultAddressFamily() const override; | 138 AddressFamily GetDefaultAddressFamily() const override; |
139 virtual void SetDnsClientEnabled(bool enabled) override; | 139 void SetDnsClientEnabled(bool enabled) override; |
140 virtual HostCache* GetHostCache() override; | 140 HostCache* GetHostCache() override; |
141 virtual base::Value* GetDnsConfigAsValue() const override; | 141 base::Value* GetDnsConfigAsValue() const override; |
142 | 142 |
143 void set_proc_params_for_test(const ProcTaskParams& proc_params) { | 143 void set_proc_params_for_test(const ProcTaskParams& proc_params) { |
144 proc_params_ = proc_params; | 144 proc_params_ = proc_params; |
145 } | 145 } |
146 | 146 |
147 private: | 147 private: |
148 friend class HostResolverImplTest; | 148 friend class HostResolverImplTest; |
149 class Job; | 149 class Job; |
150 class ProcTask; | 150 class ProcTask; |
151 class LoopbackProbeJob; | 151 class LoopbackProbeJob; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // Aborts all in progress DnsTasks. In-progress jobs will fall back to | 213 // Aborts all in progress DnsTasks. In-progress jobs will fall back to |
214 // ProcTasks. Might start new jobs, if any jobs were taking up two dispatcher | 214 // ProcTasks. Might start new jobs, if any jobs were taking up two dispatcher |
215 // slots. | 215 // slots. |
216 void AbortDnsTasks(); | 216 void AbortDnsTasks(); |
217 | 217 |
218 // Attempts to serve each Job in |jobs_| from the HOSTS file if we have | 218 // Attempts to serve each Job in |jobs_| from the HOSTS file if we have |
219 // a DnsClient with a valid DnsConfig. | 219 // a DnsClient with a valid DnsConfig. |
220 void TryServingAllJobsFromHosts(); | 220 void TryServingAllJobsFromHosts(); |
221 | 221 |
222 // NetworkChangeNotifier::IPAddressObserver: | 222 // NetworkChangeNotifier::IPAddressObserver: |
223 virtual void OnIPAddressChanged() override; | 223 void OnIPAddressChanged() override; |
224 | 224 |
225 // NetworkChangeNotifier::DNSObserver: | 225 // NetworkChangeNotifier::DNSObserver: |
226 virtual void OnDNSChanged() override; | 226 void OnDNSChanged() override; |
227 | 227 |
228 // True if have a DnsClient with a valid DnsConfig. | 228 // True if have a DnsClient with a valid DnsConfig. |
229 bool HaveDnsConfig() const; | 229 bool HaveDnsConfig() const; |
230 | 230 |
231 // Called when a host name is successfully resolved and DnsTask was run on it | 231 // Called when a host name is successfully resolved and DnsTask was run on it |
232 // and resulted in |net_error|. | 232 // and resulted in |net_error|. |
233 void OnDnsTaskResolve(int net_error); | 233 void OnDnsTaskResolve(int net_error); |
234 | 234 |
235 // Allows the tests to catch slots leaking out of the dispatcher. One | 235 // Allows the tests to catch slots leaking out of the dispatcher. One |
236 // HostResolverImpl::Job could occupy multiple PrioritizedDispatcher job | 236 // HostResolverImpl::Job could occupy multiple PrioritizedDispatcher job |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; | 290 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; |
291 | 291 |
292 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; | 292 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; |
293 | 293 |
294 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 294 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
295 }; | 295 }; |
296 | 296 |
297 } // namespace net | 297 } // namespace net |
298 | 298 |
299 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ | 299 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |