| OLD | NEW |
| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION - | 79 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION - |
| 80 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, | 80 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); | 83 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); |
| 84 NET_EXPORT AlternateProtocol AlternateProtocolFromString( | 84 NET_EXPORT AlternateProtocol AlternateProtocolFromString( |
| 85 const std::string& str); | 85 const std::string& str); |
| 86 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( | 86 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( |
| 87 NextProto next_proto); | 87 NextProto next_proto); |
| 88 | 88 |
| 89 // (protocol, host, port) triple as defined in |
| 90 // https://tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.html |
| 89 struct NET_EXPORT AlternativeService { | 91 struct NET_EXPORT AlternativeService { |
| 90 AlternativeService() | 92 AlternativeService() |
| 91 : protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), host(), port(0) {} | 93 : protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), host(), port(0) {} |
| 92 | 94 |
| 93 AlternativeService(AlternateProtocol protocol, | 95 AlternativeService(AlternateProtocol protocol, |
| 94 const std::string& host, | 96 const std::string& host, |
| 95 uint16 port) | 97 uint16 port) |
| 96 : protocol(protocol), host(host), port(port) {} | 98 : protocol(protocol), host(host), port(port) {} |
| 97 | 99 |
| 98 AlternativeService(AlternateProtocol protocol, | 100 AlternativeService(AlternateProtocol protocol, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 111 } | 113 } |
| 112 | 114 |
| 113 bool operator<(const AlternativeService& other) const { | 115 bool operator<(const AlternativeService& other) const { |
| 114 if (protocol != other.protocol) | 116 if (protocol != other.protocol) |
| 115 return protocol < other.protocol; | 117 return protocol < other.protocol; |
| 116 if (host != other.host) | 118 if (host != other.host) |
| 117 return host < other.host; | 119 return host < other.host; |
| 118 return port < other.port; | 120 return port < other.port; |
| 119 } | 121 } |
| 120 | 122 |
| 123 std::string ToString() const; |
| 124 |
| 121 AlternateProtocol protocol; | 125 AlternateProtocol protocol; |
| 122 std::string host; | 126 std::string host; |
| 123 uint16 port; | 127 uint16 port; |
| 124 }; | 128 }; |
| 125 | 129 |
| 126 struct NET_EXPORT AlternateProtocolInfo { | 130 struct NET_EXPORT AlternativeServiceInfo { |
| 127 AlternateProtocolInfo() | 131 AlternativeServiceInfo() : alternative_service(), probability(0.0) {} |
| 128 : port(0), protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), probability(0) {} | |
| 129 | 132 |
| 130 AlternateProtocolInfo(uint16 port, | 133 AlternativeServiceInfo(const AlternativeService& alternative_service, |
| 131 AlternateProtocol protocol, | 134 double probability) |
| 132 double probability) | 135 : alternative_service(alternative_service), probability(probability) {} |
| 133 : port(port), protocol(protocol), probability(probability) {} | |
| 134 | 136 |
| 135 bool Equals(const AlternateProtocolInfo& other) const { | 137 AlternativeServiceInfo(AlternateProtocol protocol, |
| 136 return port == other.port && | 138 const std::string& host, |
| 137 protocol == other.protocol && | 139 uint16 port, |
| 138 probability == other.probability; | 140 double probability) |
| 141 : alternative_service(protocol, host, port), probability(probability) {} |
| 142 |
| 143 AlternativeServiceInfo( |
| 144 const AlternativeServiceInfo& alternative_service_info) = default; |
| 145 AlternativeServiceInfo& operator=( |
| 146 const AlternativeServiceInfo& alternative_service_info) = default; |
| 147 |
| 148 bool operator==(const AlternativeServiceInfo& other) const { |
| 149 return alternative_service == other.alternative_service && |
| 150 probability == other.probability; |
| 151 } |
| 152 |
| 153 bool operator!=(const AlternativeServiceInfo& other) const { |
| 154 return !this->operator==(other); |
| 139 } | 155 } |
| 140 | 156 |
| 141 std::string ToString() const; | 157 std::string ToString() const; |
| 142 | 158 |
| 143 uint16 port; | 159 AlternativeService alternative_service; |
| 144 AlternateProtocol protocol; | |
| 145 double probability; | 160 double probability; |
| 146 }; | 161 }; |
| 147 | 162 |
| 148 struct NET_EXPORT SupportsQuic { | 163 struct NET_EXPORT SupportsQuic { |
| 149 SupportsQuic() : used_quic(false) {} | 164 SupportsQuic() : used_quic(false) {} |
| 150 SupportsQuic(bool used_quic, const std::string& address) | 165 SupportsQuic(bool used_quic, const std::string& address) |
| 151 : used_quic(used_quic), | 166 : used_quic(used_quic), |
| 152 address(address) {} | 167 address(address) {} |
| 153 | 168 |
| 154 bool Equals(const SupportsQuic& other) const { | 169 bool Equals(const SupportsQuic& other) const { |
| 155 return used_quic == other.used_quic && address == other.address; | 170 return used_quic == other.used_quic && address == other.address; |
| 156 } | 171 } |
| 157 | 172 |
| 158 bool used_quic; | 173 bool used_quic; |
| 159 std::string address; | 174 std::string address; |
| 160 }; | 175 }; |
| 161 | 176 |
| 162 struct NET_EXPORT ServerNetworkStats { | 177 struct NET_EXPORT ServerNetworkStats { |
| 163 ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {} | 178 ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {} |
| 164 | 179 |
| 165 base::TimeDelta srtt; | 180 base::TimeDelta srtt; |
| 166 QuicBandwidth bandwidth_estimate; | 181 QuicBandwidth bandwidth_estimate; |
| 167 }; | 182 }; |
| 168 | 183 |
| 169 typedef base::MRUCache< | 184 typedef base::MRUCache<HostPortPair, AlternativeServiceInfo> |
| 170 HostPortPair, AlternateProtocolInfo> AlternateProtocolMap; | 185 AlternativeServiceMap; |
| 171 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; | 186 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; |
| 172 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; | 187 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; |
| 173 | 188 |
| 174 extern const char kAlternateProtocolHeader[]; | 189 extern const char kAlternateProtocolHeader[]; |
| 175 | 190 |
| 176 // The interface for setting/retrieving the HTTP server properties. | 191 // The interface for setting/retrieving the HTTP server properties. |
| 177 // Currently, this class manages servers': | 192 // Currently, this class manages servers': |
| 178 // * SPDY support (based on NPN results) | 193 // * SPDY support (based on NPN results) |
| 179 // * Alternate-Protocol support | 194 // * alternative service support |
| 180 // * Spdy Settings (like CWND ID field) | 195 // * Spdy Settings (like CWND ID field) |
| 181 class NET_EXPORT HttpServerProperties { | 196 class NET_EXPORT HttpServerProperties { |
| 182 public: | 197 public: |
| 183 HttpServerProperties() {} | 198 HttpServerProperties() {} |
| 184 virtual ~HttpServerProperties() {} | 199 virtual ~HttpServerProperties() {} |
| 185 | 200 |
| 186 // Gets a weak pointer for this object. | 201 // Gets a weak pointer for this object. |
| 187 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() = 0; | 202 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() = 0; |
| 188 | 203 |
| 189 // Deletes all data. | 204 // Deletes all data. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 virtual bool WasAlternativeServiceRecentlyBroken( | 255 virtual bool WasAlternativeServiceRecentlyBroken( |
| 241 const AlternativeService& alternative_service) = 0; | 256 const AlternativeService& alternative_service) = 0; |
| 242 | 257 |
| 243 // Confirms that |alternative_service| is working. | 258 // Confirms that |alternative_service| is working. |
| 244 virtual void ConfirmAlternativeService( | 259 virtual void ConfirmAlternativeService( |
| 245 const AlternativeService& alternative_service) = 0; | 260 const AlternativeService& alternative_service) = 0; |
| 246 | 261 |
| 247 // Clears the alternative service for |origin|. | 262 // Clears the alternative service for |origin|. |
| 248 virtual void ClearAlternativeService(const HostPortPair& origin) = 0; | 263 virtual void ClearAlternativeService(const HostPortPair& origin) = 0; |
| 249 | 264 |
| 250 // Returns all Alternate-Protocol mappings. | 265 // Returns all alternative service mappings. |
| 251 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; | 266 virtual const AlternativeServiceMap& alternative_service_map() const = 0; |
| 252 | 267 |
| 253 // Sets the threshold to be used when evaluating alternative service | 268 // Sets the threshold to be used when evaluating alternative service |
| 254 // advertisments. Only advertisements with a probability greater than or equal | 269 // advertisments. Only advertisements with a probability greater than or equal |
| 255 // to |threshold| will be honored. |threshold| must be between 0.0 and 1.0 | 270 // to |threshold| will be honored. |threshold| must be between 0.0 and 1.0 |
| 256 // inclusive. Hence, a threshold of 0.0 implies that all advertisements will | 271 // inclusive. Hence, a threshold of 0.0 implies that all advertisements will |
| 257 // be honored. | 272 // be honored. |
| 258 virtual void SetAlternateProtocolProbabilityThreshold( | 273 virtual void SetAlternateProtocolProbabilityThreshold( |
| 259 double threshold) = 0; | 274 double threshold) = 0; |
| 260 | 275 |
| 261 // Gets a reference to the SettingsMap stored for a host. | 276 // Gets a reference to the SettingsMap stored for a host. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 292 | 307 |
| 293 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; | 308 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; |
| 294 | 309 |
| 295 private: | 310 private: |
| 296 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 311 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
| 297 }; | 312 }; |
| 298 | 313 |
| 299 } // namespace net | 314 } // namespace net |
| 300 | 315 |
| 301 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 316 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
| OLD | NEW |