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

Unified Diff: net/quic/chromium/quic_chromium_client_stream.cc

Issue 2877063002: Add an async ReadBody method to QuicChromiumClientStream::Handle (Closed)
Patch Set: format Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/chromium/quic_chromium_client_stream.cc
diff --git a/net/quic/chromium/quic_chromium_client_stream.cc b/net/quic/chromium/quic_chromium_client_stream.cc
index ad706a56e1bc34b45fc0729cf17df94c09a6339d..1b1c90ec9207f7dc122c591fa392c10995b806fe 100644
--- a/net/quic/chromium/quic_chromium_client_stream.cc
+++ b/net/quic/chromium/quic_chromium_client_stream.cc
@@ -23,7 +23,10 @@ namespace net {
QuicChromiumClientStream::Handle::Handle(QuicChromiumClientStream* stream,
Delegate* delegate)
- : stream_(stream), delegate_(delegate), read_headers_buffer_(nullptr) {
+ : stream_(stream),
+ delegate_(delegate),
+ read_headers_buffer_(nullptr),
+ read_body_buffer_len_(0) {
SaveState();
}
@@ -58,7 +61,16 @@ void QuicChromiumClientStream::Handle::OnTrailingHeadersAvailable(
}
void QuicChromiumClientStream::Handle::OnDataAvailable() {
- delegate_->OnDataAvailable();
+ if (!read_body_callback_)
+ return; // Wait for ReadBody to be called.
+
+ int rv = stream_->Read(read_body_buffer_, read_body_buffer_len_);
+ if (rv == ERR_IO_PENDING)
+ return; // Spurrious, likely because of trailers?
+
+ read_body_buffer_ = nullptr;
+ read_body_buffer_len_ = 0;
+ ResetAndReturn(&read_body_callback_).Run(rv);
}
void QuicChromiumClientStream::Handle::OnClose() {
@@ -98,6 +110,23 @@ int QuicChromiumClientStream::Handle::ReadInitialHeaders(
return ERR_IO_PENDING;
}
+int QuicChromiumClientStream::Handle::ReadBody(
+ IOBuffer* buffer,
+ int buffer_len,
+ const CompletionCallback& callback) {
+ if (!stream_)
+ return ERR_CONNECTION_CLOSED;
+
+ int rv = stream_->Read(buffer, buffer_len);
+ if (rv != ERR_IO_PENDING)
+ return rv;
+
+ read_body_callback_ = callback;
+ read_body_buffer_ = buffer;
+ read_body_buffer_len_ = buffer_len;
+ return ERR_IO_PENDING;
+}
+
size_t QuicChromiumClientStream::Handle::WriteHeaders(
SpdyHeaderBlock header_block,
bool fin,
« no previous file with comments | « net/quic/chromium/quic_chromium_client_stream.h ('k') | net/quic/chromium/quic_chromium_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698