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

Unified Diff: blimp/net/blimp_connection.cc

Issue 1909143002: Use ConnectionErrorObserver, not callbacks, for error handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wez feedback Created 4 years, 8 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 | « no previous file | blimp/net/blimp_connection_unittest.cc » ('j') | blimp/net/blimp_message_output_buffer.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/net/blimp_connection.cc
diff --git a/blimp/net/blimp_connection.cc b/blimp/net/blimp_connection.cc
index 4b48f773d488d97ecd85b3a0673b198ffc5260bf..3d8676a934a5bf019c0526203107afa3be54d287 100644
--- a/blimp/net/blimp_connection.cc
+++ b/blimp/net/blimp_connection.cc
@@ -91,10 +91,13 @@ void BlimpMessageSender::ProcessMessage(
void BlimpMessageSender::OnWritePacketComplete(int result) {
DVLOG(2) << "OnWritePacketComplete, result=" << result;
DCHECK_NE(net::ERR_IO_PENDING, result);
- base::ResetAndReturn(&pending_process_msg_callback_).Run(result);
+
if (result != net::OK) {
error_observer_->OnConnectionError(result);
+ return;
}
+
+ base::ResetAndReturn(&pending_process_msg_callback_).Run(result);
haibinlu 2016/05/03 21:23:05 nit. use net::OK instead to be specific. Also, ad
Kevin M 2016/05/24 20:47:04 Done.
}
} // namespace
@@ -103,16 +106,16 @@ BlimpConnection::BlimpConnection(std::unique_ptr<PacketReader> reader,
std::unique_ptr<PacketWriter> writer)
: reader_(std::move(reader)),
message_pump_(new BlimpMessagePump(reader_.get())),
- writer_(std::move(writer)),
- outgoing_msg_processor_(new BlimpMessageSender(writer_.get())) {
+ writer_(std::move(writer)) {
DCHECK(writer_);
+ DCHECK(reader_);
- // Observe the connection errors received by any of this connection's network
- // objects.
message_pump_->set_error_observer(this);
- BlimpMessageSender* sender =
- static_cast<BlimpMessageSender*>(outgoing_msg_processor_.get());
+
+ std::unique_ptr<BlimpMessageSender> sender(
+ new BlimpMessageSender(writer_.get()));
sender->set_error_observer(this);
+ outgoing_msg_processor_ = std::move(sender);
}
BlimpConnection::BlimpConnection() {}
« no previous file with comments | « no previous file | blimp/net/blimp_connection_unittest.cc » ('j') | blimp/net/blimp_message_output_buffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698