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 #include "net/spdy/spdy_framer.h" | 5 #include "net/spdy/spdy_framer.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
10 #include "base/third_party/valgrind/memcheck.h" | 10 #include "base/third_party/valgrind/memcheck.h" |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 current_frame_flags_ & | 967 current_frame_flags_ & |
968 ~(PUSH_PROMISE_FLAG_END_PUSH_PROMISE | | 968 ~(PUSH_PROMISE_FLAG_END_PUSH_PROMISE | |
969 HEADERS_FLAG_PAD_LOW | HEADERS_FLAG_PAD_HIGH)) { | 969 HEADERS_FLAG_PAD_LOW | HEADERS_FLAG_PAD_HIGH)) { |
970 set_error(SPDY_INVALID_CONTROL_FRAME_FLAGS); | 970 set_error(SPDY_INVALID_CONTROL_FRAME_FLAGS); |
971 } | 971 } |
972 break; | 972 break; |
973 case CONTINUATION: | 973 case CONTINUATION: |
974 if (current_frame_length_ < GetContinuationMinimumSize() || | 974 if (current_frame_length_ < GetContinuationMinimumSize() || |
975 protocol_version() <= SPDY3) { | 975 protocol_version() <= SPDY3) { |
976 set_error(SPDY_INVALID_CONTROL_FRAME); | 976 set_error(SPDY_INVALID_CONTROL_FRAME); |
977 } else if (current_frame_flags_ & | 977 } else if (current_frame_flags_ & ~HEADERS_FLAG_END_HEADERS) { |
978 ~(HEADERS_FLAG_END_HEADERS | HEADERS_FLAG_PAD_LOW | | |
979 HEADERS_FLAG_PAD_HIGH)) { | |
980 set_error(SPDY_INVALID_CONTROL_FRAME_FLAGS); | 978 set_error(SPDY_INVALID_CONTROL_FRAME_FLAGS); |
981 } | 979 } |
982 break; | 980 break; |
983 case ALTSVC: | 981 case ALTSVC: |
984 if (current_frame_length_ <= GetAltSvcMinimumSize()) { | 982 if (current_frame_length_ <= GetAltSvcMinimumSize()) { |
985 set_error(SPDY_INVALID_CONTROL_FRAME); | 983 set_error(SPDY_INVALID_CONTROL_FRAME); |
986 } else if (current_frame_flags_ != 0) { | 984 } else if (current_frame_flags_ != 0) { |
987 set_error(SPDY_INVALID_CONTROL_FRAME_FLAGS); | 985 set_error(SPDY_INVALID_CONTROL_FRAME_FLAGS); |
988 } | 986 } |
989 break; | 987 break; |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 if (debug_visitor_) { | 1509 if (debug_visitor_) { |
1512 debug_visitor_->OnReceiveCompressedFrame( | 1510 debug_visitor_->OnReceiveCompressedFrame( |
1513 current_frame_stream_id_, | 1511 current_frame_stream_id_, |
1514 current_frame_type_, | 1512 current_frame_type_, |
1515 current_frame_length_); | 1513 current_frame_length_); |
1516 } | 1514 } |
1517 visitor_->OnContinuation(current_frame_stream_id_, | 1515 visitor_->OnContinuation(current_frame_stream_id_, |
1518 (current_frame_flags_ & | 1516 (current_frame_flags_ & |
1519 HEADERS_FLAG_END_HEADERS) != 0); | 1517 HEADERS_FLAG_END_HEADERS) != 0); |
1520 } | 1518 } |
1521 CHANGE_STATE(SPDY_READ_PADDING_LENGTH); | 1519 CHANGE_STATE(SPDY_CONTROL_FRAME_HEADER_BLOCK); |
1522 break; | 1520 break; |
1523 default: | 1521 default: |
1524 DCHECK(false); | 1522 DCHECK(false); |
1525 } | 1523 } |
1526 } | 1524 } |
1527 return original_len - len; | 1525 return original_len - len; |
1528 } | 1526 } |
1529 | 1527 |
1530 // Does not buffer the control payload. Instead, either passes directly to the | 1528 // Does not buffer the control payload. Instead, either passes directly to the |
1531 // visitor or decompresses and then passes directly to the visitor, via | 1529 // visitor or decompresses and then passes directly to the visitor, via |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 if (remaining_padding_length_fields_ == 0) { | 2114 if (remaining_padding_length_fields_ == 0) { |
2117 if (remaining_padding_payload_length_ > remaining_data_length_) { | 2115 if (remaining_padding_payload_length_ > remaining_data_length_) { |
2118 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); | 2116 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); |
2119 return 0; | 2117 return 0; |
2120 } | 2118 } |
2121 if (current_frame_type_ == DATA) { | 2119 if (current_frame_type_ == DATA) { |
2122 CHANGE_STATE(SPDY_FORWARD_STREAM_FRAME); | 2120 CHANGE_STATE(SPDY_FORWARD_STREAM_FRAME); |
2123 } else { | 2121 } else { |
2124 DCHECK(current_frame_type_ == HEADERS || | 2122 DCHECK(current_frame_type_ == HEADERS || |
2125 current_frame_type_ == PUSH_PROMISE || | 2123 current_frame_type_ == PUSH_PROMISE || |
2126 current_frame_type_ == CONTINUATION || | |
2127 current_frame_type_ == SYN_STREAM || | 2124 current_frame_type_ == SYN_STREAM || |
2128 current_frame_type_ == SYN_REPLY) | 2125 current_frame_type_ == SYN_REPLY) |
2129 << current_frame_type_; | 2126 << current_frame_type_; |
2130 CHANGE_STATE(SPDY_CONTROL_FRAME_HEADER_BLOCK); | 2127 CHANGE_STATE(SPDY_CONTROL_FRAME_HEADER_BLOCK); |
2131 } | 2128 } |
2132 } | 2129 } |
2133 return original_len - len; | 2130 return original_len - len; |
2134 } | 2131 } |
2135 | 2132 |
2136 size_t SpdyFramer::ProcessFramePadding(const char* data, size_t len) { | 2133 size_t SpdyFramer::ProcessFramePadding(const char* data, size_t len) { |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3226 builder->Seek(compressed_size); | 3223 builder->Seek(compressed_size); |
3227 builder->RewriteLength(*this); | 3224 builder->RewriteLength(*this); |
3228 | 3225 |
3229 pre_compress_bytes.Add(uncompressed_len); | 3226 pre_compress_bytes.Add(uncompressed_len); |
3230 post_compress_bytes.Add(compressed_size); | 3227 post_compress_bytes.Add(compressed_size); |
3231 | 3228 |
3232 compressed_frames.Increment(); | 3229 compressed_frames.Increment(); |
3233 } | 3230 } |
3234 | 3231 |
3235 } // namespace net | 3232 } // namespace net |
OLD | NEW |