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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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_DNS_HOSTS_H_ 5 #ifndef NET_DNS_DNS_HOSTS_H_
6 #define NET_DNS_DNS_HOSTS_H_ 6 #define NET_DNS_DNS_HOSTS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "net/base/address_family.h" 16 #include "net/base/address_family.h"
17 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
18 #include "net/base/net_util.h" // can't forward-declare IPAddressNumber 18 #include "net/base/net_util.h" // can't forward-declare IPAddressNumber
19 19
20 namespace net { 20 namespace net {
21 typedef std::pair<std::string, AddressFamily> DnsHostsKey; 21 typedef std::pair<std::string, AddressFamily> DnsHostsKey;
22 }; 22 };
23 23
24 namespace BASE_HASH_NAMESPACE { 24 namespace BASE_HASH_NAMESPACE {
25 #if defined(COMPILER_GCC) 25 #if defined(COMPILER_GCC)
26 26
27 template<> 27 template <>
28 struct hash<net::DnsHostsKey> { 28 struct hash<net::DnsHostsKey> {
29 std::size_t operator()(const net::DnsHostsKey& key) const { 29 std::size_t operator()(const net::DnsHostsKey& key) const {
30 hash<base::StringPiece> string_piece_hash; 30 hash<base::StringPiece> string_piece_hash;
31 return string_piece_hash(key.first) + key.second; 31 return string_piece_hash(key.first) + key.second;
32 } 32 }
33 }; 33 };
34 34
35 #elif defined(COMPILER_MSVC) 35 #elif defined(COMPILER_MSVC)
36 36
37 inline size_t hash_value(const net::DnsHostsKey& key) { 37 inline size_t hash_value(const net::DnsHostsKey& key) {
(...skipping 19 matching lines...) Expand all
57 #if !defined(OS_ANDROID) 57 #if !defined(OS_ANDROID)
58 typedef base::hash_map<DnsHostsKey, IPAddressNumber> DnsHosts; 58 typedef base::hash_map<DnsHostsKey, IPAddressNumber> DnsHosts;
59 #else 59 #else
60 // Android's hash_map doesn't support ==, so fall back to map. (Chromium on 60 // Android's hash_map doesn't support ==, so fall back to map. (Chromium on
61 // Android doesn't use the built-in DNS resolver anyway, so it's irrelevant.) 61 // Android doesn't use the built-in DNS resolver anyway, so it's irrelevant.)
62 typedef std::map<DnsHostsKey, IPAddressNumber> DnsHosts; 62 typedef std::map<DnsHostsKey, IPAddressNumber> DnsHosts;
63 #endif 63 #endif
64 64
65 // Parses |contents| (as read from /etc/hosts or equivalent) and stores results 65 // Parses |contents| (as read from /etc/hosts or equivalent) and stores results
66 // in |dns_hosts|. Invalid lines are ignored (as in most implementations). 66 // in |dns_hosts|. Invalid lines are ignored (as in most implementations).
67 void NET_EXPORT_PRIVATE ParseHosts(const std::string& contents, 67 void NET_EXPORT_PRIVATE
68 DnsHosts* dns_hosts); 68 ParseHosts(const std::string& contents, DnsHosts* dns_hosts);
69 69
70 // As above but reads the file pointed to by |path|. 70 // As above but reads the file pointed to by |path|.
71 bool NET_EXPORT_PRIVATE ParseHostsFile(const base::FilePath& path, 71 bool NET_EXPORT_PRIVATE
72 DnsHosts* dns_hosts); 72 ParseHostsFile(const base::FilePath& path, DnsHosts* dns_hosts);
73
74
75 73
76 } // namespace net 74 } // namespace net
77 75
78 #endif // NET_DNS_DNS_HOSTS_H_ 76 #endif // NET_DNS_DNS_HOSTS_H_
79
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698