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

Unified 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: Work on pref load/save and on Job. 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 side-by-side diff with in-line comments
Download patch
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..d12822e294bfe15c9d9c577658fa13ad87bf20eb 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,30 @@ 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);
+struct NET_EXPORT AlternativeService {
+ AlternativeService(AlternateProtocol protocol,
+ const std::string& host,
+ uint16 port)
+ : protocol(protocol), host(host), port(port) {}
+
+ bool operator<(const AlternativeService& other) const {
+ if (protocol != other.protocol)
+ return protocol < other.protocol;
+ if (host != other.host)
+ return host < other.host;
+ return port < other.port;
+ }
+
+ AlternateProtocol protocol;
+ const std::string host;
+ uint16 port;
+};
+// TODO(bnc): Rename to AlternateServiceInfo.
struct NET_EXPORT AlternateProtocolInfo {
+ AlternateProtocolInfo()
+ : port(0), protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), probability(0) {}
+
AlternateProtocolInfo(uint16 port,
AlternateProtocol protocol,
double probability)
@@ -104,9 +123,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 +160,25 @@ struct NET_EXPORT ServerNetworkStats {
QuicBandwidth bandwidth_estimate;
};
-typedef base::MRUCache<
- HostPortPair, AlternateProtocolInfo> AlternateProtocolMap;
+// TODO(bnc): Rename to AlternateServices.
+typedef std::vector<AlternateProtocolInfo> AlternateProtocols;
+// TODO(bnc): Rename to AlternateServicesMap.
+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 AlternateServicesToString.
+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)
@@ -184,33 +217,52 @@ class NET_EXPORT HttpServerProperties {
SSLConfig* ssl_config) = 0;
// Returns true if |server| has an Alternate-Protocol header.
+ // TODO(bnc): Rename to HasAlternateService.
virtual bool HasAlternateProtocol(const HostPortPair& server) = 0;
- // Returns the Alternate-Protocol and port for |server|.
+ // Returns the Alternate-Protocols for |server|.
// HasAlternateProtocol(server) must be true.
- virtual AlternateProtocolInfo GetAlternateProtocol(
+ virtual const AlternateProtocols& GetAlternateProtocols(
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 AddAlternateService.
+ 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 ClearAlternateServices.
virtual void ClearAlternateProtocol(const HostPortPair& server) = 0;
+ // Clears all Alternate-Protocols that are not broken for |server|.
+ // TODO(bnc): Rename to ClearNonBrokenAlternateServices.
+ virtual void ClearNonBrokenAlternateProtocols(const HostPortPair& server) = 0;
+
+ // Removes an Alternate-Protocol for |server|.
+ // TODO(bnc): Rename to RemoveAlternateService.
+ virtual void RemoveAlternateProtocol(
+ const HostPortPair& server,
+ const AlternateProtocolInfo& alternate_protocol) = 0;
+
// Returns all Alternate-Protocol mappings.
+ // TODO(bnc): Rename to alternate_services_map.
virtual const AlternateProtocolMap& alternate_protocol_map() const = 0;
// Sets the threshold to be used when evaluating Alternate-Protocol

Powered by Google App Engine
This is Rietveld 408576698