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

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: Rebase. Created 5 years, 11 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
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/quic/quic_bandwidth.h" 18 #include "net/quic/quic_bandwidth.h"
17 #include "net/socket/next_proto.h" 19 #include "net/socket/next_proto.h"
18 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. 20 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this.
19 #include "net/spdy/spdy_protocol.h" 21 #include "net/spdy/spdy_protocol.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION and 74 // ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION and
73 // ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION (inclusive). 75 // ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION (inclusive).
74 NET_EXPORT bool IsAlternateProtocolValid(AlternateProtocol protocol); 76 NET_EXPORT bool IsAlternateProtocolValid(AlternateProtocol protocol);
75 77
76 enum AlternateProtocolSize { 78 enum AlternateProtocolSize {
77 NUM_VALID_ALTERNATE_PROTOCOLS = 79 NUM_VALID_ALTERNATE_PROTOCOLS =
78 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION - 80 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION -
79 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, 81 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1,
80 }; 82 };
81 83
82 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); 84 // TODO(bnc): Rename to AlternateServiceInfo.
83 NET_EXPORT AlternateProtocol AlternateProtocolFromString( 85 struct NET_EXPORT AlternateProtocolInfo {
84 const std::string& str); 86 AlternateProtocolInfo()
85 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( 87 : port(0), protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), probability(0) {}
86 NextProto next_proto);
87 88
88 struct NET_EXPORT AlternateProtocolInfo {
89 AlternateProtocolInfo(uint16 port, 89 AlternateProtocolInfo(uint16 port,
90 AlternateProtocol protocol, 90 AlternateProtocol protocol,
91 double probability) 91 double probability)
92 : port(port), 92 : port(port),
93 protocol(protocol), 93 protocol(protocol),
94 probability(probability), 94 probability(probability),
95 is_broken(false) {} 95 is_broken(false) {}
96 96
97 AlternateProtocolInfo(uint16 port, 97 AlternateProtocolInfo(uint16 port,
98 AlternateProtocol protocol, 98 AlternateProtocol protocol,
99 double probability, 99 double probability,
100 bool is_broken) 100 bool is_broken)
101 : port(port), 101 : port(port),
102 protocol(protocol), 102 protocol(protocol),
103 probability(probability), 103 probability(probability),
104 is_broken(is_broken) {} 104 is_broken(is_broken) {}
105 105
106 bool Equals(const AlternateProtocolInfo& other) const { 106 bool Equals(const AlternateProtocolInfo& other) const {
107 return port == other.port && 107 return port == other.port &&
108 protocol == other.protocol && 108 protocol == other.protocol &&
109 probability == other.probability; 109 probability == other.probability;
110 } 110 }
111 111
112 bool EqualsModuloProbabilityAndProtocol(
113 const AlternateProtocolInfo& other) const {
114 return port == other.port;
115 }
116
112 std::string ToString() const; 117 std::string ToString() const;
113 118
114 uint16 port; 119 uint16 port;
115 AlternateProtocol protocol; 120 AlternateProtocol protocol;
116 double probability; 121 double probability;
117 bool is_broken; 122 bool is_broken;
118 }; 123 };
119 124
120 struct NET_EXPORT SupportsQuic { 125 struct NET_EXPORT SupportsQuic {
121 SupportsQuic() : used_quic(false) {} 126 SupportsQuic() : used_quic(false) {}
122 SupportsQuic(bool used_quic, const std::string& address) 127 SupportsQuic(bool used_quic, const std::string& address)
123 : used_quic(used_quic), 128 : used_quic(used_quic),
124 address(address) {} 129 address(address) {}
125 130
126 bool Equals(const SupportsQuic& other) const { 131 bool Equals(const SupportsQuic& other) const {
127 return used_quic == other.used_quic && address == other.address; 132 return used_quic == other.used_quic && address == other.address;
128 } 133 }
129 134
130 bool used_quic; 135 bool used_quic;
131 std::string address; 136 std::string address;
132 }; 137 };
133 138
134 struct NET_EXPORT ServerNetworkStats { 139 struct NET_EXPORT ServerNetworkStats {
135 ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {} 140 ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {}
136 141
137 base::TimeDelta srtt; 142 base::TimeDelta srtt;
138 QuicBandwidth bandwidth_estimate; 143 QuicBandwidth bandwidth_estimate;
139 }; 144 };
140 145
141 typedef base::MRUCache< 146 // TODO(bnc): Rename to AlternateServices.
142 HostPortPair, AlternateProtocolInfo> AlternateProtocolMap; 147 typedef std::vector<AlternateProtocolInfo> AlternateProtocols;
148 // TODO(bnc): Rename to AlternateServicesMap.
149 typedef base::MRUCache<HostPortPair, AlternateProtocols> AlternateProtocolMap;
143 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; 150 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap;
144 typedef std::map<HostPortPair, SupportsQuic> SupportsQuicMap; 151 typedef std::map<HostPortPair, SupportsQuic> SupportsQuicMap;
145 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; 152 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap;
146 153
147 extern const char kAlternateProtocolHeader[]; 154 extern const char kAlternateProtocolHeader[];
148 155
156 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol);
157 // TODO(bnc): Rename to AlternateServicesToString.
158 NET_EXPORT std::string AlternateProtocolsToString(
159 const AlternateProtocols& services);
160 NET_EXPORT AlternateProtocol
161 AlternateProtocolFromString(const std::string& str);
162 NET_EXPORT_PRIVATE AlternateProtocol
163 AlternateProtocolFromNextProto(NextProto next_proto);
164
149 // The interface for setting/retrieving the HTTP server properties. 165 // The interface for setting/retrieving the HTTP server properties.
150 // Currently, this class manages servers': 166 // Currently, this class manages servers':
151 // * SPDY support (based on NPN results) 167 // * SPDY support (based on NPN results)
152 // * Alternate-Protocol support 168 // * Alternate-Protocol support
153 // * Spdy Settings (like CWND ID field) 169 // * Spdy Settings (like CWND ID field)
154 class NET_EXPORT HttpServerProperties { 170 class NET_EXPORT HttpServerProperties {
155 public: 171 public:
156 HttpServerProperties() {} 172 HttpServerProperties() {}
157 virtual ~HttpServerProperties() {} 173 virtual ~HttpServerProperties() {}
158 174
(...skipping 18 matching lines...) Expand all
177 virtual void SetHTTP11Required(const HostPortPair& server) = 0; 193 virtual void SetHTTP11Required(const HostPortPair& server) = 0;
178 194
179 // Modify SSLConfig to force HTTP/1.1. 195 // Modify SSLConfig to force HTTP/1.1.
180 static void ForceHTTP11(SSLConfig* ssl_config); 196 static void ForceHTTP11(SSLConfig* ssl_config);
181 197
182 // Modify SSLConfig to force HTTP/1.1 if necessary. 198 // Modify SSLConfig to force HTTP/1.1 if necessary.
183 virtual void MaybeForceHTTP11(const HostPortPair& server, 199 virtual void MaybeForceHTTP11(const HostPortPair& server,
184 SSLConfig* ssl_config) = 0; 200 SSLConfig* ssl_config) = 0;
185 201
186 // Returns true if |server| has an Alternate-Protocol header. 202 // Returns true if |server| has an Alternate-Protocol header.
203 // TODO(bnc): Rename to HasAlternateService.
187 virtual bool HasAlternateProtocol(const HostPortPair& server) = 0; 204 virtual bool HasAlternateProtocol(const HostPortPair& server) = 0;
188 205
189 // Returns the Alternate-Protocol and port for |server|. 206 // Returns the Alternate-Protocols for |server|.
190 // HasAlternateProtocol(server) must be true. 207 // HasAlternateProtocol(server) must be true.
191 virtual AlternateProtocolInfo GetAlternateProtocol( 208 virtual const AlternateProtocols& GetAlternateProtocols(
192 const HostPortPair& server) = 0; 209 const HostPortPair& server) = 0;
193 210
194 // Sets the Alternate-Protocol for |server|. 211 // Adds an Alternate-Protocol for |server|.
195 virtual void SetAlternateProtocol(const HostPortPair& server, 212 // TODO(bnc): Rename to AddAlternateService.
213 virtual void AddAlternateProtocol(const HostPortPair& server,
196 uint16 alternate_port, 214 uint16 alternate_port,
197 AlternateProtocol alternate_protocol, 215 AlternateProtocol alternate_protocol,
198 double probability) = 0; 216 double probability) = 0;
199 217
200 // Sets the Alternate-Protocol for |server| to be BROKEN. 218 // Sets a given Alternate-Protocol for |server| to be BROKEN.
201 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; 219 virtual void SetBrokenAlternateProtocol(
220 const HostPortPair& server,
221 const AlternateProtocolInfo& broken_alternate_protocol) = 0;
202 222
203 // Returns true if Alternate-Protocol for |server| was recently BROKEN. 223 // Returns true if given Alternate-Protocol for |server| was recently BROKEN.
204 virtual bool WasAlternateProtocolRecentlyBroken( 224 virtual bool WasAlternateProtocolRecentlyBroken(
205 const HostPortPair& server) = 0; 225 const HostPortPair& server,
226 const AlternateProtocolInfo& alternate_protocol) = 0;
206 227
207 // Confirms that Alternate-Protocol for |server| is working. 228 // Confirms that given Alternate-Protocol for |server| is working.
208 virtual void ConfirmAlternateProtocol(const HostPortPair& server) = 0; 229 virtual void ConfirmAlternateProtocol(
230 const HostPortPair& server,
231 const AlternateProtocolInfo& alternate_protocol) = 0;
209 232
210 // Clears the Alternate-Protocol for |server|. 233 // Clears all Alternate-Protocols for |server|.
234 // TODO(bnc): Rename to ClearAlternateServices.
211 virtual void ClearAlternateProtocol(const HostPortPair& server) = 0; 235 virtual void ClearAlternateProtocol(const HostPortPair& server) = 0;
212 236
237 // Clears all Alternate-Protocols that are not broken for |server|.
238 // TODO(bnc): Rename to ClearNonBrokenAlternateServices.
239 virtual void ClearNonBrokenAlternateProtocols(const HostPortPair& server) = 0;
240
241 // Removes an Alternate-Protocol for |server|.
242 // TODO(bnc): Rename to RemoveAlternateService.
243 virtual void RemoveAlternateProtocol(
244 const HostPortPair& server,
245 const AlternateProtocolInfo& alternate_protocol) = 0;
246
213 // Returns all Alternate-Protocol mappings. 247 // Returns all Alternate-Protocol mappings.
248 // TODO(bnc): Rename to alternate_services_map.
214 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; 249 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0;
215 250
216 // Sets the threshold to be used when evaluating Alternate-Protocol 251 // Sets the threshold to be used when evaluating Alternate-Protocol
217 // advertisments. Only advertisements with a with a probability 252 // advertisments. Only advertisements with a with a probability
218 // greater than |threshold| will be honored. |threshold| must be 253 // greater than |threshold| will be honored. |threshold| must be
219 // between 0 and 1 inclusive. Hence, a threshold of 0 implies that 254 // between 0 and 1 inclusive. Hence, a threshold of 0 implies that
220 // all advertisements will be honored. 255 // all advertisements will be honored.
221 virtual void SetAlternateProtocolProbabilityThreshold( 256 virtual void SetAlternateProtocolProbabilityThreshold(
222 double threshold) = 0; 257 double threshold) = 0;
223 258
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 295
261 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; 296 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0;
262 297
263 private: 298 private:
264 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); 299 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties);
265 }; 300 };
266 301
267 } // namespace net 302 } // namespace net
268 303
269 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ 304 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698