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

Unified Diff: mojo/system/raw_channel.cc

Issue 462563003: Mojo: Plumb "connection broken" out of RawChannel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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: mojo/system/raw_channel.cc
diff --git a/mojo/system/raw_channel.cc b/mojo/system/raw_channel.cc
index be45641540eebdc102c4b0ee8440575183ff8c60..036fa798c3408d1660055ceb818b1ba3b58e0a4d 100644
--- a/mojo/system/raw_channel.cc
+++ b/mojo/system/raw_channel.cc
@@ -284,12 +284,10 @@ void RawChannel::OnReadCompleted(IOResult io_result, size_t bytes_read) {
case IO_SUCCEEDED:
break;
case IO_FAILED_SHUTDOWN:
- read_stopped_ = true;
- CallOnError(Delegate::ERROR_READ_SHUTDOWN);
- return;
+ case IO_FAILED_BROKEN:
case IO_FAILED_UNKNOWN:
read_stopped_ = true;
- CallOnError(Delegate::ERROR_READ_UNKNOWN);
+ CallOnError(ReadIOResultToError(io_result));
return;
case IO_PENDING:
NOTREACHED();
@@ -456,6 +454,24 @@ bool RawChannel::OnReadMessageForRawChannel(
return false;
}
+// static
+RawChannel::Delegate::Error RawChannel::ReadIOResultToError(
+ IOResult io_result) {
+ switch (io_result) {
+ case IO_FAILED_SHUTDOWN:
+ return Delegate::ERROR_READ_SHUTDOWN;
+ case IO_FAILED_BROKEN:
+ return Delegate::ERROR_READ_BROKEN;
+ case IO_FAILED_UNKNOWN:
+ return Delegate::ERROR_READ_UNKNOWN;
+ case IO_SUCCEEDED:
+ case IO_PENDING:
+ NOTREACHED();
+ break;
+ }
+ return Delegate::ERROR_READ_UNKNOWN;
+}
+
void RawChannel::CallOnError(Delegate::Error error) {
DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io_);
// TODO(vtl): Add a "write_lock_.AssertNotAcquired()"?

Powered by Google App Engine
This is Rietveld 408576698