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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 case RST_STREAM_FLOW_CONTROL_ERROR: | 431 case RST_STREAM_FLOW_CONTROL_ERROR: |
432 return "FLOW_CONTROL_ERROR"; | 432 return "FLOW_CONTROL_ERROR"; |
433 case RST_STREAM_STREAM_IN_USE: | 433 case RST_STREAM_STREAM_IN_USE: |
434 return "STREAM_IN_USE"; | 434 return "STREAM_IN_USE"; |
435 case RST_STREAM_STREAM_ALREADY_CLOSED: | 435 case RST_STREAM_STREAM_ALREADY_CLOSED: |
436 return "STREAM_ALREADY_CLOSED"; | 436 return "STREAM_ALREADY_CLOSED"; |
437 case RST_STREAM_INVALID_CREDENTIALS: | 437 case RST_STREAM_INVALID_CREDENTIALS: |
438 return "INVALID_CREDENTIALS"; | 438 return "INVALID_CREDENTIALS"; |
439 case RST_STREAM_FRAME_TOO_LARGE: | 439 case RST_STREAM_FRAME_TOO_LARGE: |
440 return "FRAME_TOO_LARGE"; | 440 return "FRAME_TOO_LARGE"; |
| 441 case RST_STREAM_CONNECT_ERROR: |
| 442 return "CONNECT_ERROR"; |
| 443 case RST_STREAM_ENHANCE_YOUR_CALM: |
| 444 return "ENHANCE_YOUR_CALM"; |
441 } | 445 } |
442 return "UNKNOWN_STATUS"; | 446 return "UNKNOWN_STATUS"; |
443 } | 447 } |
444 | 448 |
445 const char* SpdyFramer::FrameTypeToString(SpdyFrameType type) { | 449 const char* SpdyFramer::FrameTypeToString(SpdyFrameType type) { |
446 switch (type) { | 450 switch (type) { |
447 case DATA: | 451 case DATA: |
448 return "DATA"; | 452 return "DATA"; |
449 case SYN_STREAM: | 453 case SYN_STREAM: |
450 return "SYN_STREAM"; | 454 return "SYN_STREAM"; |
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 reader.Seek(GetControlFrameHeaderSize()); // Seek past frame header. | 1813 reader.Seek(GetControlFrameHeaderSize()); // Seek past frame header. |
1810 if (protocol_version() <= SPDY3) { | 1814 if (protocol_version() <= SPDY3) { |
1811 bool successful_read = reader.ReadUInt31(¤t_frame_stream_id_); | 1815 bool successful_read = reader.ReadUInt31(¤t_frame_stream_id_); |
1812 DCHECK(successful_read); | 1816 DCHECK(successful_read); |
1813 } | 1817 } |
1814 | 1818 |
1815 SpdyRstStreamStatus status = RST_STREAM_INVALID; | 1819 SpdyRstStreamStatus status = RST_STREAM_INVALID; |
1816 uint32 status_raw = status; | 1820 uint32 status_raw = status; |
1817 bool successful_read = reader.ReadUInt32(&status_raw); | 1821 bool successful_read = reader.ReadUInt32(&status_raw); |
1818 DCHECK(successful_read); | 1822 DCHECK(successful_read); |
1819 // We've read an unsigned integer, so it's enough to only check | 1823 if (SpdyConstants::IsValidRstStreamStatus(protocol_version(), |
1820 // upper bound to ensure the value is in valid range. | 1824 status_raw)) { |
1821 if (status_raw > RST_STREAM_INVALID && | |
1822 status_raw < RST_STREAM_NUM_STATUS_CODES) { | |
1823 status = static_cast<SpdyRstStreamStatus>(status_raw); | 1825 status = static_cast<SpdyRstStreamStatus>(status_raw); |
1824 } else { | 1826 } else { |
1825 // TODO(hkhalil): Probably best to OnError here, depending on | 1827 // TODO(hkhalil): Probably best to OnError here, depending on |
1826 // our interpretation of the spec. Keeping with existing liberal | 1828 // our interpretation of the spec. Keeping with existing liberal |
1827 // behavior for now. | 1829 // behavior for now. |
1828 } | 1830 } |
1829 // Finished parsing the RST_STREAM header, call frame handler. | 1831 // Finished parsing the RST_STREAM header, call frame handler. |
1830 visitor_->OnRstStream(current_frame_stream_id_, status); | 1832 visitor_->OnRstStream(current_frame_stream_id_, status); |
1831 } | 1833 } |
1832 } | 1834 } |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2841 builder->Seek(compressed_size); | 2843 builder->Seek(compressed_size); |
2842 builder->RewriteLength(*this); | 2844 builder->RewriteLength(*this); |
2843 | 2845 |
2844 pre_compress_bytes.Add(uncompressed_len); | 2846 pre_compress_bytes.Add(uncompressed_len); |
2845 post_compress_bytes.Add(compressed_size); | 2847 post_compress_bytes.Add(compressed_size); |
2846 | 2848 |
2847 compressed_frames.Increment(); | 2849 compressed_frames.Increment(); |
2848 } | 2850 } |
2849 | 2851 |
2850 } // namespace net | 2852 } // namespace net |
OLD | NEW |