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

Unified Diff: net/spdy/spdy_protocol.cc

Issue 247243003: SPDY: Use SpdyMajorVersion rather than ints for SPDY version number. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Also include cr/64899106 Created 6 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/spdy/spdy_protocol.h ('k') | net/spdy/spdy_protocol_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_protocol.cc
diff --git a/net/spdy/spdy_protocol.cc b/net/spdy/spdy_protocol.cc
index 2069f8e1aeccb45f39f27d47f4cdb57f5d734868..2895d9be18162f54946ec60f5086dcbaf2a7998f 100644
--- a/net/spdy/spdy_protocol.cc
+++ b/net/spdy/spdy_protocol.cc
@@ -49,6 +49,7 @@ bool SpdyConstants::IsValidFrameType(SpdyMajorVersion version,
return true;
case SPDY4:
+ case SPDY5:
// DATA is the first valid frame.
if (frame_type_field < SerializeFrameType(version, DATA)) {
return false;
@@ -91,6 +92,7 @@ SpdyFrameType SpdyConstants::ParseFrameType(SpdyMajorVersion version,
}
break;
case SPDY4:
+ case SPDY5:
switch (frame_type_field) {
case 0:
return DATA;
@@ -148,6 +150,7 @@ int SpdyConstants::SerializeFrameType(SpdyMajorVersion version,
return -1;
}
case SPDY4:
+ case SPDY5:
switch (frame_type) {
case DATA:
return 0;
@@ -199,6 +202,7 @@ bool SpdyConstants::IsValidSettingId(SpdyMajorVersion version,
return true;
case SPDY4:
+ case SPDY5:
// HEADER_TABLE_SIZE is the first valid setting id.
if (setting_id_field <
SerializeSettingId(version, SETTINGS_HEADER_TABLE_SIZE)) {
@@ -241,6 +245,7 @@ SpdySettingsIds SpdyConstants::ParseSettingId(SpdyMajorVersion version,
}
break;
case SPDY4:
+ case SPDY5:
switch (setting_id_field) {
case 1:
return SETTINGS_HEADER_TABLE_SIZE;
@@ -283,6 +288,7 @@ int SpdyConstants::SerializeSettingId(SpdyMajorVersion version,
return -1;
}
case SPDY4:
+ case SPDY5:
switch (id) {
case SETTINGS_HEADER_TABLE_SIZE:
return 1;
@@ -320,6 +326,7 @@ bool SpdyConstants::IsValidRstStreamStatus(SpdyMajorVersion version,
return true;
case SPDY4:
+ case SPDY5:
// NO_ERROR is the first valid status code.
if (rst_stream_status_field <
SerializeRstStreamStatus(version, RST_STREAM_PROTOCOL_ERROR)) {
@@ -379,6 +386,7 @@ SpdyRstStreamStatus SpdyConstants::ParseRstStreamStatus(
}
break;
case SPDY4:
+ case SPDY5:
switch (rst_stream_status_field) {
case 1:
return RST_STREAM_PROTOCOL_ERROR;
@@ -441,6 +449,7 @@ int SpdyConstants::SerializeRstStreamStatus(
return -1;
}
case SPDY4:
+ case SPDY5:
switch (rst_stream_status) {
case RST_STREAM_PROTOCOL_ERROR:
return 1;
@@ -486,6 +495,7 @@ bool SpdyConstants::IsValidGoAwayStatus(SpdyMajorVersion version,
return true;
case SPDY4:
+ case SPDY5:
// GOAWAY_NO_ERROR is the first valid status.
if (goaway_status_field < SerializeGoAwayStatus(version,
GOAWAY_NO_ERROR)) {
@@ -517,6 +527,7 @@ SpdyGoAwayStatus SpdyConstants::ParseGoAwayStatus(SpdyMajorVersion version,
}
break;
case SPDY4:
+ case SPDY5:
switch (goaway_status_field) {
case 0:
return GOAWAY_NO_ERROR;
@@ -552,6 +563,54 @@ SpdyGoAwayStatus SpdyConstants::ParseGoAwayStatus(SpdyMajorVersion version,
return GOAWAY_PROTOCOL_ERROR;
}
+SpdyMajorVersion SpdyConstants::ParseMajorVersion(int version_number) {
+ switch (version_number) {
+ case 2:
+ return SPDY2;
+ case 3:
+ return SPDY3;
+ case 4:
+ return SPDY4;
+ case 5:
+ return SPDY5;
+ default:
+ LOG(DFATAL) << "Unsupported SPDY version number: " << version_number;
+ return SPDY3;
+ }
+}
+
+int SpdyConstants::SerializeMajorVersion(SpdyMajorVersion version) {
+ switch (version) {
+ case SPDY2:
+ return 2;
+ case SPDY3:
+ return 3;
+ case SPDY4:
+ return 4;
+ case SPDY5:
+ return 5;
+ default:
+ LOG(DFATAL) << "Unsupported SPDY major version: " << version;
+ return -1;
+ }
+}
+
+std::string SpdyConstants::GetVersionString(SpdyMajorVersion version) {
+ switch (version) {
+ case SPDY2:
+ return "spdy/2";
+ case SPDY3:
+ return "spdy/3";
+ case SPDY4:
+ return "spdy/4";
+ case SPDY5:
+ return "spdy/5";
+ default:
+ LOG(DFATAL) << "Unsupported SPDY major version: " << version;
+ return "spdy/3";
+ }
+}
+
int SpdyConstants::SerializeGoAwayStatus(SpdyMajorVersion version,
SpdyGoAwayStatus status) {
switch (version) {
@@ -569,6 +628,7 @@ int SpdyConstants::SerializeGoAwayStatus(SpdyMajorVersion version,
return -1;
}
case SPDY4:
+ case SPDY5:
switch (status) {
case GOAWAY_NO_ERROR:
return 0;
@@ -612,6 +672,7 @@ size_t SpdyConstants::GetControlFrameHeaderSize(SpdyMajorVersion version) {
case SPDY2:
case SPDY3:
case SPDY4:
+ case SPDY5:
return 8;
}
LOG(DFATAL) << "Unhandled SPDY version.";
« no previous file with comments | « net/spdy/spdy_protocol.h ('k') | net/spdy/spdy_protocol_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698