| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/core/quic_stream_sequencer_buffer.h" | 5 #include "net/quic/core/quic_stream_sequencer_buffer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/quic/core/quic_bug_tracker.h" | 9 #include "net/quic/core/quic_bug_tracker.h" |
| 10 #include "net/quic/core/quic_flags.h" | 10 #include "net/quic/core/quic_flags.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 "\nCurrent gaps: " + GapsDebugString(); | 138 "\nCurrent gaps: " + GapsDebugString(); |
| 139 return QUIC_OVERLAPPING_STREAM_DATA; | 139 return QUIC_OVERLAPPING_STREAM_DATA; |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Write beyond the current range this buffer is covering. | 142 // Write beyond the current range this buffer is covering. |
| 143 if (offset + size > total_bytes_read_ + max_buffer_capacity_bytes_) { | 143 if (offset + size > total_bytes_read_ + max_buffer_capacity_bytes_) { |
| 144 *error_details = "Received data beyond available range."; | 144 *error_details = "Received data beyond available range."; |
| 145 return QUIC_INTERNAL_ERROR; | 145 return QUIC_INTERNAL_ERROR; |
| 146 } | 146 } |
| 147 | 147 |
| 148 if (FLAGS_quic_limit_frame_gaps_in_buffer && | 148 if (current_gap->begin_offset != starting_offset && |
| 149 current_gap->begin_offset != starting_offset && | |
| 150 current_gap->end_offset != starting_offset + data.length() && | 149 current_gap->end_offset != starting_offset + data.length() && |
| 151 gaps_.size() >= kMaxNumGapsAllowed) { | 150 gaps_.size() >= kMaxNumGapsAllowed) { |
| 152 // This frame is going to create one more gap which exceeds max number of | 151 // This frame is going to create one more gap which exceeds max number of |
| 153 // gaps allowed. Stop processing. | 152 // gaps allowed. Stop processing. |
| 154 *error_details = "Too many gaps created for this stream."; | 153 *error_details = "Too many gaps created for this stream."; |
| 155 return QUIC_TOO_MANY_FRAME_GAPS; | 154 return QUIC_TOO_MANY_FRAME_GAPS; |
| 156 } | 155 } |
| 157 | 156 |
| 158 size_t total_written = 0; | 157 size_t total_written = 0; |
| 159 size_t source_remaining = size; | 158 size_t source_remaining = size; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if (GetBlockIndex(gaps_.back().begin_offset - 1) == block_index) { | 463 if (GetBlockIndex(gaps_.back().begin_offset - 1) == block_index) { |
| 465 return; | 464 return; |
| 466 } | 465 } |
| 467 | 466 |
| 468 // Read index remains in this block, which means a gap has been reached. | 467 // Read index remains in this block, which means a gap has been reached. |
| 469 if (NextBlockToRead() == block_index) { | 468 if (NextBlockToRead() == block_index) { |
| 470 Gap first_gap = gaps_.front(); | 469 Gap first_gap = gaps_.front(); |
| 471 DCHECK(first_gap.begin_offset == total_bytes_read_); | 470 DCHECK(first_gap.begin_offset == total_bytes_read_); |
| 472 // Check where the next piece data is. | 471 // Check where the next piece data is. |
| 473 // Not empty if next piece of data is still in this chunk. | 472 // Not empty if next piece of data is still in this chunk. |
| 474 bool gap_extends_to_infinity = | |
| 475 (first_gap.end_offset == std::numeric_limits<QuicStreamOffset>::max()); | |
| 476 bool gap_ends_in_this_block = | 473 bool gap_ends_in_this_block = |
| 477 (GetBlockIndex(first_gap.end_offset) == block_index); | 474 (GetBlockIndex(first_gap.end_offset) == block_index); |
| 478 if ((!FLAGS_quic_sequencer_buffer_retire_block_in_time && | 475 if (gap_ends_in_this_block) { |
| 479 !gap_extends_to_infinity) || | |
| 480 gap_ends_in_this_block) { | |
| 481 return; | 476 return; |
| 482 } | 477 } |
| 483 } | 478 } |
| 484 RetireBlock(block_index); | 479 RetireBlock(block_index); |
| 485 } | 480 } |
| 486 | 481 |
| 487 bool QuicStreamSequencerBuffer::Empty() const { | 482 bool QuicStreamSequencerBuffer::Empty() const { |
| 488 return gaps_.size() == 1 && gaps_.front().begin_offset == total_bytes_read_; | 483 return gaps_.size() == 1 && gaps_.front().begin_offset == total_bytes_read_; |
| 489 } | 484 } |
| 490 | 485 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 QuicStreamOffset current_frame_begin_offset = it.first; | 534 QuicStreamOffset current_frame_begin_offset = it.first; |
| 540 QuicStreamOffset current_frame_end_offset = | 535 QuicStreamOffset current_frame_end_offset = |
| 541 it.second.length + current_frame_begin_offset; | 536 it.second.length + current_frame_begin_offset; |
| 542 current_frames_string += | 537 current_frames_string += |
| 543 RangeDebugString(current_frame_begin_offset, current_frame_end_offset); | 538 RangeDebugString(current_frame_begin_offset, current_frame_end_offset); |
| 544 } | 539 } |
| 545 return current_frames_string; | 540 return current_frames_string; |
| 546 } | 541 } |
| 547 | 542 |
| 548 } // namespace net | 543 } // namespace net |
| OLD | NEW |