Commit e6868c46 authored by Renjie's avatar Renjie Committed by Commit Bot

Add total_length() and NumSlices() methods to QuicMemSliceSpan so that length...

Add total_length() and NumSlices() methods to QuicMemSliceSpan so that length of HTTP/3 data frame can be computed in QuicSpdyStream::WriteBodySlices().

no behavior change.

Merge internal change: 222285071

Change-Id: Ie3e2a120fc072a9d8329e33fe5cef778aa454c39
Reviewed-on: https://chromium-review.googlesource.com/c/1351584Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Commit-Queue: Renjie Tang <renjietang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612432}
parent 541b9307
...@@ -38,6 +38,12 @@ class QUIC_EXPORT_PRIVATE QuicMemSliceSpan { ...@@ -38,6 +38,12 @@ class QUIC_EXPORT_PRIVATE QuicMemSliceSpan {
// Return data of the span at |index| by the form of a QuicStringPiece. // Return data of the span at |index| by the form of a QuicStringPiece.
QuicStringPiece GetData(int index) { return impl_.GetData(index); } QuicStringPiece GetData(int index) { return impl_.GetData(index); }
// Return the total length of the data inside the span.
QuicByteCount total_length() { return impl_.total_length(); }
// Return total number of slices in the span.
size_t NumSlices() { return impl_.NumSlices(); }
bool empty() const { return impl_.empty(); } bool empty() const { return impl_.empty(); }
private: private:
......
...@@ -41,4 +41,12 @@ QuicByteCount QuicMemSliceSpanImpl::SaveMemSlicesInSendBuffer( ...@@ -41,4 +41,12 @@ QuicByteCount QuicMemSliceSpanImpl::SaveMemSlicesInSendBuffer(
return saved_length; return saved_length;
} }
QuicByteCount QuicMemSliceSpanImpl::total_length() {
QuicByteCount length = 0;
for (size_t i = 0; i < num_buffers_; ++i) {
length += lengths_[i];
}
return length;
}
} // namespace quic } // namespace quic
...@@ -36,6 +36,10 @@ class QUIC_EXPORT_PRIVATE QuicMemSliceSpanImpl { ...@@ -36,6 +36,10 @@ class QUIC_EXPORT_PRIVATE QuicMemSliceSpanImpl {
return QuicStringPiece(buffers_[index]->data(), lengths_[index]); return QuicStringPiece(buffers_[index]->data(), lengths_[index]);
} }
QuicByteCount total_length();
size_t NumSlices() { return num_buffers_; }
bool empty() const { return num_buffers_ == 0; } bool empty() const { return num_buffers_ == 0; }
private: private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment