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

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: Minor cleanup 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 5dfcebcd75f4fe2022d13d66346f188d6496bf09..d36de365e9466889d83ebaaf8d4133911ce28de3 100644
--- a/net/http/http_server_properties.cc
+++ b/net/http/http_server_properties.cc
@@ -16,8 +16,9 @@ const char* const kAlternateProtocolStrings[] = {
"npn-spdy/2.1",
"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:
@@ -25,7 +26,7 @@ static const char* AlternateProtocolToString(AlternateProtocol protocol) {
case NPN_SPDY_3:
return kAlternateProtocolStrings[protocol];
case ALTERNATE_PROTOCOL_BROKEN:
- return "Broken";
+ return kBrokenAlternateProtocol;
case UNINITIALIZED_ALTERNATE_PROTOCOL:
return "Uninitialized";
default:
@@ -34,6 +35,16 @@ static const char* AlternateProtocolToString(AlternateProtocol protocol) {
}
}
+AlternateProtocol AlternateProtocolFromString(const std::string& protocol) {
+ for (int i = NPN_SPDY_1; i < NPN_SPDY_3; i++)
ramant (doing other things) 2012/04/07 00:41:22 nit: i++ -> ++i Should we support "npn-spdy/3"?
+ 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