Index: net/http/http_server_properties.h |
diff --git a/net/http/http_server_properties.h b/net/http/http_server_properties.h |
index 79ce33d6d794bd020f4bd1a4ed80e01585d735b4..7bdcc6ec7e4e000697161117cfd07246199afd3b 100644 |
--- a/net/http/http_server_properties.h |
+++ b/net/http/http_server_properties.h |
@@ -7,6 +7,8 @@ |
#include <map> |
#include <string> |
+#include <vector> |
+ |
#include "base/basictypes.h" |
#include "base/containers/mru_cache.h" |
#include "base/memory/weak_ptr.h" |
@@ -79,13 +81,11 @@ enum AlternateProtocolSize { |
ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, |
}; |
-NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); |
-NET_EXPORT AlternateProtocol AlternateProtocolFromString( |
- const std::string& str); |
-NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( |
- NextProto next_proto); |
- |
+// TODO(bnc): Rename to AlternativeServiceInfo. |
struct NET_EXPORT AlternateProtocolInfo { |
+ AlternateProtocolInfo() |
+ : port(0), protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), probability(0) {} |
+ |
AlternateProtocolInfo(uint16 port, |
AlternateProtocol protocol, |
double probability) |
@@ -104,9 +104,12 @@ struct NET_EXPORT AlternateProtocolInfo { |
is_broken(is_broken) {} |
bool Equals(const AlternateProtocolInfo& other) const { |
- return port == other.port && |
- protocol == other.protocol && |
- probability == other.probability; |
+ return port == other.port && protocol == other.protocol && |
+ probability == other.probability; |
+ } |
+ |
+ bool EqualsModuloProbability(const AlternateProtocolInfo& other) const { |
+ return port == other.port && protocol == other.protocol; |
} |
std::string ToString() const; |
@@ -138,14 +141,25 @@ struct NET_EXPORT ServerNetworkStats { |
QuicBandwidth bandwidth_estimate; |
}; |
-typedef base::MRUCache< |
- HostPortPair, AlternateProtocolInfo> AlternateProtocolMap; |
+// TODO(bnc): Rename to AlternativeServices. |
+typedef std::vector<AlternateProtocolInfo> AlternateProtocols; |
+// TODO(bnc): Rename to AlternativeServicesMap. |
+typedef base::MRUCache<HostPortPair, AlternateProtocols> AlternateProtocolMap; |
typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; |
typedef std::map<HostPortPair, SupportsQuic> SupportsQuicMap; |
typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; |
extern const char kAlternateProtocolHeader[]; |
+NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); |
+// TODO(bnc): Rename to AlternativeServicesToString. |
+NET_EXPORT std::string AlternateProtocolsToString( |
+ const AlternateProtocols& services); |
+NET_EXPORT AlternateProtocol |
+AlternateProtocolFromString(const std::string& str); |
+NET_EXPORT_PRIVATE AlternateProtocol |
+AlternateProtocolFromNextProto(NextProto next_proto); |
+ |
// The interface for setting/retrieving the HTTP server properties. |
// Currently, this class manages servers': |
// * SPDY support (based on NPN results) |
@@ -183,34 +197,56 @@ class NET_EXPORT HttpServerProperties { |
virtual void MaybeForceHTTP11(const HostPortPair& server, |
SSLConfig* ssl_config) = 0; |
- // Returns true if |server| has an Alternate-Protocol header. |
+ // Returns true iff |server| has a non-broken AlternateProtocol with |
+ // probability exceeding threshold, or if AlternateProtocol is forced. |
+ // TODO(bnc): Rename to HasAlternativeService. |
virtual bool HasAlternateProtocol(const HostPortPair& server) = 0; |
- // Returns the Alternate-Protocol and port for |server|. |
- // HasAlternateProtocol(server) must be true. |
+ // Returns the first non-broken AlternateProtocol with probability exceeding |
+ // threshold for |server|, or forced AlternateProtocol, or one with |
+ // UNINITIALIZED_ALTERNATE_PROTOCOL. |
+ // TODO(bnc): Rename to GetAlternativeService. |
virtual AlternateProtocolInfo GetAlternateProtocol( |
const HostPortPair& server) = 0; |
- // Sets the Alternate-Protocol for |server|. |
- virtual void SetAlternateProtocol(const HostPortPair& server, |
+ // Adds an Alternate-Protocol for |server|. |
+ // TODO(bnc): Rename to AddAlternativeService. |
+ virtual void AddAlternateProtocol(const HostPortPair& server, |
uint16 alternate_port, |
AlternateProtocol alternate_protocol, |
double probability) = 0; |
- // Sets the Alternate-Protocol for |server| to be BROKEN. |
- virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; |
+ // Sets a given Alternate-Protocol for |server| to be broken. |
+ virtual void SetBrokenAlternateProtocol( |
+ const HostPortPair& server, |
+ const AlternateProtocolInfo& broken_alternate_protocol) = 0; |
- // Returns true if Alternate-Protocol for |server| was recently BROKEN. |
+ // Returns true if given Alternate-Protocol for |server| was recently broken. |
virtual bool WasAlternateProtocolRecentlyBroken( |
- const HostPortPair& server) = 0; |
+ const HostPortPair& server, |
+ const AlternateProtocolInfo& alternate_protocol) = 0; |
- // Confirms that Alternate-Protocol for |server| is working. |
- virtual void ConfirmAlternateProtocol(const HostPortPair& server) = 0; |
+ // Confirms that given Alternate-Protocol for |server| is working. |
+ virtual void ConfirmAlternateProtocol( |
+ const HostPortPair& server, |
+ const AlternateProtocolInfo& alternate_protocol) = 0; |
- // Clears the Alternate-Protocol for |server|. |
+ // Clears all Alternate-Protocols for |server|. |
+ // TODO(bnc): Rename to ClearAlternativeServices. |
virtual void ClearAlternateProtocol(const HostPortPair& server) = 0; |
+ // Clears all Alternate-Protocols that are not broken for |server|. |
+ // TODO(bnc): Rename to ClearNonBrokenAlternativeServices. |
+ virtual void ClearNonBrokenAlternateProtocols(const HostPortPair& server) = 0; |
+ |
+ // Removes an Alternate-Protocol for |server|. |
+ // TODO(bnc): Rename to RemoveAlternativeService. |
+ virtual void RemoveAlternateProtocol( |
+ const HostPortPair& server, |
+ const AlternateProtocolInfo& alternate_protocol) = 0; |
+ |
// Returns all Alternate-Protocol mappings. |
+ // TODO(bnc): Rename to alternative_services_map. |
virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; |
// Sets the threshold to be used when evaluating Alternate-Protocol |