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

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

Issue 612323010: Align base::hash_map with C++11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try a different tack for C++ insanity Created 6 years, 2 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
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)
26 25
27 template<> 26 template<>
28 struct hash<net::DnsHostsKey> { 27 struct hash<net::DnsHostsKey> {
29 std::size_t operator()(const net::DnsHostsKey& key) const { 28 std::size_t operator()(const net::DnsHostsKey& key) const {
30 hash<base::StringPiece> string_piece_hash; 29 hash<base::StringPiece> string_piece_hash;
31 return string_piece_hash(key.first) + key.second; 30 return string_piece_hash(key.first) + key.second;
32 } 31 }
33 }; 32 };
34 33
35 #elif defined(COMPILER_MSVC)
36
37 inline size_t hash_value(const net::DnsHostsKey& key) {
38 return hash_value(key.first) + key.second;
39 }
40
41 #endif // COMPILER
42
43 } // namespace BASE_HASH_NAMESPACE 34 } // namespace BASE_HASH_NAMESPACE
44 35
45 namespace net { 36 namespace net {
46 37
47 // 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.
48 enum ParseHostsCommaMode { 39 enum ParseHostsCommaMode {
49 // Comma is treated as part of a hostname: 40 // Comma is treated as part of a hostname:
50 // "127.0.0.1 foo,bar" parses as "foo,bar" mapping to "127.0.0.1". 41 // "127.0.0.1 foo,bar" parses as "foo,bar" mapping to "127.0.0.1".
51 PARSE_HOSTS_COMMA_IS_TOKEN, 42 PARSE_HOSTS_COMMA_IS_TOKEN,
52 43
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // As above but reads the file pointed to by |path|. 81 // As above but reads the file pointed to by |path|.
91 bool NET_EXPORT_PRIVATE ParseHostsFile(const base::FilePath& path, 82 bool NET_EXPORT_PRIVATE ParseHostsFile(const base::FilePath& path,
92 DnsHosts* dns_hosts); 83 DnsHosts* dns_hosts);
93 84
94 85
95 86
96 } // namespace net 87 } // namespace net
97 88
98 #endif // NET_DNS_DNS_HOSTS_H_ 89 #endif // NET_DNS_DNS_HOSTS_H_
99 90
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698