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

Side by Side Diff: net/quic/quic_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/quic/quic_framer.h ('k') | net/quic/quic_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/quic/quic_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 frame.stream_frame == nullptr) { 271 frame.stream_frame == nullptr) {
272 QUIC_BUG << "Cannot compute the length of a null frame. " 272 QUIC_BUG << "Cannot compute the length of a null frame. "
273 << "type:" << frame.type << "free_bytes:" << free_bytes 273 << "type:" << frame.type << "free_bytes:" << free_bytes
274 << " first_frame:" << first_frame << " last_frame:" << last_frame 274 << " first_frame:" << first_frame << " last_frame:" << last_frame
275 << " seq num length:" << packet_number_length; 275 << " seq num length:" << packet_number_length;
276 set_error(QUIC_INTERNAL_ERROR); 276 set_error(QUIC_INTERNAL_ERROR);
277 visitor_->OnError(this); 277 visitor_->OnError(this);
278 return 0; 278 return 0;
279 } 279 }
280 if (frame.type == PADDING_FRAME) { 280 if (frame.type == PADDING_FRAME) {
281 // PADDING implies end of packet. 281 if (frame.padding_frame.num_padding_bytes == -1) {
282 return free_bytes; 282 // Full padding to the end of the packet.
283 return free_bytes;
284 } else {
285 // Lite padding.
286 return free_bytes <
287 static_cast<size_t>(frame.padding_frame.num_padding_bytes)
288 ? free_bytes
289 : frame.padding_frame.num_padding_bytes;
290 }
283 } 291 }
292
284 size_t frame_len = 293 size_t frame_len =
285 ComputeFrameLength(frame, last_frame, packet_number_length); 294 ComputeFrameLength(frame, last_frame, packet_number_length);
286 if (frame_len <= free_bytes) { 295 if (frame_len <= free_bytes) {
287 // Frame fits within packet. Note that acks may be truncated. 296 // Frame fits within packet. Note that acks may be truncated.
288 return frame_len; 297 return frame_len;
289 } 298 }
290 // Only truncate the first frame in a packet, so if subsequent ones go 299 // Only truncate the first frame in a packet, so if subsequent ones go
291 // over, stop including more frames. 300 // over, stop including more frames.
292 if (!first_frame) { 301 if (!first_frame) {
293 return 0; 302 return 0;
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 } 1103 }
1095 1104
1096 // This was a special frame type that did not match any 1105 // This was a special frame type that did not match any
1097 // of the known ones. Error. 1106 // of the known ones. Error.
1098 set_detailed_error("Illegal frame type."); 1107 set_detailed_error("Illegal frame type.");
1099 DLOG(WARNING) << "Illegal frame type: " << static_cast<int>(frame_type); 1108 DLOG(WARNING) << "Illegal frame type: " << static_cast<int>(frame_type);
1100 return RaiseError(QUIC_INVALID_FRAME_DATA); 1109 return RaiseError(QUIC_INVALID_FRAME_DATA);
1101 } 1110 }
1102 1111
1103 switch (frame_type) { 1112 switch (frame_type) {
1104 case PADDING_FRAME: 1113 case PADDING_FRAME: {
1114 QuicPaddingFrame frame(reader->BytesRemaining());
1115 if (!visitor_->OnPaddingFrame(frame)) {
1116 DVLOG(1) << "Visitor asked to stop further processing.";
1117 }
1105 // We're done with the packet. 1118 // We're done with the packet.
1106 return true; 1119 return true;
1120 }
1107 1121
1108 case RST_STREAM_FRAME: { 1122 case RST_STREAM_FRAME: {
1109 QuicRstStreamFrame frame; 1123 QuicRstStreamFrame frame;
1110 if (!ProcessRstStreamFrame(reader, &frame)) { 1124 if (!ProcessRstStreamFrame(reader, &frame)) {
1111 return RaiseError(QUIC_INVALID_RST_STREAM_DATA); 1125 return RaiseError(QUIC_INVALID_RST_STREAM_DATA);
1112 } 1126 }
1113 if (!visitor_->OnRstStreamFrame(frame)) { 1127 if (!visitor_->OnRstStreamFrame(frame)) {
1114 DVLOG(1) << "Visitor asked to stop further processing."; 1128 DVLOG(1) << "Visitor asked to stop further processing.";
1115 // Returning true since there was no parsing error. 1129 // Returning true since there was no parsing error.
1116 return true; 1130 return true;
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 2263
2250 bool QuicFramer::RaiseError(QuicErrorCode error) { 2264 bool QuicFramer::RaiseError(QuicErrorCode error) {
2251 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) 2265 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error)
2252 << " detail: " << detailed_error_; 2266 << " detail: " << detailed_error_;
2253 set_error(error); 2267 set_error(error);
2254 visitor_->OnError(this); 2268 visitor_->OnError(this);
2255 return false; 2269 return false;
2256 } 2270 }
2257 2271
2258 } // namespace net 2272 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698