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

Unified Diff: net/http/http_server_properties.cc

Issue 2373663002: Unify enum NextProto and enum AlternateProtocol. (Closed)
Patch Set: Fix compile errors. Created 4 years, 1 month 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
« no previous file with comments | « net/http/http_server_properties.h ('k') | net/http/http_server_properties_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_server_properties.cc
diff --git a/net/http/http_server_properties.cc b/net/http/http_server_properties.cc
index c6c6432d5e49c22f6feea3886a91233648024171..1e5471c5e0c50be122241a1717a1eeed6645ee8f 100644
--- a/net/http/http_server_properties.cc
+++ b/net/http/http_server_properties.cc
@@ -63,66 +63,23 @@ void HistogramBrokenAlternateProtocolLocation(
BROKEN_ALTERNATE_PROTOCOL_LOCATION_MAX);
}
-bool IsAlternateProtocolValid(AlternateProtocol protocol) {
+bool IsAlternateProtocolValid(NextProto protocol) {
switch (protocol) {
- case NPN_HTTP_2:
+ case kProtoUnknown:
+ return false;
+ case kProtoHTTP11:
+ return false;
+ case kProtoHTTP2:
return true;
- case QUIC:
+ case kProtoQUIC:
return true;
- case UNINITIALIZED_ALTERNATE_PROTOCOL:
- return false;
}
NOTREACHED();
return false;
}
-const char* AlternateProtocolToString(AlternateProtocol protocol) {
- switch (protocol) {
- case QUIC:
- return "quic";
- case NPN_HTTP_2:
- return "h2";
- case UNINITIALIZED_ALTERNATE_PROTOCOL:
- return "Uninitialized";
- }
- NOTREACHED();
- return "";
-}
-
-AlternateProtocol AlternateProtocolFromString(const std::string& str) {
- if (str == "quic")
- return QUIC;
- if (str == "h2")
- return NPN_HTTP_2;
- // "npn-h2" and "npn-spdy/3.1" are accepted here so that persisted settings
- // with the old string can be loaded from disk. TODO(bnc): Remove around
- // 2016 December.
- if (str == "npn-h2")
- return NPN_HTTP_2;
- if (str == "npn-spdy/3.1")
- return NPN_HTTP_2;
-
- return UNINITIALIZED_ALTERNATE_PROTOCOL;
-}
-
-AlternateProtocol AlternateProtocolFromNextProto(NextProto next_proto) {
- switch (next_proto) {
- case kProtoHTTP2:
- return NPN_HTTP_2;
- case kProtoQUIC:
- return QUIC;
-
- case kProtoUnknown:
- case kProtoHTTP11:
- break;
- }
-
- NOTREACHED() << "Invalid NextProto: " << next_proto;
- return UNINITIALIZED_ALTERNATE_PROTOCOL;
-}
-
std::string AlternativeService::ToString() const {
- return base::StringPrintf("%s %s:%d", AlternateProtocolToString(protocol),
+ return base::StringPrintf("%s %s:%d", NextProtoToString(protocol),
host.c_str(), port);
}
« no previous file with comments | « net/http/http_server_properties.h ('k') | net/http/http_server_properties_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698