Index: mojo/edk/system/raw_channel.cc |
diff --git a/mojo/edk/system/raw_channel.cc b/mojo/edk/system/raw_channel.cc |
index 6f560d64043f1a3cc0da44e6bc79853bb6be7033..a7faead708a5b95c81a630cc4a2ce87f498a577c 100644 |
--- a/mojo/edk/system/raw_channel.cc |
+++ b/mojo/edk/system/raw_channel.cc |
@@ -222,6 +222,7 @@ void RawChannel::LazyInitialize() { |
return; |
initialized_ = true; |
internal::ChannelStarted(); |
+ base::MessageLoop::current()->AddDestructionObserver(this); |
OnInit(); |
@@ -286,8 +287,10 @@ void RawChannel::Shutdown() { |
OnShutdownNoLock(read_buffer_.Pass(), write_buffer_.Pass()); |
} |
- if (initialized_) |
+ if (initialized_) { |
internal::ChannelShutdown(); |
+ base::MessageLoop::current()->RemoveDestructionObserver(this); |
+ } |
delete this; |
return; |
} |
@@ -715,9 +718,14 @@ void RawChannel::UpdateWriteBuffer(size_t platform_handles_written, |
} |
void RawChannel::CallOnReadCompleted(IOResult io_result, size_t bytes_read) { |
- base::AutoLock locker(read_lock()); |
+ base::AutoLock locker(read_lock_); |
OnReadCompletedNoLock(io_result, bytes_read); |
} |
+void RawChannel::WillDestroyCurrentMessageLoop() { |
+ base::AutoLock locker(read_lock_); |
+ OnReadCompletedNoLock(IO_FAILED_SHUTDOWN, 0); |
+} |
+ |
} // namespace edk |
} // namespace mojo |