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

Unified Diff: blimp/net/blimp_message_pump.cc

Issue 1452823011: Make PacketReader/PacketWriter interfaces async-only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address wez feedback Created 5 years, 1 month 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: blimp/net/blimp_message_pump.cc
diff --git a/blimp/net/blimp_message_pump.cc b/blimp/net/blimp_message_pump.cc
index 14d8d2eec875d712d06741ff198a333ac99d4460..8aef21ae2990bbd48f77169447798e1265e390c7 100644
--- a/blimp/net/blimp_message_pump.cc
+++ b/blimp/net/blimp_message_pump.cc
@@ -40,20 +40,15 @@ void BlimpMessagePump::ReadNextPacket() {
buffer_->set_offset(0);
read_packet_callback_.Reset(base::Bind(
&BlimpMessagePump::OnReadPacketComplete, base::Unretained(this)));
- int result =
- reader_->ReadPacket(buffer_.get(), read_packet_callback_.callback());
- if (result != net::ERR_IO_PENDING) {
- // Read completed synchronously.
- OnReadPacketComplete(result);
- }
+ reader_->ReadPacket(buffer_.get(), read_packet_callback_.callback());
}
void BlimpMessagePump::OnReadPacketComplete(int result) {
- if (result > 0) {
+ if (result == net::OK) {
// The result is the size of the packet in bytes.
haibinlu 2015/11/25 19:10:33 so, ReadPacket no longer returns the size of the p
Kevin M 2015/11/30 19:25:14 The interface was changed in response to feedback
scoped_ptr<BlimpMessage> message(new BlimpMessage);
bool parse_result =
- message->ParseFromArray(buffer_->StartOfBuffer(), result);
+ message->ParseFromArray(buffer_->StartOfBuffer(), buffer_->offset());
if (parse_result) {
process_msg_callback_.Reset(base::Bind(
&BlimpMessagePump::OnProcessMessageComplete, base::Unretained(this)));
@@ -63,6 +58,9 @@ void BlimpMessagePump::OnReadPacketComplete(int result) {
}
result = net::ERR_FAILED;
}
+
+ // Error reporting.
+ DCHECK_NE(net::OK, result);
haibinlu 2015/11/25 19:10:33 is this obviously true?
Kevin M 2015/11/30 19:25:14 Yes - the only success case returns out of the fun
if (error_observer_)
error_observer_->OnConnectionError(result);
}

Powered by Google App Engine
This is Rietveld 408576698