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

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

Issue 339663010: Add a probability to Alternate-Protocol support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better plumbing Created 6 years, 5 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 | Annotate | Revision Log
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 "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION - 85 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION -
86 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, 86 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1,
87 }; 87 };
88 88
89 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); 89 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol);
90 NET_EXPORT AlternateProtocol AlternateProtocolFromString( 90 NET_EXPORT AlternateProtocol AlternateProtocolFromString(
91 const std::string& str); 91 const std::string& str);
92 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( 92 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto(
93 NextProto next_proto); 93 NextProto next_proto);
94 94
95 struct NET_EXPORT PortAlternateProtocolPair { 95 struct NET_EXPORT AlternateProtocolInfo {
96 bool Equals(const PortAlternateProtocolPair& other) const { 96 AlternateProtocolInfo(uint16 port,
97 return port == other.port && protocol == other.protocol; 97 AlternateProtocol protocol,
98 double probability)
ramant (doing other things) 2014/06/27 22:38:13 nit: lines 97-98 indentation could be wrong.
Ryan Hamilton 2014/06/30 19:02:34 Doh! Sorry for not catching this.
99 : port(port),
100 protocol(protocol),
101 probability(probability) {}
102
103 bool Equals(const AlternateProtocolInfo& other) const {
104 return port == other.port &&
105 protocol == other.protocol &&
106 probability == other.probability;
98 } 107 }
99 108
100 std::string ToString() const; 109 std::string ToString() const;
101 110
102 uint16 port; 111 uint16 port;
103 AlternateProtocol protocol; 112 AlternateProtocol protocol;
113 double probability;
104 }; 114 };
105 115
106 typedef base::MRUCache< 116 typedef base::MRUCache<
107 HostPortPair, PortAlternateProtocolPair> AlternateProtocolMap; 117 HostPortPair, AlternateProtocolInfo> AlternateProtocolMap;
108 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; 118 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap;
109 119
110 extern const char kAlternateProtocolHeader[]; 120 extern const char kAlternateProtocolHeader[];
111 121
112 // The interface for setting/retrieving the HTTP server properties. 122 // The interface for setting/retrieving the HTTP server properties.
113 // Currently, this class manages servers': 123 // Currently, this class manages servers':
114 // * SPDY support (based on NPN results) 124 // * SPDY support (based on NPN results)
115 // * Alternate-Protocol support 125 // * Alternate-Protocol support
116 // * Spdy Settings (like CWND ID field) 126 // * Spdy Settings (like CWND ID field)
117 class NET_EXPORT HttpServerProperties { 127 class NET_EXPORT HttpServerProperties {
(...skipping 18 matching lines...) Expand all
136 // Add |server| into the persistent store. Should only be called from IO 146 // Add |server| into the persistent store. Should only be called from IO
137 // thread. 147 // thread.
138 virtual void SetSupportsSpdy(const HostPortPair& server, 148 virtual void SetSupportsSpdy(const HostPortPair& server,
139 bool support_spdy) = 0; 149 bool support_spdy) = 0;
140 150
141 // Returns true if |server| has an Alternate-Protocol header. 151 // Returns true if |server| has an Alternate-Protocol header.
142 virtual bool HasAlternateProtocol(const HostPortPair& server) = 0; 152 virtual bool HasAlternateProtocol(const HostPortPair& server) = 0;
143 153
144 // Returns the Alternate-Protocol and port for |server|. 154 // Returns the Alternate-Protocol and port for |server|.
145 // HasAlternateProtocol(server) must be true. 155 // HasAlternateProtocol(server) must be true.
146 virtual PortAlternateProtocolPair GetAlternateProtocol( 156 virtual AlternateProtocolInfo GetAlternateProtocol(
147 const HostPortPair& server) = 0; 157 const HostPortPair& server) = 0;
148 158
149 // Sets the Alternate-Protocol for |server|. 159 // Sets the Alternate-Protocol for |server|.
150 virtual void SetAlternateProtocol(const HostPortPair& server, 160 virtual void SetAlternateProtocol(const HostPortPair& server,
151 uint16 alternate_port, 161 uint16 alternate_port,
152 AlternateProtocol alternate_protocol) = 0; 162 AlternateProtocol alternate_protocol,
163 double probability) = 0;
153 164
154 // Sets the Alternate-Protocol for |server| to be BROKEN. 165 // Sets the Alternate-Protocol for |server| to be BROKEN.
155 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; 166 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0;
156 167
157 // Returns true if Alternate-Protocol for |server| was recently BROKEN. 168 // Returns true if Alternate-Protocol for |server| was recently BROKEN.
158 virtual bool WasAlternateProtocolRecentlyBroken( 169 virtual bool WasAlternateProtocolRecentlyBroken(
159 const HostPortPair& server) = 0; 170 const HostPortPair& server) = 0;
160 171
161 // Confirms that Alternate-Protocol for |server| is working. 172 // Confirms that Alternate-Protocol for |server| is working.
162 virtual void ConfirmAlternateProtocol(const HostPortPair& server) = 0; 173 virtual void ConfirmAlternateProtocol(const HostPortPair& server) = 0;
163 174
164 // Clears the Alternate-Protocol for |server|. 175 // Clears the Alternate-Protocol for |server|.
165 virtual void ClearAlternateProtocol(const HostPortPair& server) = 0; 176 virtual void ClearAlternateProtocol(const HostPortPair& server) = 0;
166 177
167 // Returns all Alternate-Protocol mappings. 178 // Returns all Alternate-Protocol mappings.
168 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; 179 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0;
169 180
170 virtual void SetAlternateProtocolExperiment( 181 virtual void SetAlternateProtocolExperiment(
171 AlternateProtocolExperiment experiment) = 0; 182 AlternateProtocolExperiment experiment) = 0;
172 183
184 virtual void SetAlternateProtocolProbabilityThreshold(
185 double threshold) = 0;
186
173 virtual AlternateProtocolExperiment GetAlternateProtocolExperiment() 187 virtual AlternateProtocolExperiment GetAlternateProtocolExperiment()
174 const = 0; 188 const = 0;
175 189
176 // Gets a reference to the SettingsMap stored for a host. 190 // Gets a reference to the SettingsMap stored for a host.
177 // If no settings are stored, returns an empty SettingsMap. 191 // If no settings are stored, returns an empty SettingsMap.
178 virtual const SettingsMap& GetSpdySettings( 192 virtual const SettingsMap& GetSpdySettings(
179 const HostPortPair& host_port_pair) = 0; 193 const HostPortPair& host_port_pair) = 0;
180 194
181 // Saves an individual SPDY setting for a host. Returns true if SPDY setting 195 // Saves an individual SPDY setting for a host. Returns true if SPDY setting
182 // is to be persisted. 196 // is to be persisted.
(...skipping 17 matching lines...) Expand all
200 virtual const NetworkStats* GetServerNetworkStats( 214 virtual const NetworkStats* GetServerNetworkStats(
201 const HostPortPair& host_port_pair) const = 0; 215 const HostPortPair& host_port_pair) const = 0;
202 216
203 private: 217 private:
204 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); 218 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties);
205 }; 219 };
206 220
207 } // namespace net 221 } // namespace net
208 222
209 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ 223 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698