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

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

Issue 1918953003: Landing Recent QUIC changes until 4/22/2016 14:55 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Deleted SpdyFramerTests missed while mergeing 120451808 Created 4 years, 8 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 <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <ios> 10 #include <ios>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 SpdyFramer::SpdyFramer(SpdyMajorVersion version) 168 SpdyFramer::SpdyFramer(SpdyMajorVersion version)
169 : current_frame_buffer_(kControlFrameBufferSize), 169 : current_frame_buffer_(kControlFrameBufferSize),
170 expect_continuation_(0), 170 expect_continuation_(0),
171 visitor_(NULL), 171 visitor_(NULL),
172 debug_visitor_(NULL), 172 debug_visitor_(NULL),
173 display_protocol_("SPDY"), 173 display_protocol_("SPDY"),
174 protocol_version_(version), 174 protocol_version_(version),
175 enable_compression_(true), 175 enable_compression_(true),
176 syn_frame_processed_(false), 176 syn_frame_processed_(false),
177 probable_http_response_(false), 177 probable_http_response_(false),
178 end_stream_when_done_(false), 178 end_stream_when_done_(false) {
179 spdy_on_stream_end_(FLAGS_spdy_on_stream_end) {
180 DCHECK(protocol_version_ == SPDY3 || protocol_version_ == HTTP2); 179 DCHECK(protocol_version_ == SPDY3 || protocol_version_ == HTTP2);
181 // TODO(bnc): The way kMaxControlFrameSize is currently interpreted, it 180 // TODO(bnc): The way kMaxControlFrameSize is currently interpreted, it
182 // includes the frame header, whereas kSpdyInitialFrameSizeLimit does not. 181 // includes the frame header, whereas kSpdyInitialFrameSizeLimit does not.
183 // Therefore this assertion is unnecessarily strict. 182 // Therefore this assertion is unnecessarily strict.
184 static_assert(kMaxControlFrameSize <= kSpdyInitialFrameSizeLimit, 183 static_assert(kMaxControlFrameSize <= kSpdyInitialFrameSizeLimit,
185 "Our send limit should be at most our receive limit"); 184 "Our send limit should be at most our receive limit");
186 Reset(); 185 Reset();
187 } 186 }
188 187
189 SpdyFramer::~SpdyFramer() { 188 SpdyFramer::~SpdyFramer() {
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 set_error(SPDY_INVALID_DATA_FRAME_FLAGS); 886 set_error(SPDY_INVALID_DATA_FRAME_FLAGS);
888 } else { 887 } else {
889 visitor_->OnDataFrameHeader(current_frame_stream_id_, 888 visitor_->OnDataFrameHeader(current_frame_stream_id_,
890 remaining_data_length_, 889 remaining_data_length_,
891 current_frame_flags_ & DATA_FLAG_FIN); 890 current_frame_flags_ & DATA_FLAG_FIN);
892 if (remaining_data_length_ > 0) { 891 if (remaining_data_length_ > 0) {
893 CHANGE_STATE(SPDY_READ_DATA_FRAME_PADDING_LENGTH); 892 CHANGE_STATE(SPDY_READ_DATA_FRAME_PADDING_LENGTH);
894 } else { 893 } else {
895 // Empty data frame. 894 // Empty data frame.
896 if (current_frame_flags_ & DATA_FLAG_FIN) { 895 if (current_frame_flags_ & DATA_FLAG_FIN) {
897 if (spdy_on_stream_end_) { 896 visitor_->OnStreamEnd(current_frame_stream_id_);
898 visitor_->OnStreamEnd(current_frame_stream_id_);
899 } else {
900 visitor_->OnStreamFrameData(current_frame_stream_id_, nullptr, 0,
901 true);
902 }
903 } 897 }
904 CHANGE_STATE(SPDY_FRAME_COMPLETE); 898 CHANGE_STATE(SPDY_FRAME_COMPLETE);
905 } 899 }
906 } 900 }
907 } else { 901 } else {
908 ProcessControlFrameHeader(control_frame_type_field); 902 ProcessControlFrameHeader(control_frame_type_field);
909 } 903 }
910 904
911 return original_len - len; 905 return original_len - len;
912 } 906 }
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 remaining_data_length_ -= amount_to_discard; 2159 remaining_data_length_ -= amount_to_discard;
2166 } 2160 }
2167 2161
2168 if (remaining_data_length_ == 0) { 2162 if (remaining_data_length_ == 0) {
2169 // If the FIN flag is set, or this ends a header block which set FIN, 2163 // If the FIN flag is set, or this ends a header block which set FIN,
2170 // inform the visitor of EOF via a 0-length data frame. 2164 // inform the visitor of EOF via a 0-length data frame.
2171 if (expect_continuation_ == 0 && 2165 if (expect_continuation_ == 0 &&
2172 ((current_frame_flags_ & CONTROL_FLAG_FIN) != 0 || 2166 ((current_frame_flags_ & CONTROL_FLAG_FIN) != 0 ||
2173 end_stream_when_done_)) { 2167 end_stream_when_done_)) {
2174 end_stream_when_done_ = false; 2168 end_stream_when_done_ = false;
2175 if (spdy_on_stream_end_) { 2169 visitor_->OnStreamEnd(current_frame_stream_id_);
2176 visitor_->OnStreamEnd(current_frame_stream_id_);
2177 } else {
2178 visitor_->OnStreamFrameData(current_frame_stream_id_, nullptr, 0, true);
2179 }
2180 } 2170 }
2181 CHANGE_STATE(SPDY_FRAME_COMPLETE); 2171 CHANGE_STATE(SPDY_FRAME_COMPLETE);
2182 } 2172 }
2183 return original_len - len; 2173 return original_len - len;
2184 } 2174 }
2185 2175
2186 size_t SpdyFramer::ProcessDataFramePayload(const char* data, size_t len) { 2176 size_t SpdyFramer::ProcessDataFramePayload(const char* data, size_t len) {
2187 size_t original_len = len; 2177 size_t original_len = len;
2188 if (remaining_data_length_ - remaining_padding_payload_length_ > 0) { 2178 if (remaining_data_length_ - remaining_padding_payload_length_ > 0) {
2189 size_t amount_to_forward = std::min( 2179 size_t amount_to_forward = std::min(
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
3203 #else 3193 #else
3204 WriteHeaderBlockToZ(&frame.header_block(), compressor); 3194 WriteHeaderBlockToZ(&frame.header_block(), compressor);
3205 #endif // defined(USE_SYSTEM_ZLIB) 3195 #endif // defined(USE_SYSTEM_ZLIB)
3206 3196
3207 int compressed_size = compressed_max_size - compressor->avail_out; 3197 int compressed_size = compressed_max_size - compressor->avail_out;
3208 builder->Seek(compressed_size); 3198 builder->Seek(compressed_size);
3209 builder->RewriteLength(*this); 3199 builder->RewriteLength(*this);
3210 } 3200 }
3211 3201
3212 } // namespace net 3202 } // 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