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

Unified Diff: ipc/ipc_channel_nacl.cc

Issue 10698138: PPAPI/NaCl: Make ipc_channel_nacl post to the correct thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_nacl.cc
diff --git a/ipc/ipc_channel_nacl.cc b/ipc/ipc_channel_nacl.cc
index 4dec85bd6130cf0d43a4b7590a0e117801363db3..628b8a163d02617d459d9411e4d0b0655c656fef 100644
--- a/ipc/ipc_channel_nacl.cc
+++ b/ipc/ipc_channel_nacl.cc
@@ -132,17 +132,6 @@ Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle,
LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name
<< "\" in " << modestr << " mode";
}
- reader_thread_runner_.reset(
- new ReaderThreadRunner(
- pipe_,
- base::Bind(&Channel::ChannelImpl::DidRecvMsg,
- weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&Channel::ChannelImpl::ReadDidFail,
- weak_ptr_factory_.GetWeakPtr()),
- base::MessageLoopProxy::current()));
- reader_thread_.reset(
- new base::DelegateSimpleThread(reader_thread_runner_.get(),
- "ipc_channel_nacl reader thread"));
}
Channel::ChannelImpl::~ChannelImpl() {
@@ -155,6 +144,22 @@ bool Channel::ChannelImpl::Connect() {
return false;
}
+ // Note that Connect is called on the "Channel" thread (i.e., the same thread
+ // where Channel::Send will be called, and the same thread that should receive
+ // messages). The constructor might be invoked on another thread (see
+ // ChannelProxy for an example of that). Therefore, we must wait until Connect
+ // is called to decide which MessageLoopProxy to pass to ReaderThreadRunner.
+ reader_thread_runner_.reset(
+ new ReaderThreadRunner(
+ pipe_,
+ base::Bind(&Channel::ChannelImpl::DidRecvMsg,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&Channel::ChannelImpl::ReadDidFail,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::MessageLoopProxy::current()));
+ reader_thread_.reset(
+ new base::DelegateSimpleThread(reader_thread_runner_.get(),
+ "ipc_channel_nacl reader thread"));
reader_thread_->Start();
waiting_connect_ = false;
// If there were any messages queued before connection, send them.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698