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/http/http_server_properties_impl.h

Issue 665083009: ABANDONED Handle multiple AlternateProtocols for each HostPortPair. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Custom entries for broken_alternate_protocol_list_ and map_. 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 | « net/http/http_server_properties.cc ('k') | 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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Returns true if |server| has required HTTP/1.1 via HTTP/2 error code. 86 // Returns true if |server| has required HTTP/1.1 via HTTP/2 error code.
87 bool RequiresHTTP11(const HostPortPair& server) override; 87 bool RequiresHTTP11(const HostPortPair& server) override;
88 88
89 // Require HTTP/1.1 on subsequent connections. Not persisted. 89 // Require HTTP/1.1 on subsequent connections. Not persisted.
90 void SetHTTP11Required(const HostPortPair& server) override; 90 void SetHTTP11Required(const HostPortPair& server) override;
91 91
92 // Modify SSLConfig to force HTTP/1.1 if necessary. 92 // Modify SSLConfig to force HTTP/1.1 if necessary.
93 void MaybeForceHTTP11(const HostPortPair& server, 93 void MaybeForceHTTP11(const HostPortPair& server,
94 SSLConfig* ssl_config) override; 94 SSLConfig* ssl_config) override;
95 95
96 // Returns true if |server| has an Alternate-Protocol header. 96 // Returns true iff |server| has a non-broken AlternateProtocol with
97 // probability exceeding threshold, or if AlternateProtocol is forced.
98 // TODO(bnc): Rename to HasAlternativeService.
97 bool HasAlternateProtocol(const HostPortPair& server) override; 99 bool HasAlternateProtocol(const HostPortPair& server) override;
98 100
99 // Returns the Alternate-Protocol and port for |server|. 101 // Returns the first non-broken AlternateProtocol with probability exceeding
100 // HasAlternateProtocol(server) must be true. 102 // threshold for |server|, or forced AlternateProtocol, or one with
103 // UNINITIALIZED_ALTERNATE_PROTOCOL.
101 AlternateProtocolInfo GetAlternateProtocol( 104 AlternateProtocolInfo GetAlternateProtocol(
102 const HostPortPair& server) override; 105 const HostPortPair& server) override;
103 106
104 // Sets the Alternate-Protocol for |server|. 107 // Adds an Alternate-Protocol for |server|.
105 void SetAlternateProtocol(const HostPortPair& server, 108 void AddAlternateProtocol(const HostPortPair& server,
106 uint16 alternate_port, 109 uint16 alternate_port,
107 AlternateProtocol alternate_protocol, 110 AlternateProtocol alternate_protocol,
108 double probability) override; 111 double probability) override;
109 112
110 // Sets the Alternate-Protocol for |server| to be BROKEN. 113 // Sets a given Alternate-Protocol for |server| to be broken.
111 void SetBrokenAlternateProtocol(const HostPortPair& server) override; 114 void SetBrokenAlternateProtocol(
115 const HostPortPair& server,
116 const AlternateProtocolInfo& broken_alternate_protocol) override;
112 117
113 // Returns true if Alternate-Protocol for |server| was recently BROKEN. 118 // Returns true if given Alternate-Protocol for |server| was recently broken.
114 bool WasAlternateProtocolRecentlyBroken(const HostPortPair& server) override; 119 bool WasAlternateProtocolRecentlyBroken(
120 const HostPortPair& server,
121 const AlternateProtocolInfo& alternate_protocol) override;
115 122
116 // Confirms that Alternate-Protocol for |server| is working. 123 // Confirms that given Alternate-Protocol for |server| is working.
117 void ConfirmAlternateProtocol(const HostPortPair& server) override; 124 void ConfirmAlternateProtocol(
125 const HostPortPair& server,
126 const AlternateProtocolInfo& alternate_protocol) override;
118 127
119 // Clears the Alternate-Protocol for |server|. 128 // Clears all Alternate-Protocols for |server|.
120 void ClearAlternateProtocol(const HostPortPair& server) override; 129 void ClearAlternateProtocol(const HostPortPair& server) override;
121 130
131 // Clears all Alternate-Protocols that are not broken for |server|.
132 void ClearNonBrokenAlternateProtocols(const HostPortPair& server) override;
133
134 // Removes an Alternate-Protocol for |server|.
135 void RemoveAlternateProtocol(
136 const HostPortPair& server,
137 const AlternateProtocolInfo& alternate_protocol) override;
138
122 // Returns all Alternate-Protocol mappings. 139 // Returns all Alternate-Protocol mappings.
123 const AlternateProtocolMap& alternate_protocol_map() const override; 140 const AlternateProtocolMap& alternate_protocol_map() const override;
124 141
125 void SetAlternateProtocolProbabilityThreshold(double threshold) override; 142 void SetAlternateProtocolProbabilityThreshold(double threshold) override;
126 143
127 // Gets a reference to the SettingsMap stored for a host. 144 // Gets a reference to the SettingsMap stored for a host.
128 // If no settings are stored, returns an empty SettingsMap. 145 // If no settings are stored, returns an empty SettingsMap.
129 const SettingsMap& GetSpdySettings( 146 const SettingsMap& GetSpdySettings(
130 const HostPortPair& host_port_pair) override; 147 const HostPortPair& host_port_pair) override;
131 148
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 181
165 const ServerNetworkStatsMap& server_network_stats_map() const override; 182 const ServerNetworkStatsMap& server_network_stats_map() const override;
166 183
167 private: 184 private:
168 // |spdy_servers_map_| has flattened representation of servers (host, port) 185 // |spdy_servers_map_| has flattened representation of servers (host, port)
169 // that either support or not support SPDY protocol. 186 // that either support or not support SPDY protocol.
170 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; 187 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap;
171 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; 188 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap;
172 typedef std::vector<std::string> CanonicalSufficList; 189 typedef std::vector<std::string> CanonicalSufficList;
173 typedef std::set<HostPortPair> Http11ServerHostPortSet; 190 typedef std::set<HostPortPair> Http11ServerHostPortSet;
174 // List of broken host:ports and the times when they can be expired. 191 // Server, port, and AlternateProtocol: an entity that can be broken. (Once
192 // we use AlternativeService, the same AltSvc can be broken for one server but
193 // not for another depending on what certificate it can offer.)
175 struct BrokenAlternateProtocolEntry { 194 struct BrokenAlternateProtocolEntry {
195 BrokenAlternateProtocolEntry(const BrokenAlternateProtocolEntry&) = default;
196 BrokenAlternateProtocolEntry(const HostPortPair& server,
197 uint16 port,
198 AlternateProtocol protocol)
199 : server(server), port(port), protocol(protocol) {}
200
201 bool operator<(const BrokenAlternateProtocolEntry& other) const {
202 if (!server.Equals(other.server))
203 return server < other.server;
204 if (port != other.port)
205 return port < other.port;
206 return protocol < other.protocol;
207 }
208
176 HostPortPair server; 209 HostPortPair server;
210 uint16 port;
211 AlternateProtocol protocol;
212 };
213 // List of BrokenAlternateProtocolEntries with when they can be expired.
214 struct BrokenAlternateProtocolEntryWithTime {
215 BrokenAlternateProtocolEntryWithTime(
216 const BrokenAlternateProtocolEntry& broken_alternate_protocol_entry,
217 base::TimeTicks when)
218 : broken_alternate_protocol_entry(broken_alternate_protocol_entry),
219 when(when) {}
220
221 BrokenAlternateProtocolEntry broken_alternate_protocol_entry;
177 base::TimeTicks when; 222 base::TimeTicks when;
178 }; 223 };
179 typedef std::list<BrokenAlternateProtocolEntry> 224 typedef std::list<BrokenAlternateProtocolEntryWithTime>
180 BrokenAlternateProtocolList; 225 BrokenAlternateProtocolList;
181 // Map from host:port to the number of times alternate protocol has 226 // Map from host:port to the number of times alternate protocol has
182 // been marked broken. 227 // been marked broken.
183 typedef std::map<HostPortPair, int> BrokenAlternateProtocolMap; 228 typedef std::map<BrokenAlternateProtocolEntry, int>
229 BrokenAlternateProtocolMap;
184 230
185 // Return the iterator for |server|, or for its canonical host, or end. 231 // Return the iterator for |server|, or for its canonical host, or end.
186 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator( 232 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator(
187 const HostPortPair& server); 233 const HostPortPair& server);
188 234
189 // Return the canonical host for |server|, or end if none exists. 235 // Return the canonical host for |server|, or end if none exists.
190 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; 236 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const;
191 237
192 void RemoveCanonicalHost(const HostPortPair& server); 238 void RemoveCanonicalHost(const HostPortPair& server);
193 void ExpireBrokenAlternateProtocolMappings(); 239 void ExpireBrokenAlternateProtocolMappings();
(...skipping 20 matching lines...) Expand all
214 double alternate_protocol_probability_threshold_; 260 double alternate_protocol_probability_threshold_;
215 261
216 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; 262 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_;
217 263
218 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); 264 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl);
219 }; 265 };
220 266
221 } // namespace net 267 } // namespace net
222 268
223 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 269 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
OLDNEW
« no previous file with comments | « net/http/http_server_properties.cc ('k') | net/http/http_server_properties_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698