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

Unified Diff: net/socket/next_proto.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/socket/next_proto.h ('k') | net/socket/ssl_client_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/next_proto.cc
diff --git a/net/socket/next_proto.cc b/net/socket/next_proto.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7ec7c1d68d09537581bb04452dec60fd63a689c3
--- /dev/null
+++ b/net/socket/next_proto.cc
@@ -0,0 +1,39 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/socket/next_proto.h"
+
+namespace net {
+
+NextProto NextProtoFromString(base::StringPiece proto_string) {
+ if (proto_string == "http1.1" || proto_string == "http/1.1")
+ return kProtoHTTP11;
+ // "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 (proto_string == "h2" || proto_string == "npn-h2" ||
+ proto_string == "npn-spdy/3.1") {
+ return kProtoHTTP2;
+ }
+ if (proto_string == "quic")
+ return kProtoQUIC;
+
+ return kProtoUnknown;
+}
+
+const char* NextProtoToString(NextProto next_proto) {
+ switch (next_proto) {
+ case kProtoHTTP11:
+ return "http/1.1";
+ case kProtoHTTP2:
+ return "h2";
+ case kProtoQUIC:
+ return "quic";
+ case kProtoUnknown:
+ break;
+ }
+ return "unknown";
+}
+
+} // namespace net
« no previous file with comments | « net/socket/next_proto.h ('k') | net/socket/ssl_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698