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

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

Issue 1475113004: Fix shutdown assert in new Mojo EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/data_pipe_producer_dispatcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/message_pipe_dispatcher.cc
diff --git a/mojo/edk/system/message_pipe_dispatcher.cc b/mojo/edk/system/message_pipe_dispatcher.cc
index fb3ce4e9f3c2079041d56d04e22f46a191741991..df4cb0ffe816f85028a5d661db07a7a8743766c0 100644
--- a/mojo/edk/system/message_pipe_dispatcher.cc
+++ b/mojo/edk/system/message_pipe_dispatcher.cc
@@ -23,10 +23,6 @@
namespace mojo {
namespace edk {
-// TODO(jam): do more tests on using channel on same thread if it supports it (
-// i.e. with USE_CHROME_EDK and Windows). Also see ipc_channel_mojo.cc
-bool g_use_channel_on_io_thread_only = true;
-
namespace {
const size_t kInvalidMessagePipeHandleIndex = static_cast<size_t>(-1);
@@ -134,13 +130,8 @@ void MessagePipeDispatcher::Init(
serialized_read_buffer, serialized_read_buffer_size,
serialized_write_buffer, serialized_write_buffer_size,
serialized_read_fds, serialized_write_fds);
- if (g_use_channel_on_io_thread_only) {
- internal::g_io_thread_task_runner->PostTask(
- FROM_HERE, base::Bind(&MessagePipeDispatcher::InitOnIO, this));
- } else {
- InitOnIO();
- }
- // TODO(jam): optimize for when running on IO thread?
+ internal::g_io_thread_task_runner->PostTask(
+ FROM_HERE, base::Bind(&MessagePipeDispatcher::InitOnIO, this));
}
}
@@ -357,8 +348,14 @@ MessagePipeDispatcher::MessagePipeDispatcher()
}
MessagePipeDispatcher::~MessagePipeDispatcher() {
- // |Close()|/|CloseImplNoLock()| should have taken care of the channel.
- DCHECK(!channel_);
+ // |Close()|/|CloseImplNoLock()| should have taken care of the channel. The
+ // exception is if they posted a task to run CloseOnIO but the IO thread shut
+ // down and so when it was deleting pending tasks it caused the last reference
+ // to destruct this object. In that case, safe to destroy the channel.
+ if (channel_ && internal::g_io_thread_task_runner->RunsTasksOnCurrentThread())
+ channel_->Shutdown();
+ else
+ DCHECK(!channel_);
#if defined(OS_POSIX)
ClosePlatformHandles(&serialized_fds_);
#endif
@@ -371,12 +368,8 @@ void MessagePipeDispatcher::CancelAllAwakablesNoLock() {
void MessagePipeDispatcher::CloseImplNoLock() {
lock().AssertAcquired();
- if (g_use_channel_on_io_thread_only) {
- internal::g_io_thread_task_runner->PostTask(
- FROM_HERE, base::Bind(&MessagePipeDispatcher::CloseOnIO, this));
- } else {
- CloseOnIO();
- }
+ internal::g_io_thread_task_runner->PostTask(
+ FROM_HERE, base::Bind(&MessagePipeDispatcher::CloseOnIO, this));
}
void MessagePipeDispatcher::SerializeInternal() {
« no previous file with comments | « mojo/edk/system/data_pipe_producer_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698