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

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: 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 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..223231904735ae51eb2d9e2d59fa5e8d6a0732ba 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 AlternateServiceInfo.
struct NET_EXPORT AlternateProtocolInfo {
+ AlternateProtocolInfo()
+ : port(0), protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), probability(0) {}
+
AlternateProtocolInfo(uint16 port,
AlternateProtocol protocol,
double probability)
@@ -109,6 +109,11 @@ struct NET_EXPORT AlternateProtocolInfo {
probability == other.probability;
}
+ bool EqualsModuloProbabilityAndProtocol(
+ const AlternateProtocolInfo& other) const {
+ return port == other.port;
+ }
+
std::string ToString() const;
uint16 port;
@@ -138,14 +143,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 +200,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