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

Side by Side Diff: net/http/http_server_properties_impl.h

Issue 888943003: Add AlternateProtocol to broken_altproto_list_ and map_. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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 | « no previous file | net/http/http_server_properties_impl.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) 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 <deque>
8 #include <map> 9 #include <map>
9 #include <set> 10 #include <set>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/threading/non_thread_safe.h" 17 #include "base/threading/non_thread_safe.h"
17 #include "base/values.h" 18 #include "base/values.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const HostPortPair& host_port_pair) override; 113 const HostPortPair& host_port_pair) override;
113 const ServerNetworkStatsMap& server_network_stats_map() const override; 114 const ServerNetworkStatsMap& server_network_stats_map() const override;
114 115
115 private: 116 private:
116 // |spdy_servers_map_| has flattened representation of servers (host, port) 117 // |spdy_servers_map_| has flattened representation of servers (host, port)
117 // that either support or not support SPDY protocol. 118 // that either support or not support SPDY protocol.
118 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; 119 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap;
119 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; 120 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap;
120 typedef std::vector<std::string> CanonicalSufficList; 121 typedef std::vector<std::string> CanonicalSufficList;
121 typedef std::set<HostPortPair> Http11ServerHostPortSet; 122 typedef std::set<HostPortPair> Http11ServerHostPortSet;
122 // List of broken host:ports and the times when they can be expired. 123
124 // Server, port, and AlternateProtocol: an entity that can be broken. (Once
125 // we use AlternativeService, the same AltSvc can be broken for one server but
126 // not for another depending on what certificate it can offer.)
123 struct BrokenAlternateProtocolEntry { 127 struct BrokenAlternateProtocolEntry {
128 BrokenAlternateProtocolEntry(const BrokenAlternateProtocolEntry&) = default;
129 BrokenAlternateProtocolEntry(const HostPortPair& server,
130 uint16 port,
131 AlternateProtocol protocol)
132 : server(server), port(port), protocol(protocol) {}
133
134 bool operator<(const BrokenAlternateProtocolEntry& other) const {
135 if (!server.Equals(other.server))
136 return server < other.server;
137 if (port != other.port)
138 return port < other.port;
139 return protocol < other.protocol;
140 }
141
124 HostPortPair server; 142 HostPortPair server;
143 uint16 port;
144 AlternateProtocol protocol;
145 };
146 // BrokenAlternateProtocolEntry with expiration time.
147 struct BrokenAlternateProtocolEntryWithTime {
148 BrokenAlternateProtocolEntryWithTime(
149 const BrokenAlternateProtocolEntry& broken_alternate_protocol_entry,
150 base::TimeTicks when)
151 : broken_alternate_protocol_entry(broken_alternate_protocol_entry),
152 when(when) {}
153
154 BrokenAlternateProtocolEntry broken_alternate_protocol_entry;
125 base::TimeTicks when; 155 base::TimeTicks when;
126 }; 156 };
127 typedef std::list<BrokenAlternateProtocolEntry> 157 // Deque of BrokenAlternateProtocolEntryWithTime items, ordered by expiration
158 // time.
159 typedef std::deque<BrokenAlternateProtocolEntryWithTime>
128 BrokenAlternateProtocolList; 160 BrokenAlternateProtocolList;
129 // Map from host:port to the number of times alternate protocol has 161 // Map from (server, alternate protocol and port) to the number of
130 // been marked broken. 162 // times that alternate protocol has been marked broken for that server.
131 typedef std::map<HostPortPair, int> BrokenAlternateProtocolMap; 163 typedef std::map<BrokenAlternateProtocolEntry, int>
164 BrokenAlternateProtocolMap;
132 165
133 // Return the iterator for |server|, or for its canonical host, or end. 166 // Return the iterator for |server|, or for its canonical host, or end.
134 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator( 167 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator(
135 const HostPortPair& server); 168 const HostPortPair& server);
136 169
137 // Return the canonical host for |server|, or end if none exists. 170 // Return the canonical host for |server|, or end if none exists.
138 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; 171 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const;
139 172
140 void RemoveCanonicalHost(const HostPortPair& server); 173 void RemoveCanonicalHost(const HostPortPair& server);
141 void ExpireBrokenAlternateProtocolMappings(); 174 void ExpireBrokenAlternateProtocolMappings();
(...skipping 20 matching lines...) Expand all
162 double alternate_protocol_probability_threshold_; 195 double alternate_protocol_probability_threshold_;
163 196
164 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; 197 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_;
165 198
166 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); 199 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl);
167 }; 200 };
168 201
169 } // namespace net 202 } // namespace net
170 203
171 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 204 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_server_properties_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698