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

Side by Side Diff: net/http/http_server_properties_impl.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/dns/dns_hosts.h ('k') | net/quic/quic_blocked_writer_interface.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_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/containers/hash_tables.h"
18 #include "base/macros.h" 17 #include "base/macros.h"
19 #include "base/threading/non_thread_safe.h" 18 #include "base/threading/non_thread_safe.h"
20 #include "base/values.h" 19 #include "base/values.h"
21 #include "net/base/host_port_pair.h" 20 #include "net/base/host_port_pair.h"
22 #include "net/base/linked_hash_map.h" 21 #include "net/base/linked_hash_map.h"
23 #include "net/base/net_export.h" 22 #include "net/base/net_export.h"
24 #include "net/http/http_server_properties.h" 23 #include "net/http/http_server_properties.h"
25 24
26 namespace base { 25 namespace base {
27 class ListValue; 26 class ListValue;
28 } 27 }
29 28
30 namespace BASE_HASH_NAMESPACE { 29 namespace net {
31 30
32 template <> 31 struct AlternativeServiceHash {
33 struct hash<net::AlternativeService> {
34 size_t operator()(const net::AlternativeService& entry) const { 32 size_t operator()(const net::AlternativeService& entry) const {
35 return entry.protocol ^ hash<std::string>()(entry.host) ^ entry.port; 33 return entry.protocol ^ std::hash<std::string>()(entry.host) ^ entry.port;
36 } 34 }
37 }; 35 };
38 36
39 } // namespace BASE_HASH_NAMESPACE
40
41 namespace net {
42
43 // The implementation for setting/retrieving the HTTP server properties. 37 // The implementation for setting/retrieving the HTTP server properties.
44 class NET_EXPORT HttpServerPropertiesImpl 38 class NET_EXPORT HttpServerPropertiesImpl
45 : public HttpServerProperties, 39 : public HttpServerProperties,
46 NON_EXPORTED_BASE(public base::NonThreadSafe) { 40 NON_EXPORTED_BASE(public base::NonThreadSafe) {
47 public: 41 public:
48 HttpServerPropertiesImpl(); 42 HttpServerPropertiesImpl();
49 ~HttpServerPropertiesImpl() override; 43 ~HttpServerPropertiesImpl() override;
50 44
51 // Initializes |spdy_servers_map_| with the servers (host/port) from 45 // Initializes |spdy_servers_map_| with the servers (host/port) from
52 // |spdy_servers| that either support SPDY or not. 46 // |spdy_servers| that either support SPDY or not.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // |spdy_servers_map_| has flattened representation of servers (host, port) 138 // |spdy_servers_map_| has flattened representation of servers (host, port)
145 // that either support or not support SPDY protocol. 139 // that either support or not support SPDY protocol.
146 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; 140 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap;
147 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; 141 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap;
148 typedef std::vector<std::string> CanonicalSufficList; 142 typedef std::vector<std::string> CanonicalSufficList;
149 typedef std::set<HostPortPair> Http11ServerHostPortSet; 143 typedef std::set<HostPortPair> Http11ServerHostPortSet;
150 144
151 // Linked hash map from AlternativeService to expiration time. This container 145 // Linked hash map from AlternativeService to expiration time. This container
152 // is a queue with O(1) enqueue and dequeue, and a hash_map with O(1) lookup 146 // is a queue with O(1) enqueue and dequeue, and a hash_map with O(1) lookup
153 // at the same time. 147 // at the same time.
154 typedef linked_hash_map<AlternativeService, base::TimeTicks> 148 typedef linked_hash_map<AlternativeService,
149 base::TimeTicks,
150 AlternativeServiceHash>
155 BrokenAlternativeServices; 151 BrokenAlternativeServices;
156 // Map to the number of times each alternative service has been marked broken. 152 // Map to the number of times each alternative service has been marked broken.
157 typedef std::map<AlternativeService, int> RecentlyBrokenAlternativeServices; 153 typedef std::map<AlternativeService, int> RecentlyBrokenAlternativeServices;
158 154
159 // Return the iterator for |server|, or for its canonical host, or end. 155 // Return the iterator for |server|, or for its canonical host, or end.
160 AlternativeServiceMap::const_iterator GetAlternateProtocolIterator( 156 AlternativeServiceMap::const_iterator GetAlternateProtocolIterator(
161 const HostPortPair& server); 157 const HostPortPair& server);
162 158
163 // Return the canonical host for |server|, or end if none exists. 159 // Return the canonical host for |server|, or end if none exists.
164 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; 160 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const;
(...skipping 28 matching lines...) Expand all
193 size_t max_server_configs_stored_in_properties_; 189 size_t max_server_configs_stored_in_properties_;
194 190
195 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; 191 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_;
196 192
197 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); 193 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl);
198 }; 194 };
199 195
200 } // namespace net 196 } // namespace net
201 197
202 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 198 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
OLDNEW
« no previous file with comments | « net/dns/dns_hosts.h ('k') | net/quic/quic_blocked_writer_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698