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

Side by Side Diff: net/spdy/spdy_framer.cc

Issue 10054034: SPDY - replaced SpdySettings (list) with SettingsMap (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(rtenhove) clean up frame buffer size calculations so that we aren't 5 // TODO(rtenhove) clean up frame buffer size calculations so that we aren't
6 // constantly adding and subtracting header sizes; this is ugly and error- 6 // constantly adding and subtracting header sizes; this is ugly and error-
7 // prone. 7 // prone.
8 8
9 #include "net/spdy/spdy_framer.h" 9 #include "net/spdy/spdy_framer.h"
10 10
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 } 1004 }
1005 1005
1006 // Store header. 1006 // Store header.
1007 (*block)[name] = value; 1007 (*block)[name] = value;
1008 } 1008 }
1009 return true; 1009 return true;
1010 } 1010 }
1011 1011
1012 /* static */ 1012 /* static */
1013 bool SpdyFramer::ParseSettings(const SpdySettingsControlFrame* frame, 1013 bool SpdyFramer::ParseSettings(const SpdySettingsControlFrame* frame,
1014 SpdySettings* settings) { 1014 SettingsMap* settings) {
1015 DCHECK_EQ(frame->type(), SETTINGS); 1015 DCHECK_EQ(frame->type(), SETTINGS);
1016 DCHECK(settings);
Ryan Hamilton 2012/04/12 17:11:21 Did you mean to remove this DCHECK?
ramant (doing other things) 2012/04/12 18:35:59 (my fault. deleted it by mistake) Done.
1017 1016
1018 SpdyFrameReader parser(frame->header_block(), frame->header_block_len()); 1017 SpdyFrameReader parser(frame->header_block(), frame->header_block_len());
1019 for (size_t index = 0; index < frame->num_entries(); ++index) { 1018 for (size_t index = 0; index < frame->num_entries(); ++index) {
1020 uint32 id_and_flags_wire; 1019 uint32 id_and_flags_wire;
1021 uint32 value; 1020 uint32 value;
1022 // SettingsFlagsAndId accepts off-the-wire (network byte order) data, so we 1021 // SettingsFlagsAndId accepts off-the-wire (network byte order) data, so we
1023 // use ReadBytes() instead of ReadUInt32() as the latter calls ntohl(). 1022 // use ReadBytes() instead of ReadUInt32() as the latter calls ntohl().
1024 if (!parser.ReadBytes(&id_and_flags_wire, 4)) { 1023 if (!parser.ReadBytes(&id_and_flags_wire, 4)) {
1025 return false; 1024 return false;
1026 } 1025 }
1027 if (!parser.ReadUInt32(&value)) 1026 if (!parser.ReadUInt32(&value))
1028 return false; 1027 return false;
1029 SettingsFlagsAndId id_and_flags = 1028 SettingsFlagsAndId flags_and_id =
1030 SettingsFlagsAndId::FromWireFormat(frame->version(), id_and_flags_wire); 1029 SettingsFlagsAndId::FromWireFormat(frame->version(), id_and_flags_wire);
1031 settings->insert(settings->end(), std::make_pair(id_and_flags, value)); 1030 SpdySettingsIds id = static_cast<SpdySettingsIds>(flags_and_id.id());
1031 SpdySettingsFlags flags =
1032 static_cast<SpdySettingsFlags>(flags_and_id.flags());
1033 settings->insert(std::make_pair(id, SettingsFlagsAndValue(flags, value)));
1032 } 1034 }
1033 return true; 1035 return true;
1034 } 1036 }
1035 1037
1036 /* static */ 1038 /* static */
1037 bool SpdyFramer::ParseCredentialData(const char* data, size_t len, 1039 bool SpdyFramer::ParseCredentialData(const char* data, size_t len,
1038 SpdyCredential* credential) { 1040 SpdyCredential* credential) {
1039 DCHECK(credential); 1041 DCHECK(credential);
1040 1042
1041 SpdyFrameReader parser(data, len); 1043 SpdyFrameReader parser(data, len);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 SpdyFrameBuilder frame(SpdyRstStreamControlFrame::size()); 1158 SpdyFrameBuilder frame(SpdyRstStreamControlFrame::size());
1157 frame.WriteUInt16(kControlFlagMask | spdy_version_); 1159 frame.WriteUInt16(kControlFlagMask | spdy_version_);
1158 frame.WriteUInt16(RST_STREAM); 1160 frame.WriteUInt16(RST_STREAM);
1159 frame.WriteUInt32(8); 1161 frame.WriteUInt32(8);
1160 frame.WriteUInt32(stream_id); 1162 frame.WriteUInt32(stream_id);
1161 frame.WriteUInt32(status); 1163 frame.WriteUInt32(status);
1162 return reinterpret_cast<SpdyRstStreamControlFrame*>(frame.take()); 1164 return reinterpret_cast<SpdyRstStreamControlFrame*>(frame.take());
1163 } 1165 }
1164 1166
1165 SpdySettingsControlFrame* SpdyFramer::CreateSettings( 1167 SpdySettingsControlFrame* SpdyFramer::CreateSettings(
1166 const SpdySettings& values) const { 1168 const SettingsMap& values) const {
1167 SpdyFrameBuilder frame(SpdySettingsControlFrame::size() + 8 * values.size()); 1169 SpdyFrameBuilder frame(SpdySettingsControlFrame::size() + 8 * values.size());
1168 frame.WriteUInt16(kControlFlagMask | spdy_version_); 1170 frame.WriteUInt16(kControlFlagMask | spdy_version_);
1169 frame.WriteUInt16(SETTINGS); 1171 frame.WriteUInt16(SETTINGS);
1170 size_t settings_size = 1172 size_t settings_size =
1171 SpdySettingsControlFrame::size() - SpdyFrame::kHeaderSize + 1173 SpdySettingsControlFrame::size() - SpdyFrame::kHeaderSize +
1172 8 * values.size(); 1174 8 * values.size();
1173 frame.WriteUInt32(settings_size); 1175 frame.WriteUInt32(settings_size);
1174 frame.WriteUInt32(values.size()); 1176 frame.WriteUInt32(values.size());
1175 SpdySettings::const_iterator it = values.begin(); 1177 SettingsMap::const_iterator it = values.begin();
1176 while (it != values.end()) { 1178 while (it != values.end()) {
1177 uint32 id_and_flags_wire = it->first.GetWireFormat(spdy_version_); 1179 SettingsFlagsAndId flags_and_id(it->second.first, it->first);
1180 uint32 id_and_flags_wire = flags_and_id.GetWireFormat(spdy_version_);
1178 frame.WriteBytes(&id_and_flags_wire, 4); 1181 frame.WriteBytes(&id_and_flags_wire, 4);
1179 frame.WriteUInt32(it->second); 1182 frame.WriteUInt32(it->second.second);
1180 ++it; 1183 ++it;
1181 } 1184 }
1182 return reinterpret_cast<SpdySettingsControlFrame*>(frame.take()); 1185 return reinterpret_cast<SpdySettingsControlFrame*>(frame.take());
1183 } 1186 }
1184 1187
1185 SpdyPingControlFrame* SpdyFramer::CreatePingFrame(uint32 unique_id) const { 1188 SpdyPingControlFrame* SpdyFramer::CreatePingFrame(uint32 unique_id) const {
1186 SpdyFrameBuilder frame(SpdyPingControlFrame::size()); 1189 SpdyFrameBuilder frame(SpdyPingControlFrame::size());
1187 frame.WriteUInt16(kControlFlagMask | spdy_version_); 1190 frame.WriteUInt16(kControlFlagMask | spdy_version_);
1188 frame.WriteUInt16(PING); 1191 frame.WriteUInt16(PING);
1189 size_t ping_size = SpdyPingControlFrame::size() - SpdyFrame::kHeaderSize; 1192 size_t ping_size = SpdyPingControlFrame::size() - SpdyFrame::kHeaderSize;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 1805
1803 void SpdyFramer::set_validate_control_frame_sizes(bool value) { 1806 void SpdyFramer::set_validate_control_frame_sizes(bool value) {
1804 validate_control_frame_sizes_ = value; 1807 validate_control_frame_sizes_ = value;
1805 } 1808 }
1806 1809
1807 void SpdyFramer::set_enable_compression_default(bool value) { 1810 void SpdyFramer::set_enable_compression_default(bool value) {
1808 g_enable_compression_default = value; 1811 g_enable_compression_default = value;
1809 } 1812 }
1810 1813
1811 } // namespace net 1814 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698