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

Side by Side Diff: net/quic/quic_stream_sequencer.cc

Issue 1908103002: Landing Recent QUIC changes until 4/15/2016 17:20 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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_stream_factory.cc ('k') | net/quic/quic_stream_sequencer_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_stream_sequencer.h" 5 #include "net/quic/quic_stream_sequencer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 24 matching lines...) Expand all
35 num_early_frames_received_(0), 35 num_early_frames_received_(0),
36 clock_(clock), 36 clock_(clock),
37 ignore_read_data_(false) {} 37 ignore_read_data_(false) {}
38 38
39 QuicStreamSequencer::~QuicStreamSequencer() {} 39 QuicStreamSequencer::~QuicStreamSequencer() {}
40 40
41 void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) { 41 void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) {
42 ++num_frames_received_; 42 ++num_frames_received_;
43 const QuicStreamOffset byte_offset = frame.offset; 43 const QuicStreamOffset byte_offset = frame.offset;
44 const size_t data_len = frame.frame_length; 44 const size_t data_len = frame.frame_length;
45 bool consolidate_errors = FLAGS_quic_consolidate_onstreamframe_errors;
46 if (!consolidate_errors && data_len == 0 && !frame.fin) {
47 // Stream frames must have data or a fin flag.
48 LOG(WARNING) << "QUIC_INVALID_STREAM_FRAM: Empty stream frame "
49 "without FIN set.";
50 stream_->CloseConnectionWithDetails(QUIC_EMPTY_STREAM_FRAME_NO_FIN,
51 "Empty stream frame without FIN set.");
52 return;
53 }
54 45
55 if (frame.fin) { 46 if (frame.fin) {
56 CloseStreamAtOffset(frame.offset + data_len); 47 CloseStreamAtOffset(frame.offset + data_len);
57 if (data_len == 0) { 48 if (data_len == 0) {
58 return; 49 return;
59 } 50 }
60 } 51 }
61 size_t bytes_written; 52 size_t bytes_written;
62 string error_details; 53 string error_details;
63 QuicErrorCode result = buffered_frames_.OnStreamData( 54 QuicErrorCode result = buffered_frames_.OnStreamData(
64 byte_offset, StringPiece(frame.frame_buffer, frame.frame_length), 55 byte_offset, StringPiece(frame.frame_buffer, frame.frame_length),
65 clock_->ApproximateNow(), &bytes_written, &error_details); 56 clock_->ApproximateNow(), &bytes_written, &error_details);
66 if (!consolidate_errors) { 57 if (result != QUIC_NO_ERROR) {
67 if (result == QUIC_OVERLAPPING_STREAM_DATA) { 58 DLOG(WARNING) << QuicUtils::ErrorToString(result);
68 LOG(WARNING) << "QUIC_INVALID_STREAM_FRAME: Stream frame " 59 DLOG(WARNING) << error_details;
69 "overlaps with buffered data."; 60 stream_->CloseConnectionWithDetails(result, error_details);
70 stream_->CloseConnectionWithDetails( 61 return;
71 QUIC_EMPTY_STREAM_FRAME_NO_FIN,
72 "Stream frame overlaps with buffered data.");
73 return;
74 }
75 } else {
76 if (result != QUIC_NO_ERROR) {
77 LOG(WARNING) << QuicUtils::ErrorToString(result) << ": " << error_details;
78 stream_->CloseConnectionWithDetails(result, error_details);
79 return;
80 }
81 } 62 }
82 63
83 if ((consolidate_errors || result == QUIC_NO_ERROR) && bytes_written == 0) { 64 if (bytes_written == 0) {
84 ++num_duplicate_frames_received_; 65 ++num_duplicate_frames_received_;
85 // Silently ignore duplicates. 66 // Silently ignore duplicates.
86 return; 67 return;
87 } 68 }
88 69
89 if (byte_offset > buffered_frames_.BytesConsumed()) { 70 if (byte_offset > buffered_frames_.BytesConsumed()) {
90 ++num_early_frames_received_; 71 ++num_early_frames_received_;
91 } 72 }
92 73
93 if (blocked_) { 74 if (blocked_) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 190
210 size_t QuicStreamSequencer::NumBytesBuffered() const { 191 size_t QuicStreamSequencer::NumBytesBuffered() const {
211 return buffered_frames_.BytesBuffered(); 192 return buffered_frames_.BytesBuffered();
212 } 193 }
213 194
214 QuicStreamOffset QuicStreamSequencer::NumBytesConsumed() const { 195 QuicStreamOffset QuicStreamSequencer::NumBytesConsumed() const {
215 return buffered_frames_.BytesConsumed(); 196 return buffered_frames_.BytesConsumed();
216 } 197 }
217 198
218 } // namespace net 199 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.cc ('k') | net/quic/quic_stream_sequencer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698