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

Unified Diff: blimp/net/stream_packet_reader.cc

Issue 1551583003: Implementation and fixes for Blimp client/engine E2E communication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dtrainor-linux-cl1528243002
Patch Set: Fixed misplaced EXPORT directive Created 4 years, 12 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
« no previous file with comments | « blimp/net/null_blimp_message_processor.cc ('k') | blimp/net/test_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/net/stream_packet_reader.cc
diff --git a/blimp/net/stream_packet_reader.cc b/blimp/net/stream_packet_reader.cc
index dd91cae085b6e080841ba13d6d2b6d1a562bcd60..00e0c3ec137856d2ed24c309d8ed40f703592198 100644
--- a/blimp/net/stream_packet_reader.cc
+++ b/blimp/net/stream_packet_reader.cc
@@ -103,10 +103,11 @@ int StreamPacketReader::DoReadHeader(int result) {
header_buffer_->set_offset(header_buffer_->offset() + result);
if (static_cast<size_t>(header_buffer_->offset()) < kPacketHeaderSizeBytes) {
// There is more header to read.
- return socket_->Read(header_buffer_.get(),
- kPacketHeaderSizeBytes - header_buffer_->offset(),
- base::Bind(&StreamPacketReader::OnReadComplete,
- weak_factory_.GetWeakPtr()));
+ int result = socket_->Read(
+ header_buffer_.get(), kPacketHeaderSizeBytes - header_buffer_->offset(),
+ base::Bind(&StreamPacketReader::OnReadComplete,
+ weak_factory_.GetWeakPtr()));
+ return (result != 0 ? result : net::ERR_CONNECTION_CLOSED);
}
// Finished reading the header. Parse the size and prepare for payload read.
@@ -141,6 +142,12 @@ int StreamPacketReader::DoReadPayload(int result) {
void StreamPacketReader::OnReadComplete(int result) {
DCHECK_NE(net::ERR_IO_PENDING, result);
+ if (result == 0 /* EOF */) {
+ payload_buffer_ = nullptr;
+ base::ResetAndReturn(&callback_).Run(net::ERR_CONNECTION_CLOSED);
+ return;
+ }
+
// If the read was succesful, then process the result.
if (result > 0) {
result = DoReadLoop(result);
« no previous file with comments | « blimp/net/null_blimp_message_processor.cc ('k') | blimp/net/test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698