Enabling tests which should be fixed by r173829.
[chromium-blink-merge.git] / net / dns / dns_hosts.h
blobd6e6b47cdeb4293c1a03129d0e009179bb2339a9
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
3 // found in the LICENSE file.
5 #ifndef NET_DNS_DNS_HOSTS_H_
6 #define NET_DNS_DNS_HOSTS_H_
8 #include <map>
9 #include <string>
10 #include <utility>
11 #include <vector>
13 #include "base/file_path.h"
14 #include "net/base/address_family.h"
15 #include "net/base/net_export.h"
16 #include "net/base/net_util.h" // can't forward-declare IPAddressNumber
18 namespace net {
20 // Parsed results of a Hosts file.
22 // Although Hosts files map IP address to a list of domain names, for name
23 // resolution the desired mapping direction is: domain name to IP address.
24 // When parsing Hosts, we apply the "first hit" rule as Windows and glibc do.
25 // With a Hosts file of:
26 // 300.300.300.300 localhost # bad ip
27 // 127.0.0.1 localhost
28 // 10.0.0.1 localhost
29 // The expected resolution of localhost is 127.0.0.1.
30 typedef std::pair<std::string, AddressFamily> DnsHostsKey;
31 typedef std::map<DnsHostsKey, IPAddressNumber> DnsHosts;
33 // Parses |contents| (as read from /etc/hosts or equivalent) and stores results
34 // in |dns_hosts|. Invalid lines are ignored (as in most implementations).
35 void NET_EXPORT_PRIVATE ParseHosts(const std::string& contents,
36 DnsHosts* dns_hosts);
38 // As above but reads the file pointed to by |path|.
39 bool NET_EXPORT_PRIVATE ParseHostsFile(const FilePath& path,
40 DnsHosts* dns_hosts);
44 } // namespace net
46 #endif // NET_DNS_DNS_HOSTS_H_