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

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

Issue 959743002: Account for HTTP/2 padding in receive windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more mock implementation. Created 5 years, 9 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
« 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 #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 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (remaining_data_length_ < kPadLengthFieldSize) { 2158 if (remaining_data_length_ < kPadLengthFieldSize) {
2159 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); 2159 set_error(SPDY_INVALID_DATA_FRAME_FLAGS);
2160 return 0; 2160 return 0;
2161 } 2161 }
2162 2162
2163 static_assert(kPadLengthFieldSize == 1,
2164 "Unexpected pad length field size.");
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 visitor_->OnStreamPadding(current_frame_stream_id_, kPadLengthFieldSize);
2167 } else { 2170 } else {
2168 // We don't have the data available for parsing the pad length field. Keep 2171 // We don't have the data available for parsing the pad length field. Keep
2169 // waiting. 2172 // waiting.
2170 return 0; 2173 return 0;
2171 } 2174 }
2172 } 2175 }
2173 2176
2174 if (remaining_padding_payload_length_ > remaining_data_length_) { 2177 if (remaining_padding_payload_length_ > remaining_data_length_) {
2175 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); 2178 set_error(SPDY_INVALID_DATA_FRAME_FLAGS);
2176 return 0; 2179 return 0;
2177 } 2180 }
2178 CHANGE_STATE(SPDY_FORWARD_STREAM_FRAME); 2181 CHANGE_STATE(SPDY_FORWARD_STREAM_FRAME);
2179 return original_len - len; 2182 return original_len - len;
2180 } 2183 }
2181 2184
2182 size_t SpdyFramer::ProcessFramePadding(const char* data, size_t len) { 2185 size_t SpdyFramer::ProcessFramePadding(const char* data, size_t len) {
2183 DCHECK_EQ(SPDY_CONSUME_PADDING, state_); 2186 DCHECK_EQ(SPDY_CONSUME_PADDING, state_);
2184 2187
2185 size_t original_len = len; 2188 size_t original_len = len;
2186 if (remaining_padding_payload_length_ > 0) { 2189 if (remaining_padding_payload_length_ > 0) {
2187 DCHECK_EQ(remaining_padding_payload_length_, remaining_data_length_); 2190 DCHECK_EQ(remaining_padding_payload_length_, remaining_data_length_);
2188 size_t amount_to_discard = std::min(remaining_padding_payload_length_, len); 2191 size_t amount_to_discard = std::min(remaining_padding_payload_length_, len);
2189 if (current_frame_type_ == DATA && amount_to_discard > 0) { 2192 if (current_frame_type_ == DATA && amount_to_discard > 0) {
2190 // The visitor needs to know about padding so it can send window updates. 2193 DCHECK_LE(SPDY4, protocol_version());
2191 // Communicate the padding to the visitor through a NULL data pointer, 2194 visitor_->OnStreamPadding(current_frame_stream_id_, amount_to_discard);
2192 // with a nonzero size.
2193 visitor_->OnStreamFrameData(
2194 current_frame_stream_id_, NULL, amount_to_discard, false);
2195 } 2195 }
2196 data += amount_to_discard; 2196 data += amount_to_discard;
2197 len -= amount_to_discard; 2197 len -= amount_to_discard;
2198 remaining_padding_payload_length_ -= amount_to_discard; 2198 remaining_padding_payload_length_ -= amount_to_discard;
2199 remaining_data_length_ -= amount_to_discard; 2199 remaining_data_length_ -= amount_to_discard;
2200 } 2200 }
2201 2201
2202 if (remaining_data_length_ == 0) { 2202 if (remaining_data_length_ == 0) {
2203 // If the FIN flag is set, or this ends a header block which set FIN, 2203 // If the FIN flag is set, or this ends a header block which set FIN,
2204 // inform the visitor of EOF via a 0-length data frame. 2204 // inform the visitor of EOF via a 0-length data frame.
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 #else 3279 #else
3280 WriteHeaderBlockToZ(&frame.name_value_block(), compressor); 3280 WriteHeaderBlockToZ(&frame.name_value_block(), compressor);
3281 #endif // defined(USE_SYSTEM_ZLIB) 3281 #endif // defined(USE_SYSTEM_ZLIB)
3282 3282
3283 int compressed_size = compressed_max_size - compressor->avail_out; 3283 int compressed_size = compressed_max_size - compressor->avail_out;
3284 builder->Seek(compressed_size); 3284 builder->Seek(compressed_size);
3285 builder->RewriteLength(*this); 3285 builder->RewriteLength(*this);
3286 } 3286 }
3287 3287
3288 } // namespace net 3288 } // 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