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

Unified Diff: mojo/edk/system/raw_channel.cc

Issue 1471123002: Don't leak the WatcherThreadManager background thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: also posix 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
« no previous file with comments | « mojo/edk/system/raw_channel.h ('k') | mojo/message_pump/handle_watcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « mojo/edk/system/raw_channel.h ('k') | mojo/message_pump/handle_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698