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

Unified Diff: net/http/http_server_properties.cc

Issue 10006047: Persist the alternate protocol as a string not an int to allow the enum to be changed without affec… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add NET_EXPORT to new public functions Created 8 years, 8 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
« no previous file with comments | « net/http/http_server_properties.h ('k') | no next file » | 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 128bf664bcd062fbb9201e009183a470c5b6f27c..eba05ef875d79e9f90aecc54d3bd6d023dd45284 100644
--- a/net/http/http_server_properties.cc
+++ b/net/http/http_server_properties.cc
@@ -15,15 +15,16 @@ const char* const kAlternateProtocolStrings[] = {
"npn-spdy/2",
"npn-spdy/3",
};
+const char kBrokenAlternateProtocol[] = "Broken";
-static const char* AlternateProtocolToString(AlternateProtocol protocol) {
+const char* AlternateProtocolToString(AlternateProtocol protocol) {
switch (protocol) {
case NPN_SPDY_1:
case NPN_SPDY_2:
case NPN_SPDY_3:
return kAlternateProtocolStrings[protocol];
case ALTERNATE_PROTOCOL_BROKEN:
- return "Broken";
+ return kBrokenAlternateProtocol;
case UNINITIALIZED_ALTERNATE_PROTOCOL:
return "Uninitialized";
default:
@@ -32,6 +33,16 @@ static const char* AlternateProtocolToString(AlternateProtocol protocol) {
}
}
+AlternateProtocol AlternateProtocolFromString(const std::string& protocol) {
+ for (int i = NPN_SPDY_1; i < NUM_ALTERNATE_PROTOCOLS; ++i)
+ if (protocol == kAlternateProtocolStrings[i])
+ return static_cast<AlternateProtocol>(i);
+ if (protocol == kBrokenAlternateProtocol)
+ return ALTERNATE_PROTOCOL_BROKEN;
+ return UNINITIALIZED_ALTERNATE_PROTOCOL;
+}
+
+
std::string PortAlternateProtocolPair::ToString() const {
return base::StringPrintf("%d:%s", port,
AlternateProtocolToString(protocol));
« no previous file with comments | « net/http/http_server_properties.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698