Replaces a std::string used to buffer data in OgHttp2Session with a new buffer type.
PiperOrigin-RevId: 627419977
diff --git a/quiche/http2/adapter/oghttp2_session.cc b/quiche/http2/adapter/oghttp2_session.cc
index e5d8375..842e3fb 100644
--- a/quiche/http2/adapter/oghttp2_session.cc
+++ b/quiche/http2/adapter/oghttp2_session.cc
@@ -693,10 +693,10 @@
OgHttp2Session::SendResult OgHttp2Session::MaybeSendBufferedData() {
int64_t result = std::numeric_limits<int64_t>::max();
- while (result > 0 && !buffered_data_.empty()) {
- result = visitor_.OnReadyToSend(buffered_data_);
+ while (result > 0 && !buffered_data_.Empty()) {
+ result = visitor_.OnReadyToSend(buffered_data_.GetPrefix());
if (result > 0) {
- buffered_data_.erase(0, result);
+ buffered_data_.RemovePrefix(result);
}
}
if (result < 0) {
@@ -704,7 +704,7 @@
ConnectionError::kSendError);
return SendResult::SEND_ERROR;
}
- return buffered_data_.empty() ? SendResult::SEND_OK
+ return buffered_data_.Empty() ? SendResult::SEND_OK
: SendResult::SEND_BLOCKED;
}
@@ -769,7 +769,8 @@
}
if (static_cast<size_t>(result) < frame.size()) {
// The frame was partially written, so the rest must be buffered.
- buffered_data_.append(frame.data() + result, frame.size() - result);
+ buffered_data_.Append(
+ absl::string_view(frame.data() + result, frame.size() - result));
return SendResult::SEND_BLOCKED;
}
}
@@ -892,7 +893,7 @@
spdy::SpdySerializedFrame header =
spdy::SpdyFramer::SerializeDataFrameHeaderWithPaddingLengthField(
data);
- QUICHE_DCHECK(buffered_data_.empty() && frames_.empty());
+ QUICHE_DCHECK(buffered_data_.Empty() && frames_.empty());
data.Visit(&send_logger_);
const bool success = SendDataFrame(stream_id, absl::string_view(header),
info.payload_length, state);
@@ -1646,8 +1647,9 @@
if (!queued_preface_) {
queued_preface_ = true;
if (!IsServerSession()) {
- buffered_data_.assign(spdy::kHttp2ConnectionHeaderPrefix,
- spdy::kHttp2ConnectionHeaderPrefixSize);
+ buffered_data_.Append(
+ absl::string_view(spdy::kHttp2ConnectionHeaderPrefix,
+ spdy::kHttp2ConnectionHeaderPrefixSize));
}
if (!sending_outbound_settings) {
QUICHE_DCHECK(frames_.empty());
diff --git a/quiche/http2/adapter/oghttp2_session.h b/quiche/http2/adapter/oghttp2_session.h
index 006383f..5de72a8 100644
--- a/quiche/http2/adapter/oghttp2_session.h
+++ b/quiche/http2/adapter/oghttp2_session.h
@@ -10,6 +10,7 @@
#include "absl/strings/string_view.h"
#include "absl/types/variant.h"
+#include "quiche/http2/adapter/chunked_buffer.h"
#include "quiche/http2/adapter/data_source.h"
#include "quiche/http2/adapter/event_forwarder.h"
#include "quiche/http2/adapter/header_validator.h"
@@ -166,7 +167,7 @@
}
bool want_write() const override {
return !fatal_send_error_ &&
- (!frames_.empty() || !buffered_data_.empty() || HasReadyStream() ||
+ (!frames_.empty() || !buffered_data_.Empty() || HasReadyStream() ||
!goaway_rejected_streams_.empty());
}
int GetRemoteWindowSize() const override { return connection_send_window_; }
@@ -511,7 +512,7 @@
std::list<std::unique_ptr<spdy::SpdyFrameIR>> frames_;
// Buffered data (connection preface, serialized frames) that has not yet been
// sent.
- std::string buffered_data_;
+ ChunkedBuffer buffered_data_;
// Maintains the set of streams ready to write data to the peer.
using WriteScheduler = PriorityWriteScheduler<Http2StreamId>;