gfe-relnote: (n/a) Remove QuicStreamSequencerBuffer::GapsDebugString(). No behavior change, not protected. This function is not doing what its name suggests, we don't really need it because (in logs) we can always use bytes_received_ to infer gaps. Also fixed some clang-tidy issues. PiperOrigin-RevId: 294281430 Change-Id: Idce0b55b3f7c06adf80b97f169460fe669624ac0
diff --git a/quic/core/quic_stream_sequencer_buffer.cc b/quic/core/quic_stream_sequencer_buffer.cc index ec3b49f..8a26521 100644 --- a/quic/core/quic_stream_sequencer_buffer.cc +++ b/quic/core/quic_stream_sequencer_buffer.cc
@@ -55,14 +55,14 @@ bytes_received_.Add(0, total_bytes_read_); } -bool QuicStreamSequencerBuffer::RetireBlock(size_t idx) { - if (blocks_[idx] == nullptr) { +bool QuicStreamSequencerBuffer::RetireBlock(size_t index) { + if (blocks_[index] == nullptr) { QUIC_BUG << "Try to retire block twice"; return false; } - delete blocks_[idx]; - blocks_[idx] = nullptr; - QUIC_DVLOG(1) << "Retired block with index: " << idx; + delete blocks_[index]; + blocks_[index] = nullptr; + QUIC_DVLOG(1) << "Retired block with index: " << index; return true; } @@ -198,8 +198,8 @@ "QuicStreamSequencerBuffer error: OnStreamData()" " dest == nullptr: ", (dest == nullptr), " source == nullptr: ", (source == nullptr), - " Writing at offset ", offset, " Gaps: ", GapsDebugString(), - " Remaining frames: ", ReceivedFramesDebugString(), + " Writing at offset ", offset, + " Received frames: ", ReceivedFramesDebugString(), " total_bytes_read_ = ", total_bytes_read_); return false; } @@ -236,8 +236,7 @@ " Readv() dest == nullptr: ", (dest == nullptr), " blocks_[", block_idx, "] == nullptr: ", (blocks_[block_idx] == nullptr), - " Gaps: ", GapsDebugString(), - " Remaining frames: ", ReceivedFramesDebugString(), + " Received frames: ", ReceivedFramesDebugString(), " total_bytes_read_ = ", total_bytes_read_); return QUIC_STREAM_SEQUENCER_INVALID_STATE; } @@ -260,7 +259,8 @@ "QuicStreamSequencerBuffer error: fail to retire block ", block_idx, " as the block is already released, total_bytes_read_ = ", - total_bytes_read_, " Gaps: ", GapsDebugString()); + total_bytes_read_, + " Received frames: ", ReceivedFramesDebugString()); return QUIC_STREAM_SEQUENCER_INVALID_STATE; } } @@ -271,9 +271,9 @@ } int QuicStreamSequencerBuffer::GetReadableRegions(struct iovec* iov, - int iov_count) const { + int iov_len) const { DCHECK(iov != nullptr); - DCHECK_GT(iov_count, 0); + DCHECK_GT(iov_len, 0); if (ReadableBytes() == 0) { iov[0].iov_base = nullptr; @@ -308,7 +308,7 @@ // a region. int iov_used = 1; size_t block_idx = (start_block_idx + iov_used) % blocks_count_; - while (block_idx != end_block_idx && iov_used < iov_count) { + while (block_idx != end_block_idx && iov_used < iov_len) { DCHECK(nullptr != blocks_[block_idx]); iov[iov_used].iov_base = blocks_[block_idx]->buffer; iov[iov_used].iov_len = GetBlockCapacity(block_idx); @@ -318,7 +318,7 @@ } // Deal with last block if |iov| can hold more. - if (iov_used < iov_count) { + if (iov_used < iov_len) { DCHECK(nullptr != blocks_[block_idx]); iov[iov_used].iov_base = blocks_[end_block_idx]->buffer; iov[iov_used].iov_len = end_block_offset + 1; @@ -364,11 +364,11 @@ return true; } -bool QuicStreamSequencerBuffer::MarkConsumed(size_t bytes_used) { - if (bytes_used > ReadableBytes()) { +bool QuicStreamSequencerBuffer::MarkConsumed(size_t bytes_consumed) { + if (bytes_consumed > ReadableBytes()) { return false; } - size_t bytes_to_consume = bytes_used; + size_t bytes_to_consume = bytes_consumed; while (bytes_to_consume > 0) { size_t block_idx = NextBlockToRead(); size_t offset_in_block = ReadOffset(); @@ -483,11 +483,6 @@ } } -std::string QuicStreamSequencerBuffer::GapsDebugString() const { - // TODO(vasilvv): this should return the complement of |bytes_received_|. - return bytes_received_.ToString(); -} - std::string QuicStreamSequencerBuffer::ReceivedFramesDebugString() const { return bytes_received_.ToString(); }
diff --git a/quic/core/quic_stream_sequencer_buffer.h b/quic/core/quic_stream_sequencer_buffer.h index babf3c8..356b62f 100644 --- a/quic/core/quic_stream_sequencer_buffer.h +++ b/quic/core/quic_stream_sequencer_buffer.h
@@ -137,10 +137,10 @@ // Does not consume data. bool PeekRegion(QuicStreamOffset offset, iovec* iov) const; - // Called after GetReadableRegions() to free up |bytes_used| space if these - // bytes are processed. - // Pre-requisite: bytes_used <= available bytes to read. - bool MarkConsumed(size_t bytes_buffered); + // Called after GetReadableRegions() to free up |bytes_consumed| space if + // these bytes are processed. + // Pre-requisite: bytes_consumed <= available bytes to read. + bool MarkConsumed(size_t bytes_consumed); // Deletes and records as consumed any buffered data and clear the buffer. // (To be called only after sequencer's StopReading has been called.) @@ -208,10 +208,7 @@ // Returns offset of highest received byte + 1. QuicStreamOffset NextExpectedByte() const; - // Return |gaps_| as a string: [1024, 1500) [1800, 2048)... for debugging. - std::string GapsDebugString() const; - - // Return all received frames as a string in same format as GapsDebugString(); + // Return all received frames as a string. std::string ReceivedFramesDebugString() const; // The maximum total capacity of this buffer in byte, as constructed.