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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_channel_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 delete this; 59 delete this;
60 } 60 }
61 61
62 //------------------------------------------------------------------------------ 62 //------------------------------------------------------------------------------
63 63
64 ChannelProxy::Context::Context(Channel::Listener* listener, 64 ChannelProxy::Context::Context(Channel::Listener* listener,
65 base::MessageLoopProxy* ipc_message_loop) 65 base::MessageLoopProxy* ipc_message_loop)
66 : listener_message_loop_(base::MessageLoopProxy::current()), 66 : listener_message_loop_(base::MessageLoopProxy::current()),
67 listener_(listener), 67 listener_(listener),
68 ipc_message_loop_(ipc_message_loop), 68 ipc_message_loop_(ipc_message_loop),
69 peer_pid_(0), 69 channel_connected_called_(false),
70 channel_connected_called_(false) { 70 peer_pid_(base::kNullProcessId) {
71 } 71 }
72 72
73 ChannelProxy::Context::~Context() { 73 ChannelProxy::Context::~Context() {
74 } 74 }
75 75
76 void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, 76 void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle,
77 const Channel::Mode& mode) { 77 const Channel::Mode& mode) {
78 DCHECK(channel_.get() == NULL); 78 DCHECK(channel_.get() == NULL);
79 channel_id_ = handle.name; 79 channel_id_ = handle.name;
80 channel_.reset(new Channel(handle, mode, this)); 80 channel_.reset(new Channel(handle, mode, this));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 // Called on the IPC::Channel thread 121 // Called on the IPC::Channel thread
122 void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) { 122 void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) {
123 // Add any pending filters. This avoids a race condition where someone 123 // Add any pending filters. This avoids a race condition where someone
124 // creates a ChannelProxy, calls AddFilter, and then right after starts the 124 // creates a ChannelProxy, calls AddFilter, and then right after starts the
125 // peer process. The IO thread could receive a message before the task to add 125 // peer process. The IO thread could receive a message before the task to add
126 // the filter is run on the IO thread. 126 // the filter is run on the IO thread.
127 OnAddFilter(); 127 OnAddFilter();
128 128
129 peer_pid_ = peer_pid; 129 // We cache off the peer_pid so it can be safely accessed from both threads.
130 peer_pid_ = channel_->peer_pid();
130 for (size_t i = 0; i < filters_.size(); ++i) 131 for (size_t i = 0; i < filters_.size(); ++i)
131 filters_[i]->OnChannelConnected(peer_pid); 132 filters_[i]->OnChannelConnected(peer_pid);
132 133
133 // See above comment about using listener_message_loop_ here. 134 // See above comment about using listener_message_loop_ here.
134 listener_message_loop_->PostTask( 135 listener_message_loop_->PostTask(
135 FROM_HERE, base::Bind(&Context::OnDispatchConnected, this)); 136 FROM_HERE, base::Bind(&Context::OnDispatchConnected, this));
136 } 137 }
137 138
138 // Called on the IPC::Channel thread 139 // Called on the IPC::Channel thread
139 void ChannelProxy::Context::OnChannelError() { 140 void ChannelProxy::Context::OnChannelError() {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 Channel* channel = context_.get()->channel_.get(); 408 Channel* channel = context_.get()->channel_.get();
408 // Channel must have been created first. 409 // Channel must have been created first.
409 DCHECK(channel) << context_.get()->channel_id_; 410 DCHECK(channel) << context_.get()->channel_id_;
410 return channel->GetClientEuid(client_euid); 411 return channel->GetClientEuid(client_euid);
411 } 412 }
412 #endif 413 #endif
413 414
414 //----------------------------------------------------------------------------- 415 //-----------------------------------------------------------------------------
415 416
416 } // namespace IPC 417 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_channel_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698