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

Unified Diff: net/spdy/spdy_protocol.cc

Issue 2544343003: Use wire values in SpdySettingsIds. (Closed)
Patch Set: Created 4 years 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 6970ce7c43c8fbcee68f8cf01a32f12f332dc0e9..cd7733942da49764c8b81bb4af2dd5134a272f4b 100644
--- a/net/spdy/spdy_protocol.cc
+++ b/net/spdy/spdy_protocol.cc
@@ -158,57 +158,47 @@ bool SpdyConstants::IsValidHTTP2FrameStreamId(
}
}
-bool SpdyConstants::IsValidSettingId(int setting_id_field) {
- // HEADER_TABLE_SIZE is the first valid setting id.
- if (setting_id_field < SerializeSettingId(SETTINGS_HEADER_TABLE_SIZE)) {
+bool SpdyConstants::ParseSettingsId(int wire_setting_id,
+ SpdySettingsIds* setting_id) {
+ // HEADER_TABLE_SIZE is the first defined setting id.
+ if (wire_setting_id < SETTINGS_MIN) {
return false;
}
- // MAX_HEADER_LIST_SIZE is the last valid setting id.
- if (setting_id_field > SerializeSettingId(SETTINGS_MAX_HEADER_LIST_SIZE)) {
+ // MAX_HEADER_LIST_SIZE is the last defined setting id.
+ if (wire_setting_id > SETTINGS_MAX) {
return false;
}
+ *setting_id = static_cast<SpdySettingsIds>(wire_setting_id);
return true;
}
-SpdySettingsIds SpdyConstants::ParseSettingId(int setting_id_field) {
- switch (setting_id_field) {
- case 1:
- return SETTINGS_HEADER_TABLE_SIZE;
- case 2:
- return SETTINGS_ENABLE_PUSH;
- case 3:
- return SETTINGS_MAX_CONCURRENT_STREAMS;
- case 4:
- return SETTINGS_INITIAL_WINDOW_SIZE;
- case 5:
- return SETTINGS_MAX_FRAME_SIZE;
- case 6:
- return SETTINGS_MAX_HEADER_LIST_SIZE;
- }
- SPDY_BUG << "Unhandled setting ID " << setting_id_field;
- return SETTINGS_UPLOAD_BANDWIDTH;
-}
-
-int SpdyConstants::SerializeSettingId(SpdySettingsIds id) {
+bool SpdyConstants::SettingsIdToString(SpdySettingsIds id,
+ const char** settings_id_string) {
switch (id) {
case SETTINGS_HEADER_TABLE_SIZE:
- return 1;
+ *settings_id_string = "SETTINGS_HEADER_TABLE_SIZE";
+ return true;
case SETTINGS_ENABLE_PUSH:
- return 2;
+ *settings_id_string = "SETTINGS_ENABLE_PUSH";
+ return true;
case SETTINGS_MAX_CONCURRENT_STREAMS:
- return 3;
+ *settings_id_string = "SETTINGS_MAX_CONCURRENT_STREAMS";
+ return true;
case SETTINGS_INITIAL_WINDOW_SIZE:
- return 4;
+ *settings_id_string = "SETTINGS_INITIAL_WINDOW_SIZE";
+ return true;
case SETTINGS_MAX_FRAME_SIZE:
- return 5;
+ *settings_id_string = "SETTINGS_MAX_FRAME_SIZE";
+ return true;
case SETTINGS_MAX_HEADER_LIST_SIZE:
- return 6;
- default:
- SPDY_BUG << "Serializing unhandled setting id " << id;
- return -1;
+ *settings_id_string = "SETTINGS_MAX_HEADER_LIST_SIZE";
+ return true;
}
+
+ *settings_id_string = "SETTINGS_UNKNOWN";
+ return false;
}
bool SpdyConstants::IsValidRstStreamStatus(int rst_stream_status_field) {
« 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