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

Unified Diff: net/spdy/spdy_framer.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_framer.h ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_framer.cc
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 970899da2694eef4e957a0aa43f5a5907bf57c6c..23080accd994ad2c6982d3e639fdaab2a1c28981 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -90,7 +90,7 @@ SettingsFlagsAndId SettingsFlagsAndId::FromWireFormat(int version,
SettingsFlagsAndId::SettingsFlagsAndId(uint8 flags, uint32 id)
: flags_(flags), id_(id & 0x00ffffff) {
- LOG_IF(DFATAL, id > (1u << 24)) << "SPDY setting ID too large.";
+ LOG_IF(DFATAL, id > (1u << 24)) << "SPDY setting ID too large: " << id;
}
uint32 SettingsFlagsAndId::GetWireFormat(int version) const {
@@ -1607,6 +1607,7 @@ void SpdyFramer::DeliverHpackBlockAsSpdy3Block() {
}
bool SpdyFramer::ProcessSetting(const char* data) {
+ int id_field;
SpdySettingsIds id;
uint8 flags = 0;
uint32 value;
@@ -1617,33 +1618,24 @@ bool SpdyFramer::ProcessSetting(const char* data) {
const uint32 id_and_flags_wire = *(reinterpret_cast<const uint32*>(data));
SettingsFlagsAndId id_and_flags =
SettingsFlagsAndId::FromWireFormat(protocol_version(), id_and_flags_wire);
- id = static_cast<SpdySettingsIds>(id_and_flags.id());
+ id_field = id_and_flags.id();
flags = id_and_flags.flags();
value = ntohl(*(reinterpret_cast<const uint32*>(data + 4)));
} else {
- id = static_cast<SpdySettingsIds>(*(reinterpret_cast<const uint8*>(data)));
+ id_field = *(reinterpret_cast<const uint8*>(data));
value = ntohl(*(reinterpret_cast<const uint32*>(data + 1)));
}
// Validate id.
- switch (id) {
- case SETTINGS_UPLOAD_BANDWIDTH:
- case SETTINGS_DOWNLOAD_BANDWIDTH:
- case SETTINGS_ROUND_TRIP_TIME:
- case SETTINGS_MAX_CONCURRENT_STREAMS:
- case SETTINGS_CURRENT_CWND:
- case SETTINGS_DOWNLOAD_RETRANS_RATE:
- case SETTINGS_INITIAL_WINDOW_SIZE:
- // Valid values.
- break;
- default:
- DLOG(WARNING) << "Unknown SETTINGS ID: " << id;
- return false;
+ if (!SpdyConstants::IsValidSettingId(protocol_version(), id_field)) {
+ DLOG(WARNING) << "Unknown SETTINGS ID: " << id_field;
+ return false;
}
+ id = SpdyConstants::ParseSettingId(protocol_version(), id_field);
if (protocol_version() <= SPDY3) {
// Detect duplicates.
- if (static_cast<uint32>(id) <= settings_scratch_.last_setting_id) {
+ if (id <= settings_scratch_.last_setting_id) {
DLOG(WARNING) << "Duplicate entry or invalid ordering for id " << id
<< " in " << display_protocol_ << " SETTINGS frame "
<< "(last setting id was "
@@ -2294,11 +2286,14 @@ SpdySerializedFrame* SpdyFramer::SerializeSettings(
if (it->second.persisted) {
setting_flags |= SETTINGS_FLAG_PERSISTED;
}
- SettingsFlagsAndId flags_and_id(setting_flags, it->first);
+ SettingsFlagsAndId flags_and_id(
+ setting_flags,
+ SpdyConstants::SerializeSettingId(protocol_version(), it->first));
uint32 id_and_flags_wire = flags_and_id.GetWireFormat(protocol_version());
builder.WriteBytes(&id_and_flags_wire, 4);
} else {
- builder.WriteUInt8(static_cast<uint8>(it->first));
+ builder.WriteUInt8(SpdyConstants::SerializeSettingId(protocol_version(),
+ it->first));
}
builder.WriteUInt32(it->second.value);
}
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698