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

Side by Side Diff: net/base/host_cache.h

Issue 338023: Fix a bad comparator. This caused lookups in std::map to be wrong.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Remove %s from format string Created 11 years, 1 month 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
« no previous file with comments | « no previous file | net/base/host_cache_unittest.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_BASE_HOST_CACHE_H_ 5 #ifndef NET_BASE_HOST_CACHE_H_
6 #define NET_BASE_HOST_CACHE_H_ 6 #define NET_BASE_HOST_CACHE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 24 matching lines...) Expand all
35 struct Key { 35 struct Key {
36 Key(const std::string& hostname, AddressFamily address_family) 36 Key(const std::string& hostname, AddressFamily address_family)
37 : hostname(hostname), address_family(address_family) {} 37 : hostname(hostname), address_family(address_family) {}
38 38
39 bool operator==(const Key& other) const { 39 bool operator==(const Key& other) const {
40 return other.hostname == hostname && 40 return other.hostname == hostname &&
41 other.address_family == address_family; 41 other.address_family == address_family;
42 } 42 }
43 43
44 bool operator<(const Key& other) const { 44 bool operator<(const Key& other) const {
45 if (address_family < other.address_family) 45 if (address_family == other.address_family)
46 return true; 46 return hostname < other.hostname;
47 return hostname < other.hostname; 47 return address_family < other.address_family;
48 } 48 }
49 49
50 std::string hostname; 50 std::string hostname;
51 AddressFamily address_family; 51 AddressFamily address_family;
52 }; 52 };
53 53
54 typedef std::map<Key, scoped_refptr<Entry> > EntryMap; 54 typedef std::map<Key, scoped_refptr<Entry> > EntryMap;
55 55
56 // Constructs a HostCache whose entries are valid for |cache_duration_ms| 56 // Constructs a HostCache whose entries are valid for |cache_duration_ms|
57 // milliseconds. The cache will store up to |max_entries|. 57 // milliseconds. The cache will store up to |max_entries|.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Map from hostname (presumably in lowercase canonicalized format) to 115 // Map from hostname (presumably in lowercase canonicalized format) to
116 // a resolved result entry. 116 // a resolved result entry.
117 EntryMap entries_; 117 EntryMap entries_;
118 118
119 DISALLOW_COPY_AND_ASSIGN(HostCache); 119 DISALLOW_COPY_AND_ASSIGN(HostCache);
120 }; 120 };
121 121
122 } // namespace net 122 } // namespace net
123 123
124 #endif // NET_BASE_HOST_CACHE_H_ 124 #endif // NET_BASE_HOST_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/host_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698