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

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

Issue 1666843002: Refactor StringPiece hash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sort includes. Created 4 years, 10 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/linked_hash_map.h ('k') | net/http/http_server_properties_impl.h » ('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_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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "net/base/address_family.h" 17 #include "net/base/address_family.h"
18 #include "net/base/ip_address_number.h" 18 #include "net/base/ip_address_number.h"
19 #include "net/base/net_export.h" 19 #include "net/base/net_export.h"
20 20
21 namespace net { 21 namespace net {
22 typedef std::pair<std::string, AddressFamily> DnsHostsKey; 22 typedef std::pair<std::string, AddressFamily> DnsHostsKey;
23 }; 23 };
24 24
25 namespace BASE_HASH_NAMESPACE { 25 namespace BASE_HASH_NAMESPACE {
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 return base::StringPieceHash()(key.first) + key.second;
31 return string_piece_hash(key.first) + key.second;
32 } 31 }
33 }; 32 };
34 33
35 } // namespace BASE_HASH_NAMESPACE 34 } // namespace BASE_HASH_NAMESPACE
36 35
37 namespace net { 36 namespace net {
38 37
39 // There are OS-specific variations in how commas in the hosts file behave. 38 // There are OS-specific variations in how commas in the hosts file behave.
40 enum ParseHostsCommaMode { 39 enum ParseHostsCommaMode {
41 // Comma is treated as part of a hostname: 40 // Comma is treated as part of a hostname:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // As above but reads the file pointed to by |path|. 81 // As above but reads the file pointed to by |path|.
83 bool NET_EXPORT_PRIVATE ParseHostsFile(const base::FilePath& path, 82 bool NET_EXPORT_PRIVATE ParseHostsFile(const base::FilePath& path,
84 DnsHosts* dns_hosts); 83 DnsHosts* dns_hosts);
85 84
86 85
87 86
88 } // namespace net 87 } // namespace net
89 88
90 #endif // NET_DNS_DNS_HOSTS_H_ 89 #endif // NET_DNS_DNS_HOSTS_H_
91 90
OLDNEW
« no previous file with comments | « net/base/linked_hash_map.h ('k') | net/http/http_server_properties_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698