Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: net/dns/host_resolver_impl.h

Issue 1177933002: Resolve RFC 6761 localhost names to loopback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rsleevi nit Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/net_util_unittest.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 typedef std::map<Key, Job*> JobMap; 154 typedef std::map<Key, Job*> JobMap;
155 typedef ScopedVector<Request> RequestsList; 155 typedef ScopedVector<Request> RequestsList;
156 156
157 // Number of consecutive failures of DnsTask (with successful fallback to 157 // Number of consecutive failures of DnsTask (with successful fallback to
158 // ProcTask) before the DnsClient is disabled until the next DNS change. 158 // ProcTask) before the DnsClient is disabled until the next DNS change.
159 static const unsigned kMaximumDnsFailures; 159 static const unsigned kMaximumDnsFailures;
160 160
161 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP 161 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP
162 // literal, cache and HOSTS lookup (if enabled), returns OK if successful, 162 // literal, cache and HOSTS lookup (if enabled), returns OK if successful,
163 // ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is 163 // ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is
164 // incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache and HOSTS. 164 // incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache and
165 // HOSTS and is not localhost.
165 int ResolveHelper(const Key& key, 166 int ResolveHelper(const Key& key,
166 const RequestInfo& info, 167 const RequestInfo& info,
167 const IPAddressNumber* ip_address, 168 const IPAddressNumber* ip_address,
168 AddressList* addresses, 169 AddressList* addresses,
169 const BoundNetLog& request_net_log); 170 const BoundNetLog& request_net_log);
170 171
171 // Tries to resolve |key| as an IP, returns true and sets |net_error| if 172 // Tries to resolve |key| as an IP, returns true and sets |net_error| if
172 // succeeds, returns false otherwise. 173 // succeeds, returns false otherwise.
173 bool ResolveAsIP(const Key& key, 174 bool ResolveAsIP(const Key& key,
174 const RequestInfo& info, 175 const RequestInfo& info,
175 const IPAddressNumber* ip_address, 176 const IPAddressNumber* ip_address,
176 int* net_error, 177 int* net_error,
177 AddressList* addresses); 178 AddressList* addresses);
178 179
179 // If |key| is not found in cache returns false, otherwise returns 180 // If |key| is not found in cache returns false, otherwise returns
180 // true, sets |net_error| to the cached error code and fills |addresses| 181 // true, sets |net_error| to the cached error code and fills |addresses|
181 // if it is a positive entry. 182 // if it is a positive entry.
182 bool ServeFromCache(const Key& key, 183 bool ServeFromCache(const Key& key,
183 const RequestInfo& info, 184 const RequestInfo& info,
184 int* net_error, 185 int* net_error,
185 AddressList* addresses); 186 AddressList* addresses);
186 187
187 // If we have a DnsClient with a valid DnsConfig, and |key| is found in the 188 // If we have a DnsClient with a valid DnsConfig, and |key| is found in the
188 // HOSTS file, returns true and fills |addresses|. Otherwise returns false. 189 // HOSTS file, returns true and fills |addresses|. Otherwise returns false.
189 bool ServeFromHosts(const Key& key, 190 bool ServeFromHosts(const Key& key,
190 const RequestInfo& info, 191 const RequestInfo& info,
191 AddressList* addresses); 192 AddressList* addresses);
192 193
194 // If |key| is for a localhost name (RFC 6761), returns true and fills
195 // |addresses| with the loopback IP. Otherwise returns false.
196 bool ServeLocalhost(const Key& key,
197 const RequestInfo& info,
198 AddressList* addresses);
199
193 // Callback from HaveOnlyLoopbackAddresses probe. 200 // Callback from HaveOnlyLoopbackAddresses probe.
194 void SetHaveOnlyLoopbackAddresses(bool result); 201 void SetHaveOnlyLoopbackAddresses(bool result);
195 202
196 // Returns the (hostname, address_family) key to use for |info|, choosing an 203 // Returns the (hostname, address_family) key to use for |info|, choosing an
197 // "effective" address family by inheriting the resolver's default address 204 // "effective" address family by inheriting the resolver's default address
198 // family when the request leaves it unspecified. 205 // family when the request leaves it unspecified.
199 Key GetEffectiveKeyForRequest(const RequestInfo& info, 206 Key GetEffectiveKeyForRequest(const RequestInfo& info,
200 const IPAddressNumber* ip_number, 207 const IPAddressNumber* ip_number,
201 const BoundNetLog& net_log); 208 const BoundNetLog& net_log);
202 209
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; 303 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_;
297 304
298 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; 305 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_;
299 306
300 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); 307 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl);
301 }; 308 };
302 309
303 } // namespace net 310 } // namespace net
304 311
305 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ 312 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_
OLDNEW
« no previous file with comments | « net/base/net_util_unittest.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698