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

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

Issue 12259004: Remove SpdyPingControlFrame struct. Useful for SPDY 4 development. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 size_t bytes_read = UpdateCurrentFrameBuffer(&data, &len, 1176 size_t bytes_read = UpdateCurrentFrameBuffer(&data, &len,
1177 remaining_control_payload_); 1177 remaining_control_payload_);
1178 remaining_control_payload_ -= bytes_read; 1178 remaining_control_payload_ -= bytes_read;
1179 remaining_data_ -= bytes_read; 1179 remaining_data_ -= bytes_read;
1180 if (remaining_control_payload_ == 0) { 1180 if (remaining_control_payload_ == 0) {
1181 SpdyControlFrame control_frame(current_frame_buffer_.get(), false); 1181 SpdyControlFrame control_frame(current_frame_buffer_.get(), false);
1182 DCHECK(!control_frame.has_header_block()); 1182 DCHECK(!control_frame.has_header_block());
1183 // Use frame-specific handlers. 1183 // Use frame-specific handlers.
1184 switch (control_frame.type()) { 1184 switch (control_frame.type()) {
1185 case PING: { 1185 case PING: {
1186 SpdyPingControlFrame* ping_frame = 1186 SpdyFrameReader reader(current_frame_buffer_.get(),
1187 reinterpret_cast<SpdyPingControlFrame*>(&control_frame); 1187 current_frame_len_);
1188 visitor_->OnPing(ping_frame->unique_id()); 1188 reader.Seek(GetControlFrameMinimumSize()); // Skip frame header.
1189 SpdyPingId id = 0;
1190 bool successful_read = reader.ReadUInt32(&id);
1191 DCHECK(successful_read);
1192 DCHECK(reader.IsDoneReading());
1193 visitor_->OnPing(id);
1189 } 1194 }
1190 break; 1195 break;
1191 case WINDOW_UPDATE: { 1196 case WINDOW_UPDATE: {
1192 SpdyFrameReader reader(current_frame_buffer_.get(), 1197 SpdyFrameReader reader(current_frame_buffer_.get(),
1193 current_frame_len_); 1198 current_frame_len_);
1194 reader.Seek(SpdyFrame::kHeaderSize); // Seek past frame header. 1199 reader.Seek(SpdyFrame::kHeaderSize); // Seek past frame header.
1195 SpdyStreamId stream_id = kInvalidStream; 1200 SpdyStreamId stream_id = kInvalidStream;
1196 uint32 delta_window_size = 0; 1201 uint32 delta_window_size = 0;
1197 bool successful_read = reader.ReadUInt31(&stream_id); 1202 bool successful_read = reader.ReadUInt31(&stream_id);
1198 DCHECK(successful_read); 1203 DCHECK(successful_read);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 } 1572 }
1568 SettingsFlagsAndId flags_and_id(setting_flags, it->first); 1573 SettingsFlagsAndId flags_and_id(setting_flags, it->first);
1569 uint32 id_and_flags_wire = flags_and_id.GetWireFormat(protocol_version()); 1574 uint32 id_and_flags_wire = flags_and_id.GetWireFormat(protocol_version());
1570 builder.WriteBytes(&id_and_flags_wire, 4); 1575 builder.WriteBytes(&id_and_flags_wire, 4);
1571 builder.WriteUInt32(it->second.value); 1576 builder.WriteUInt32(it->second.value);
1572 } 1577 }
1573 DCHECK_EQ(size, builder.length()); 1578 DCHECK_EQ(size, builder.length());
1574 return builder.take(); 1579 return builder.take();
1575 } 1580 }
1576 1581
1577 SpdyPingControlFrame* SpdyFramer::CreatePingFrame(uint32 unique_id) const { 1582 SpdyFrame* SpdyFramer::CreatePingFrame(uint32 unique_id) const {
1578 SpdyPingIR ping(unique_id); 1583 SpdyPingIR ping(unique_id);
1579 return reinterpret_cast<SpdyPingControlFrame*>(SerializePing(ping)); 1584 return SerializePing(ping);
1580 } 1585 }
1581 1586
1582 SpdySerializedFrame* SpdyFramer::SerializePing(const SpdyPingIR& ping) const { 1587 SpdySerializedFrame* SpdyFramer::SerializePing(const SpdyPingIR& ping) const {
1583 SpdyFrameBuilder builder(PING, 0, protocol_version(), GetPingSize()); 1588 SpdyFrameBuilder builder(PING, 0, protocol_version(), GetPingSize());
1584 builder.WriteUInt32(ping.id()); 1589 builder.WriteUInt32(ping.id());
1585 DCHECK_EQ(GetPingSize(), builder.length()); 1590 DCHECK_EQ(GetPingSize(), builder.length());
1586 return builder.take(); 1591 return builder.take();
1587 } 1592 }
1588 1593
1589 SpdyFrame* SpdyFramer::CreateGoAway( 1594 SpdyFrame* SpdyFramer::CreateGoAway(
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 builder->WriteString(it->first); 2071 builder->WriteString(it->first);
2067 builder->WriteString(it->second); 2072 builder->WriteString(it->second);
2068 } else { 2073 } else {
2069 builder->WriteStringPiece32(it->first); 2074 builder->WriteStringPiece32(it->first);
2070 builder->WriteStringPiece32(it->second); 2075 builder->WriteStringPiece32(it->second);
2071 } 2076 }
2072 } 2077 }
2073 } 2078 }
2074 2079
2075 } // namespace net 2080 } // namespace net
OLDNEW
« 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