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

Unified Diff: net/spdy/spdy_protocol.cc

Issue 2619493005: Harmonize SpdyFrameType enum values with wire values. (Closed)
Patch Set: Rebase. Created 3 years, 11 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') | no next file » | 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 adf76ef0c98975c3c15f981e388244689be20d2a..1c9254e3045679670228efdf1552656dce53c635 100644
--- a/net/spdy/spdy_protocol.cc
+++ b/net/spdy/spdy_protocol.cc
@@ -46,54 +46,13 @@ SpdyPriority Http2WeightToSpdy3Priority(int weight) {
}
bool IsValidFrameType(int frame_type_field) {
- // Check for recognized extensions.
- if (frame_type_field == SerializeFrameType(ALTSVC) ||
- frame_type_field == SerializeFrameType(BLOCKED)) {
- return true;
- }
-
- // DATA is the first valid frame.
- if (frame_type_field < SerializeFrameType(DATA)) {
- return false;
- }
-
- // CONTINUATION is the last valid frame.
- if (frame_type_field > SerializeFrameType(CONTINUATION)) {
- return false;
- }
-
- return true;
+ return frame_type_field >= MIN_FRAME_TYPE &&
+ frame_type_field <= MAX_FRAME_TYPE;
}
SpdyFrameType ParseFrameType(int frame_type_field) {
- switch (frame_type_field) {
- case 0:
- return DATA;
- case 1:
- return HEADERS;
- case 2:
- return PRIORITY;
- case 3:
- return RST_STREAM;
- case 4:
- return SETTINGS;
- case 5:
- return PUSH_PROMISE;
- case 6:
- return PING;
- case 7:
- return GOAWAY;
- case 8:
- return WINDOW_UPDATE;
- case 9:
- return CONTINUATION;
- case 10:
- return ALTSVC;
- case 11:
- return BLOCKED;
- }
- SPDY_BUG << "Unhandled frame type " << frame_type_field;
- return DATA;
+ SPDY_BUG_IF(!IsValidFrameType(frame_type_field)) << "Invalid frame type.";
+ return static_cast<SpdyFrameType>(frame_type_field);
}
int SerializeFrameType(SpdyFrameType frame_type) {
« no previous file with comments | « net/spdy/spdy_protocol.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698