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

Unified Diff: net/spdy/spdy_protocol.cc

Issue 202383002: Add settings IDs to SpdyConstants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test fix. Created 6 years, 9 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 cec9ba29dc06da07abf0e0ab09fe3bcfcdef83b6..02c74ef3bd178f5d287bc525966c6e071b8a4974 100644
--- a/net/spdy/spdy_protocol.cc
+++ b/net/spdy/spdy_protocol.cc
@@ -61,6 +61,9 @@ bool SpdyConstants::IsValidFrameType(SpdyMajorVersion version,
return true;
}
+
+ LOG(DFATAL) << "Unhandled SPDY version " << version;
+ return false;
}
SpdyFrameType SpdyConstants::ParseFrameType(SpdyMajorVersion version,
@@ -172,6 +175,130 @@ int SpdyConstants::SerializeFrameType(SpdyMajorVersion version,
return -1;
}
}
+
+ LOG(DFATAL) << "Unhandled SPDY version " << version;
+ return -1;
+}
+
+bool SpdyConstants::IsValidSettingId(SpdyMajorVersion version,
+ int setting_id_field) {
+ switch (version) {
+ case SPDY2:
+ case SPDY3:
+ // UPLOAD_BANDWIDTH is the first valid setting id.
+ if (setting_id_field <
+ SerializeSettingId(version, SETTINGS_UPLOAD_BANDWIDTH)) {
+ return false;
+ }
+
+ // INITIAL_WINDOW_SIZE is the last valid setting id.
+ if (setting_id_field >
+ SerializeSettingId(version, SETTINGS_INITIAL_WINDOW_SIZE)) {
+ return false;
+ }
+
+ return true;
+ case SPDY4:
+ // HEADER_TABLE_SIZE is the first valid setting id.
+ if (setting_id_field <
+ SerializeSettingId(version, SETTINGS_HEADER_TABLE_SIZE)) {
+ return false;
+ }
+
+ // INITIAL_WINDOW_SIZE is the last valid setting id.
+ if (setting_id_field >
+ SerializeSettingId(version, SETTINGS_INITIAL_WINDOW_SIZE)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ LOG(DFATAL) << "Unhandled SPDY version " << version;
+ return false;
+}
+
+SpdySettingsIds SpdyConstants::ParseSettingId(SpdyMajorVersion version,
+ int setting_id_field) {
+ switch (version) {
+ case SPDY2:
+ case SPDY3:
+ switch (setting_id_field) {
+ case 1:
+ return SETTINGS_UPLOAD_BANDWIDTH;
+ case 2:
+ return SETTINGS_DOWNLOAD_BANDWIDTH;
+ case 3:
+ return SETTINGS_ROUND_TRIP_TIME;
+ case 4:
+ return SETTINGS_MAX_CONCURRENT_STREAMS;
+ case 5:
+ return SETTINGS_CURRENT_CWND;
+ case 6:
+ return SETTINGS_DOWNLOAD_RETRANS_RATE;
+ case 7:
+ return SETTINGS_INITIAL_WINDOW_SIZE;
+ }
+ break;
+ case SPDY4:
+ 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;
+ }
+ break;
+ }
+
+ LOG(DFATAL) << "Unhandled setting ID " << setting_id_field;
+ return SETTINGS_UPLOAD_BANDWIDTH;
+}
+
+int SpdyConstants::SerializeSettingId(SpdyMajorVersion version,
+ SpdySettingsIds id) {
+ switch (version) {
+ case SPDY2:
+ case SPDY3:
+ switch (id) {
+ case SETTINGS_UPLOAD_BANDWIDTH:
+ return 1;
+ case SETTINGS_DOWNLOAD_BANDWIDTH:
+ return 2;
+ case SETTINGS_ROUND_TRIP_TIME:
+ return 3;
+ case SETTINGS_MAX_CONCURRENT_STREAMS:
+ return 4;
+ case SETTINGS_CURRENT_CWND:
+ return 5;
+ case SETTINGS_DOWNLOAD_RETRANS_RATE:
+ return 6;
+ case SETTINGS_INITIAL_WINDOW_SIZE:
+ return 7;
+ default:
+ LOG(DFATAL) << "Serializing unhandled setting id " << id;
+ return -1;
+ }
+ case SPDY4:
+ switch (id) {
+ case SETTINGS_HEADER_TABLE_SIZE:
+ return 1;
+ case SETTINGS_ENABLE_PUSH:
+ return 2;
+ case SETTINGS_MAX_CONCURRENT_STREAMS:
+ return 3;
+ case SETTINGS_INITIAL_WINDOW_SIZE:
+ return 4;
+ default:
+ LOG(DFATAL) << "Serializing unhandled setting id " << id;
+ return -1;
+ }
+ }
+ LOG(DFATAL) << "Unhandled SPDY version " << version;
+ return -1;
}
void SpdyDataIR::Visit(SpdyFrameVisitor* visitor) const {
« 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