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

Unified Diff: ipc/ipc_channel_nacl.cc

Issue 183553004: Eliminate a potential race in IPC::ChannelProxy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: merge Created 6 years, 9 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 | « ipc/ipc_channel_nacl.h ('k') | ipc/ipc_channel_proxy.h » ('j') | 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 1ecd5718245d3c00a0663ce9f1221ea3b21962bd..f796af9ea3dc54bc86c501bc41d9ba839e8d3bfc 100644
--- a/ipc/ipc_channel_nacl.cc
+++ b/ipc/ipc_channel_nacl.cc
@@ -17,6 +17,7 @@
#include "base/task_runner_util.h"
#include "base/threading/simple_thread.h"
#include "ipc/file_descriptor_set_posix.h"
+#include "ipc/ipc_listener.h"
#include "ipc/ipc_logging.h"
#include "native_client/src/public/imc_syscalls.h"
#include "native_client/src/public/imc_types.h"
@@ -138,9 +139,15 @@ Channel::ChannelImpl::~ChannelImpl() {
Close();
}
+base::ProcessId Channel::ChannelImpl::peer_pid() const {
+ // This shouldn't actually get used in the untrusted side of the proxy, and we
+ // don't have the real pid anyway.
+ return -1;
+}
+
bool Channel::ChannelImpl::Connect() {
if (pipe_ == -1) {
- DLOG(INFO) << "Channel creation failed: " << pipe_name_;
+ DLOG(WARNING) << "Channel creation failed: " << pipe_name_;
return false;
}
@@ -164,6 +171,10 @@ bool Channel::ChannelImpl::Connect() {
waiting_connect_ = false;
// If there were any messages queued before connection, send them.
ProcessOutgoingMessages();
+ base::MessageLoopProxy::current()->PostTask(FROM_HERE,
+ base::Bind(&Channel::ChannelImpl::CallOnChannelConnected,
+ weak_ptr_factory_.GetWeakPtr()));
+
return true;
}
@@ -293,6 +304,10 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
return true;
}
+void Channel::ChannelImpl::CallOnChannelConnected() {
+ listener()->OnChannelConnected(peer_pid());
+}
+
Channel::ChannelImpl::ReadState Channel::ChannelImpl::ReadData(
char* buffer,
int buffer_len,
@@ -372,9 +387,7 @@ void Channel::Close() {
}
base::ProcessId Channel::peer_pid() const {
- // This shouldn't actually get used in the untrusted side of the proxy, and we
- // don't have the real pid anyway.
- return -1;
+ return channel_impl_->peer_pid();
}
bool Channel::Send(Message* message) {
« no previous file with comments | « ipc/ipc_channel_nacl.h ('k') | ipc/ipc_channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698