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/third_party/valgrind/memcheck.h" | 9 #include "base/third_party/valgrind/memcheck.h" |
10 #include "net/spdy/spdy_frame_builder.h" | 10 #include "net/spdy/spdy_frame_builder.h" |
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2148 } | 2148 } |
2149 | 2149 |
2150 size_t SpdyFramer::ProcessDataFramePaddingLength(const char* data, size_t len) { | 2150 size_t SpdyFramer::ProcessDataFramePaddingLength(const char* data, size_t len) { |
2151 DCHECK_EQ(SPDY_READ_DATA_FRAME_PADDING_LENGTH, state_); | 2151 DCHECK_EQ(SPDY_READ_DATA_FRAME_PADDING_LENGTH, state_); |
2152 DCHECK_EQ(0u, remaining_padding_payload_length_); | 2152 DCHECK_EQ(0u, remaining_padding_payload_length_); |
2153 DCHECK_EQ(DATA, current_frame_type_); | 2153 DCHECK_EQ(DATA, current_frame_type_); |
2154 | 2154 |
2155 size_t original_len = len; | 2155 size_t original_len = len; |
2156 if (current_frame_flags_ & DATA_FLAG_PADDED) { | 2156 if (current_frame_flags_ & DATA_FLAG_PADDED) { |
2157 if (len != 0) { | 2157 if (len != 0) { |
2158 static_assert(kPadLengthFieldSize == 1, | |
2159 "Unexpected pad length field size."); | |
2158 if (remaining_data_length_ < kPadLengthFieldSize) { | 2160 if (remaining_data_length_ < kPadLengthFieldSize) { |
2159 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); | 2161 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); |
2160 return 0; | 2162 return 0; |
2161 } | 2163 } |
2162 | 2164 |
2163 remaining_padding_payload_length_ = *reinterpret_cast<const uint8*>(data); | 2165 remaining_padding_payload_length_ = *reinterpret_cast<const uint8*>(data); |
2164 ++data; | 2166 ++data; |
2165 --len; | 2167 --len; |
2166 --remaining_data_length_; | 2168 --remaining_data_length_; |
2169 | |
2170 // Notify visitor that |kPadLengthFieldSize| bytes of payload are | |
2171 // consumed. | |
2172 visitor_->OnStreamFrameData(current_frame_stream_id_, NULL, | |
2173 kPadLengthFieldSize, false); | |
Ryan Hamilton
2015/02/25 21:59:15
Should this change land internally first? In any c
| |
2167 } else { | 2174 } else { |
2168 // We don't have the data available for parsing the pad length field. Keep | 2175 // We don't have the data available for parsing the pad length field. Keep |
2169 // waiting. | 2176 // waiting. |
2170 return 0; | 2177 return 0; |
2171 } | 2178 } |
2172 } | 2179 } |
2173 | 2180 |
2174 if (remaining_padding_payload_length_ > remaining_data_length_) { | 2181 if (remaining_padding_payload_length_ > remaining_data_length_) { |
2175 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); | 2182 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); |
2176 return 0; | 2183 return 0; |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3277 #else | 3284 #else |
3278 WriteHeaderBlockToZ(&frame.name_value_block(), compressor); | 3285 WriteHeaderBlockToZ(&frame.name_value_block(), compressor); |
3279 #endif // defined(USE_SYSTEM_ZLIB) | 3286 #endif // defined(USE_SYSTEM_ZLIB) |
3280 | 3287 |
3281 int compressed_size = compressed_max_size - compressor->avail_out; | 3288 int compressed_size = compressed_max_size - compressor->avail_out; |
3282 builder->Seek(compressed_size); | 3289 builder->Seek(compressed_size); |
3283 builder->RewriteLength(*this); | 3290 builder->RewriteLength(*this); |
3284 } | 3291 } |
3285 | 3292 |
3286 } // namespace net | 3293 } // namespace net |
OLD | NEW |