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

Unified Diff: net/http/http_server_properties.h

Issue 1824903002: Change the AlternativeServiceMap with SchemeOriginPair key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unittests Created 4 years, 9 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 4b1f92eada072c4d365d9bc6a36bd21b96c63521..9b1e7323a6d7043fcc3766f97eaada6a19af2a48 100644
--- a/net/http/http_server_properties.h
+++ b/net/http/http_server_properties.h
@@ -23,6 +23,7 @@
#include "net/socket/next_proto.h"
#include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this.
#include "net/spdy/spdy_protocol.h"
+#include "url/gurl.h"
namespace base {
class Value;
@@ -206,9 +207,48 @@ struct NET_EXPORT ServerNetworkStats {
QuicBandwidth bandwidth_estimate;
};
+class NET_EXPORT SchemeOriginPair {
Ryan Hamilton 2016/03/24 22:23:14 I think we should definitely use url::SchemeHostPo
Zhongyi Shi 2016/04/04 18:58:35 Done.
+ public:
+ SchemeOriginPair();
+ SchemeOriginPair(const std::string& in_scheme,
+ const HostPortPair& in_host_port);
+ // If |in_host| represents an IPv6 address, it should not bracket the address.
+ SchemeOriginPair(const std::string& in_scheme,
+ const std::string& in_host,
+ uint16_t in_port);
+
+ const std::string& scheme() const { return scheme_; }
+
+ const HostPortPair& host_port_pair() const { return host_port_pair_; }
+
+ const std::string& host() const { return host_port_pair_.host(); }
+
+ uint16_t port() const { return host_port_pair_.port(); }
+
+ void set_scheme(const std::string& scheme) { scheme_ = scheme; }
+
+ void set_host(const std::string& host) { host_port_pair_.set_host(host); }
+
+ void set_port(uint16_t port) { host_port_pair_.set_port(port); }
+
+ static SchemeOriginPair FromURL(const GURL& url);
+
+ // Equality test of contents. (Probably another violation of style guide).
+ bool Equals(const SchemeOriginPair& other) const;
+
+ bool IsEmpty() const;
+
+ // Allows SchemeOriginPair to be used as a key in STL.
+ bool operator<(const SchemeOriginPair& other) const;
+
+ private:
+ std::string scheme_;
+ HostPortPair host_port_pair_;
+};
+
typedef std::vector<AlternativeService> AlternativeServiceVector;
typedef std::vector<AlternativeServiceInfo> AlternativeServiceInfoVector;
-typedef base::MRUCache<HostPortPair, AlternativeServiceInfoVector>
+typedef base::MRUCache<SchemeOriginPair, AlternativeServiceInfoVector>
AlternativeServiceMap;
typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap;
typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap;
@@ -242,7 +282,7 @@ class NET_EXPORT HttpServerProperties {
// Returns true if |server| supports a network protocol which honors
// request prioritization.
- virtual bool SupportsRequestPriority(const HostPortPair& server) = 0;
+ virtual bool SupportsRequestPriority(const SchemeOriginPair& server) = 0;
// Returns the value set by SetSupportsSpdy(). If not set, returns false.
virtual bool GetSupportsSpdy(const HostPortPair& server) = 0;
Ryan Hamilton 2016/03/24 22:23:14 Should these next 6 methods also use a SHP?
Zhongyi Shi 2016/04/04 18:58:35 I don't think so, only SupportsRequestPriority que
@@ -269,14 +309,14 @@ class NET_EXPORT HttpServerProperties {
// or equal to the threshold, including broken ones.
// Returned alternative services never have empty hostnames.
virtual AlternativeServiceVector GetAlternativeServices(
- const HostPortPair& origin) = 0;
+ const SchemeOriginPair& origin) = 0;
// Set a single alternative service for |origin|. Previous alternative
// services for |origin| are discarded.
// |alternative_service.host| may be empty.
// Return true if |alternative_service_map_| is changed.
virtual bool SetAlternativeService(
- const HostPortPair& origin,
+ const SchemeOriginPair& origin,
const AlternativeService& alternative_service,
double alternative_probability,
base::Time expiration) = 0;
@@ -286,7 +326,7 @@ class NET_EXPORT HttpServerProperties {
// Hostnames in |alternative_service_info_vector| may be empty.
// Return true if |alternative_service_map_| is changed.
virtual bool SetAlternativeServices(
- const HostPortPair& origin,
+ const SchemeOriginPair& origin,
const AlternativeServiceInfoVector& alternative_service_info_vector) = 0;
// Marks |alternative_service| as broken.
@@ -315,7 +355,7 @@ class NET_EXPORT HttpServerProperties {
const AlternativeService& alternative_service) = 0;
// Clear all alternative services for |origin|.
- virtual void ClearAlternativeServices(const HostPortPair& origin) = 0;
+ virtual void ClearAlternativeServices(const SchemeOriginPair& origin) = 0;
// Returns all alternative service mappings.
// Returned alternative services may have empty hostnames.

Powered by Google App Engine
This is Rietveld 408576698