| OLD | NEW |
| 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 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 uint32 delta_window_size = 0; | 1201 uint32 delta_window_size = 0; |
| 1202 bool successful_read = reader.ReadUInt31(&stream_id); | 1202 bool successful_read = reader.ReadUInt31(&stream_id); |
| 1203 DCHECK(successful_read); | 1203 DCHECK(successful_read); |
| 1204 successful_read = reader.ReadUInt32(&delta_window_size); | 1204 successful_read = reader.ReadUInt32(&delta_window_size); |
| 1205 DCHECK(successful_read); | 1205 DCHECK(successful_read); |
| 1206 DCHECK(reader.IsDoneReading()); | 1206 DCHECK(reader.IsDoneReading()); |
| 1207 visitor_->OnWindowUpdate(stream_id, delta_window_size); | 1207 visitor_->OnWindowUpdate(stream_id, delta_window_size); |
| 1208 } | 1208 } |
| 1209 break; | 1209 break; |
| 1210 case RST_STREAM: { | 1210 case RST_STREAM: { |
| 1211 SpdyRstStreamControlFrame* rst_stream_frame = | 1211 SpdyFrameReader reader(current_frame_buffer_.get(), |
| 1212 reinterpret_cast<SpdyRstStreamControlFrame*>(&control_frame); | 1212 current_frame_len_); |
| 1213 visitor_->OnRstStream(rst_stream_frame->stream_id(), | 1213 reader.Seek(GetControlFrameMinimumSize()); // Skip frame header. |
| 1214 rst_stream_frame->status()); | 1214 SpdyStreamId stream_id = kInvalidStream; |
| 1215 bool successful_read = reader.ReadUInt32(&stream_id); |
| 1216 DCHECK(successful_read); |
| 1217 SpdyRstStreamStatus status = RST_STREAM_INVALID; |
| 1218 uint32 status_raw = status; |
| 1219 successful_read = reader.ReadUInt32(&status_raw); |
| 1220 DCHECK(successful_read); |
| 1221 if (status_raw > RST_STREAM_INVALID && |
| 1222 status_raw < RST_STREAM_NUM_STATUS_CODES) { |
| 1223 status = static_cast<SpdyRstStreamStatus>(status_raw); |
| 1224 } else { |
| 1225 // TODO(hkhalil): Probably best to OnError here, depending on |
| 1226 // our interpretation of the spec. Keeping with existing liberal |
| 1227 // behavior for now. |
| 1228 } |
| 1229 DCHECK(reader.IsDoneReading()); |
| 1230 visitor_->OnRstStream(stream_id, status); |
| 1215 } | 1231 } |
| 1216 break; | 1232 break; |
| 1217 case GOAWAY: { | 1233 case GOAWAY: { |
| 1218 SpdyFrameReader reader(current_frame_buffer_.get(), | 1234 SpdyFrameReader reader(current_frame_buffer_.get(), |
| 1219 current_frame_len_); | 1235 current_frame_len_); |
| 1220 reader.Seek(GetControlFrameMinimumSize()); // Skip frame header. | 1236 reader.Seek(GetControlFrameMinimumSize()); // Skip frame header. |
| 1221 SpdyStreamId last_accepted_stream_id = kInvalidStream; | 1237 SpdyStreamId last_accepted_stream_id = kInvalidStream; |
| 1222 bool successful_read = reader.ReadUInt31(&last_accepted_stream_id); | 1238 bool successful_read = reader.ReadUInt31(&last_accepted_stream_id); |
| 1223 DCHECK(successful_read); | 1239 DCHECK(successful_read); |
| 1224 SpdyGoAwayStatus status = GOAWAY_OK; | 1240 SpdyGoAwayStatus status = GOAWAY_OK; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 builder.WriteUInt32(syn_reply.stream_id()); | 1520 builder.WriteUInt32(syn_reply.stream_id()); |
| 1505 if (protocol_version() < 3) { | 1521 if (protocol_version() < 3) { |
| 1506 builder.WriteUInt16(0); // Unused. | 1522 builder.WriteUInt16(0); // Unused. |
| 1507 } | 1523 } |
| 1508 DCHECK_EQ(GetSynReplyMinimumSize(), builder.length()); | 1524 DCHECK_EQ(GetSynReplyMinimumSize(), builder.length()); |
| 1509 SerializeNameValueBlock(&builder, syn_reply); | 1525 SerializeNameValueBlock(&builder, syn_reply); |
| 1510 | 1526 |
| 1511 return builder.take(); | 1527 return builder.take(); |
| 1512 } | 1528 } |
| 1513 | 1529 |
| 1514 SpdyRstStreamControlFrame* SpdyFramer::CreateRstStream( | 1530 SpdyFrame* SpdyFramer::CreateRstStream( |
| 1515 SpdyStreamId stream_id, | 1531 SpdyStreamId stream_id, |
| 1516 SpdyRstStreamStatus status) const { | 1532 SpdyRstStreamStatus status) const { |
| 1517 SpdyRstStreamIR rst_stream(stream_id, status); | 1533 SpdyRstStreamIR rst_stream(stream_id, status); |
| 1518 return reinterpret_cast<SpdyRstStreamControlFrame*>( | 1534 return SerializeRstStream(rst_stream); |
| 1519 SerializeRstStream(rst_stream)); | |
| 1520 } | 1535 } |
| 1521 | 1536 |
| 1522 SpdySerializedFrame* SpdyFramer::SerializeRstStream( | 1537 SpdySerializedFrame* SpdyFramer::SerializeRstStream( |
| 1523 const SpdyRstStreamIR& rst_stream) const { | 1538 const SpdyRstStreamIR& rst_stream) const { |
| 1524 SpdyFrameBuilder builder(RST_STREAM, | 1539 SpdyFrameBuilder builder(RST_STREAM, |
| 1525 kNoFlags, | 1540 kNoFlags, |
| 1526 protocol_version(), | 1541 protocol_version(), |
| 1527 GetRstStreamSize()); | 1542 GetRstStreamSize()); |
| 1528 builder.WriteUInt32(rst_stream.stream_id()); | 1543 builder.WriteUInt32(rst_stream.stream_id()); |
| 1529 builder.WriteUInt32(rst_stream.status()); | 1544 builder.WriteUInt32(rst_stream.status()); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2071 builder->WriteString(it->first); | 2086 builder->WriteString(it->first); |
| 2072 builder->WriteString(it->second); | 2087 builder->WriteString(it->second); |
| 2073 } else { | 2088 } else { |
| 2074 builder->WriteStringPiece32(it->first); | 2089 builder->WriteStringPiece32(it->first); |
| 2075 builder->WriteStringPiece32(it->second); | 2090 builder->WriteStringPiece32(it->second); |
| 2076 } | 2091 } |
| 2077 } | 2092 } |
| 2078 } | 2093 } |
| 2079 | 2094 |
| 2080 } // namespace net | 2095 } // namespace net |
| OLD | NEW |