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

Unified Diff: ipc/ipc_channel_proxy.cc

Issue 9968111: Make IPC channels track their peer process ID (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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
Index: ipc/ipc_channel_proxy.cc
===================================================================
--- ipc/ipc_channel_proxy.cc (revision 130443)
+++ ipc/ipc_channel_proxy.cc (working copy)
@@ -66,7 +66,6 @@
: listener_message_loop_(base::MessageLoopProxy::current()),
listener_(listener),
ipc_message_loop_(ipc_message_loop),
- peer_pid_(0),
channel_connected_called_(false) {
}
@@ -126,7 +125,6 @@
// the filter is run on the IO thread.
OnAddFilter();
- peer_pid_ = peer_pid;
for (size_t i = 0; i < filters_.size(); ++i)
filters_[i]->OnChannelConnected(peer_pid);
@@ -208,11 +206,13 @@
// If the channel has already been created, then we need to send this
// message so that the filter gets access to the Channel.
- if (channel_.get())
+ if (channel_.get()) {
new_filters[i]->OnFilterAdded(channel_.get());
- // Ditto for if the channel has been connected.
- if (peer_pid_)
- new_filters[i]->OnChannelConnected(peer_pid_);
+ // Ditto for if the channel has been connected.
+ base::ProcessId peer_pid = channel_->peer_pid();
+ if (peer_pid)
+ new_filters[i]->OnChannelConnected(peer_pid);
+ }
}
}
@@ -280,7 +280,7 @@
channel_connected_called_ = true;
if (listener_)
- listener_->OnChannelConnected(peer_pid_);
+ listener_->OnChannelConnected(channel_->peer_pid());
}
// Called on the listener's thread
@@ -386,6 +386,12 @@
context()->ClearIPCMessageLoop();
}
+base::ProcessId ChannelProxy::peer_pid() const {
jam 2012/04/04 19:05:00 ChannelProxy gets called on the listener thread, b
jschuh 2012/04/04 19:18:08 That is a subtlety I definitely did not appreciate
+ if (context_.get() && context_->channel_.get())
+ return context_->channel_->peer_pid();
+ return 0;
Tom Sepez 2012/04/04 19:07:07 return base::kNullProcessId constant? Any reason
jschuh 2012/04/04 21:05:13 Done.
+}
+
#if defined(OS_POSIX) && !defined(OS_NACL)
// See the TODO regarding lazy initialization of the channel in
// ChannelProxy::Init().

Powered by Google App Engine
This is Rietveld 408576698