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

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

Issue 665083009: ABANDONED Handle multiple AlternateProtocols for each HostPortPair. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: 18. Created 5 years, 9 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_network_transaction_unittest.cc ('k') | net/http/http_server_properties.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_H_ 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_H_
6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_H_ 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector>
11
10 #include "base/basictypes.h" 12 #include "base/basictypes.h"
11 #include "base/containers/mru_cache.h" 13 #include "base/containers/mru_cache.h"
12 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h" 15 #include "base/time/time.h"
14 #include "net/base/host_port_pair.h" 16 #include "net/base/host_port_pair.h"
15 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
16 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
17 #include "net/quic/quic_bandwidth.h" 19 #include "net/quic/quic_bandwidth.h"
18 #include "net/socket/next_proto.h" 20 #include "net/socket/next_proto.h"
19 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. 21 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION and 75 // ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION and
74 // ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION (inclusive). 76 // ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION (inclusive).
75 NET_EXPORT bool IsAlternateProtocolValid(AlternateProtocol protocol); 77 NET_EXPORT bool IsAlternateProtocolValid(AlternateProtocol protocol);
76 78
77 enum AlternateProtocolSize { 79 enum AlternateProtocolSize {
78 NUM_VALID_ALTERNATE_PROTOCOLS = 80 NUM_VALID_ALTERNATE_PROTOCOLS =
79 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION - 81 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION -
80 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, 82 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1,
81 }; 83 };
82 84
83 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol);
84 NET_EXPORT AlternateProtocol AlternateProtocolFromString(
85 const std::string& str);
86 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto(
87 NextProto next_proto);
88
89 struct NET_EXPORT AlternateProtocolInfo { 85 struct NET_EXPORT AlternateProtocolInfo {
90 AlternateProtocolInfo() 86 AlternateProtocolInfo()
91 : port(0), 87 : port(0),
92 protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), 88 protocol(UNINITIALIZED_ALTERNATE_PROTOCOL),
93 probability(0), 89 probability(0.0),
94 is_broken(false) {} 90 is_broken(false) {}
95 91
96 AlternateProtocolInfo(uint16 port, 92 AlternateProtocolInfo(uint16 port,
97 AlternateProtocol protocol, 93 AlternateProtocol protocol,
98 double probability) 94 double probability)
99 : port(port), 95 : port(port),
100 protocol(protocol), 96 protocol(protocol),
101 probability(probability), 97 probability(probability),
102 is_broken(false) {} 98 is_broken(false) {}
103 99
104 AlternateProtocolInfo(uint16 port, 100 AlternateProtocolInfo(uint16 port,
105 AlternateProtocol protocol, 101 AlternateProtocol protocol,
106 double probability, 102 double probability,
107 bool is_broken) 103 bool is_broken)
108 : port(port), 104 : port(port),
109 protocol(protocol), 105 protocol(protocol),
110 probability(probability), 106 probability(probability),
111 is_broken(is_broken) {} 107 is_broken(is_broken) {}
112 108
113 bool Equals(const AlternateProtocolInfo& other) const { 109 bool Equals(const AlternateProtocolInfo& other) const {
114 return port == other.port && 110 return port == other.port && protocol == other.protocol &&
115 protocol == other.protocol && 111 probability == other.probability;
116 probability == other.probability; 112 }
113
114 bool EqualsModuloProbability(const AlternateProtocolInfo& other) const {
115 return port == other.port && protocol == other.protocol;
117 } 116 }
118 117
119 std::string ToString() const; 118 std::string ToString() const;
120 119
121 uint16 port; 120 uint16 port;
122 AlternateProtocol protocol; 121 AlternateProtocol protocol;
123 double probability; 122 double probability;
124 bool is_broken; 123 bool is_broken;
125 }; 124 };
126 125
(...skipping 11 matching lines...) Expand all
138 std::string address; 137 std::string address;
139 }; 138 };
140 139
141 struct NET_EXPORT ServerNetworkStats { 140 struct NET_EXPORT ServerNetworkStats {
142 ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {} 141 ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {}
143 142
144 base::TimeDelta srtt; 143 base::TimeDelta srtt;
145 QuicBandwidth bandwidth_estimate; 144 QuicBandwidth bandwidth_estimate;
146 }; 145 };
147 146
148 typedef base::MRUCache< 147 typedef std::vector<AlternateProtocolInfo> AlternateProtocols;
149 HostPortPair, AlternateProtocolInfo> AlternateProtocolMap; 148 typedef base::MRUCache<HostPortPair, AlternateProtocols> AlternateProtocolMap;
150 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; 149 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap;
151 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; 150 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap;
152 151
153 extern const char kAlternateProtocolHeader[]; 152 extern const char kAlternateProtocolHeader[];
154 153
154 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol);
155 NET_EXPORT std::string AlternateProtocolsToString(
156 const AlternateProtocols& services);
157 NET_EXPORT AlternateProtocol
158 AlternateProtocolFromString(const std::string& str);
159 NET_EXPORT_PRIVATE AlternateProtocol
160 AlternateProtocolFromNextProto(NextProto next_proto);
161
155 // The interface for setting/retrieving the HTTP server properties. 162 // The interface for setting/retrieving the HTTP server properties.
156 // Currently, this class manages servers': 163 // Currently, this class manages servers':
157 // * SPDY support (based on NPN results) 164 // * SPDY support (based on NPN results)
158 // * Alternate-Protocol support 165 // * Alternate-Protocol support
159 // * Spdy Settings (like CWND ID field) 166 // * Spdy Settings (like CWND ID field)
160 class NET_EXPORT HttpServerProperties { 167 class NET_EXPORT HttpServerProperties {
161 public: 168 public:
162 HttpServerProperties() {} 169 HttpServerProperties() {}
163 virtual ~HttpServerProperties() {} 170 virtual ~HttpServerProperties() {}
164 171
(...skipping 18 matching lines...) Expand all
183 // Require HTTP/1.1 on subsequent connections. Not persisted. 190 // Require HTTP/1.1 on subsequent connections. Not persisted.
184 virtual void SetHTTP11Required(const HostPortPair& server) = 0; 191 virtual void SetHTTP11Required(const HostPortPair& server) = 0;
185 192
186 // Modify SSLConfig to force HTTP/1.1. 193 // Modify SSLConfig to force HTTP/1.1.
187 static void ForceHTTP11(SSLConfig* ssl_config); 194 static void ForceHTTP11(SSLConfig* ssl_config);
188 195
189 // Modify SSLConfig to force HTTP/1.1 if necessary. 196 // Modify SSLConfig to force HTTP/1.1 if necessary.
190 virtual void MaybeForceHTTP11(const HostPortPair& server, 197 virtual void MaybeForceHTTP11(const HostPortPair& server,
191 SSLConfig* ssl_config) = 0; 198 SSLConfig* ssl_config) = 0;
192 199
193 // Returns the AlternateProtocol for |server| if it has probability equal to 200 // Returns all alternate protocols for |server| with probability greater than
194 // or exceeding threshold, or else the forced AlternateProtocol if there is 201 // or equal to the threshold, even broken ones.
195 // one, or else one with UNINITIALIZED_ALTERNATE_PROTOCOL. 202 virtual AlternateProtocols GetAlternateProtocols(
196 virtual AlternateProtocolInfo GetAlternateProtocol(
197 const HostPortPair& server) = 0; 203 const HostPortPair& server) = 0;
198 204
199 // Sets the Alternate-Protocol for |server|. 205 // Adds an alternate protocol for |server|.
200 virtual void SetAlternateProtocol(const HostPortPair& server, 206 virtual void AddAlternateProtocol(const HostPortPair& server,
201 uint16 alternate_port, 207 uint16 alternate_port,
202 AlternateProtocol alternate_protocol, 208 AlternateProtocol alternate_protocol,
203 double probability) = 0; 209 double probability) = 0;
204 210
205 // Sets the Alternate-Protocol for |server| to be BROKEN. 211 // Sets a given alternate protocol for |server| to be broken.
206 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; 212 virtual void SetBrokenAlternateProtocol(
213 const HostPortPair& server,
214 const AlternateProtocolInfo& broken_alternate_protocol) = 0;
207 215
208 // Returns true if Alternate-Protocol for |server| was recently BROKEN. 216 // Returns true if given alternate protocol for |server| was recently broken.
209 virtual bool WasAlternateProtocolRecentlyBroken( 217 virtual bool WasAlternateProtocolRecentlyBroken(
210 const HostPortPair& server) = 0; 218 const HostPortPair& server,
219 const AlternateProtocolInfo& alternate_protocol) const = 0;
211 220
212 // Confirms that Alternate-Protocol for |server| is working. 221 // Removes given (alternate protocol, server) pair from recently broken list.
213 virtual void ConfirmAlternateProtocol(const HostPortPair& server) = 0; 222 virtual void ConfirmAlternateProtocol(
223 const HostPortPair& server,
224 const AlternateProtocolInfo& alternate_protocol) = 0;
214 225
215 // Clears the Alternate-Protocol for |server|. 226 // Clears all alternate protocols for |server|.
216 virtual void ClearAlternateProtocol(const HostPortPair& server) = 0; 227 virtual void ClearAlternateProtocols(const HostPortPair& server) = 0;
228
229 // Clears all alternate protocols that are not broken for |server|.
230 virtual void ClearNonBrokenAlternateProtocols(const HostPortPair& server) = 0;
231
232 // Removes an alternate protocol for |server|.
233 virtual void RemoveAlternateProtocol(
234 const HostPortPair& server,
235 const AlternateProtocolInfo& alternate_protocol) = 0;
217 236
218 // Returns all Alternate-Protocol mappings. 237 // Returns all Alternate-Protocol mappings.
219 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; 238 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0;
220 239
221 // Sets the threshold to be used when evaluating Alternate-Protocol 240 // Sets the threshold to be used when evaluating Alternate-Protocol
222 // advertisments. Only advertisements with a with a probability 241 // advertisments. Only advertisements with a with a probability
223 // greater than |threshold| will be honored. |threshold| must be 242 // greater than |threshold| will be honored. |threshold| must be
224 // between 0 and 1 inclusive. Hence, a threshold of 0 implies that 243 // between 0 and 1 inclusive. Hence, a threshold of 0 implies that
225 // all advertisements will be honored. 244 // all advertisements will be honored.
226 virtual void SetAlternateProtocolProbabilityThreshold( 245 virtual void SetAlternateProtocolProbabilityThreshold(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 279
261 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; 280 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0;
262 281
263 private: 282 private:
264 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); 283 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties);
265 }; 284 };
266 285
267 } // namespace net 286 } // namespace net
268 287
269 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ 288 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_server_properties.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698