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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 7712022: This patch caused Chrome to be unable to load any web pages on Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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_posix.cc ('k') | ipc/ipc_channel_proxy.cc » ('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 #ifndef IPC_IPC_CHANNEL_PROXY_H_ 5 #ifndef IPC_IPC_CHANNEL_PROXY_H_
6 #define IPC_IPC_CHANNEL_PROXY_H_ 6 #define IPC_IPC_CHANNEL_PROXY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // passed directly to the underlying IPC::Channel. The listener is called on 111 // passed directly to the underlying IPC::Channel. The listener is called on
112 // the thread that creates the ChannelProxy. The filter's OnMessageReceived 112 // the thread that creates the ChannelProxy. The filter's OnMessageReceived
113 // method is called on the thread where the IPC::Channel is running. The 113 // method is called on the thread where the IPC::Channel is running. The
114 // filter may be null if the consumer is not interested in handling messages 114 // filter may be null if the consumer is not interested in handling messages
115 // on the background thread. Any message not handled by the filter will be 115 // on the background thread. Any message not handled by the filter will be
116 // dispatched to the listener. The given message loop indicates where the 116 // dispatched to the listener. The given message loop indicates where the
117 // IPC::Channel should be created. 117 // IPC::Channel should be created.
118 ChannelProxy(const IPC::ChannelHandle& channel_handle, 118 ChannelProxy(const IPC::ChannelHandle& channel_handle,
119 Channel::Mode mode, 119 Channel::Mode mode,
120 Channel::Listener* listener, 120 Channel::Listener* listener,
121 base::MessageLoopProxy* ipc_thread_loop, 121 base::MessageLoopProxy* ipc_thread_loop);
122 bool needs_override_peer_pid);
123 122
124 virtual ~ChannelProxy(); 123 virtual ~ChannelProxy();
125 124
126 // Close the IPC::Channel. This operation completes asynchronously, once the 125 // Close the IPC::Channel. This operation completes asynchronously, once the
127 // background thread processes the command to close the channel. It is ok to 126 // background thread processes the command to close the channel. It is ok to
128 // call this method multiple times. Redundant calls are ignored. 127 // call this method multiple times. Redundant calls are ignored.
129 // 128 //
130 // WARNING: The MessageFilter object held by the ChannelProxy is also 129 // WARNING: The MessageFilter object held by the ChannelProxy is also
131 // released asynchronously, and it may in fact have its final reference 130 // released asynchronously, and it may in fact have its final reference
132 // released on the background thread. The caller should be careful to deal 131 // released on the background thread. The caller should be careful to deal
(...skipping 22 matching lines...) Expand all
155 154
156 // Called to clear the pointer to the IPC message loop when it's going away. 155 // Called to clear the pointer to the IPC message loop when it's going away.
157 void ClearIPCMessageLoop(); 156 void ClearIPCMessageLoop();
158 157
159 #if defined(OS_POSIX) 158 #if defined(OS_POSIX)
160 // Calls through to the underlying channel's methods. 159 // Calls through to the underlying channel's methods.
161 int GetClientFileDescriptor() const; 160 int GetClientFileDescriptor() const;
162 bool GetClientEuid(uid_t* client_euid) const; 161 bool GetClientEuid(uid_t* client_euid) const;
163 #endif // defined(OS_POSIX) 162 #endif // defined(OS_POSIX)
164 163
165 #if defined(OS_LINUX)
166 // Calls through to the underlying channel's method.
167 void OverridePeerPid(int32 peer_pid);
168 #endif // defined(OS_LINUX)
169
170 protected: 164 protected:
171 class Context; 165 class Context;
172 // A subclass uses this constructor if it needs to add more information 166 // A subclass uses this constructor if it needs to add more information
173 // to the internal state. If create_pipe_now is true, the pipe is created 167 // to the internal state. If create_pipe_now is true, the pipe is created
174 // immediately. Otherwise it's created on the IO thread. 168 // immediately. Otherwise it's created on the IO thread.
175 ChannelProxy(const IPC::ChannelHandle& channel_handle, 169 ChannelProxy(const IPC::ChannelHandle& channel_handle,
176 Channel::Mode mode, 170 Channel::Mode mode,
177 base::MessageLoopProxy* ipc_thread_loop, 171 base::MessageLoopProxy* ipc_thread_loop,
178 bool needs_override_peer_pid,
179 Context* context, 172 Context* context,
180 bool create_pipe_now); 173 bool create_pipe_now);
181 174
182 // Used internally to hold state that is referenced on the IPC thread. 175 // Used internally to hold state that is referenced on the IPC thread.
183 class Context : public base::RefCountedThreadSafe<Context>, 176 class Context : public base::RefCountedThreadSafe<Context>,
184 public Channel::Listener { 177 public Channel::Listener {
185 public: 178 public:
186 Context(Channel::Listener* listener, base::MessageLoopProxy* ipc_thread); 179 Context(Channel::Listener* listener, base::MessageLoopProxy* ipc_thread);
187 void ClearIPCMessageLoop() { ipc_message_loop_ = NULL; } 180 void ClearIPCMessageLoop() { ipc_message_loop_ = NULL; }
188 base::MessageLoopProxy* ipc_message_loop() const { 181 base::MessageLoopProxy* ipc_message_loop() const {
(...skipping 28 matching lines...) Expand all
217 // point the consumer is telling us that they don't want to receive any 210 // point the consumer is telling us that they don't want to receive any
218 // more messages, so we honor that wish by forgetting them! 211 // more messages, so we honor that wish by forgetting them!
219 virtual void Clear() { listener_ = NULL; } 212 virtual void Clear() { listener_ = NULL; }
220 213
221 private: 214 private:
222 friend class ChannelProxy; 215 friend class ChannelProxy;
223 friend class SendTask; 216 friend class SendTask;
224 217
225 // Create the Channel 218 // Create the Channel
226 void CreateChannel(const IPC::ChannelHandle& channel_handle, 219 void CreateChannel(const IPC::ChannelHandle& channel_handle,
227 const Channel::Mode& mode, 220 const Channel::Mode& mode);
228 bool needs_override_peer_pid);
229 221
230 // Methods called on the IO thread. 222 // Methods called on the IO thread.
231 void OnSendMessage(Message* message_ptr); 223 void OnSendMessage(Message* message_ptr);
232 void OnAddFilter(); 224 void OnAddFilter();
233 void OnRemoveFilter(MessageFilter* filter); 225 void OnRemoveFilter(MessageFilter* filter);
234 #if defined(OS_LINUX)
235 void OnOverridePeerPid(int32 peer_pid);
236 #endif
237 226
238 // Methods called on the listener thread. 227 // Methods called on the listener thread.
239 void AddFilter(MessageFilter* filter); 228 void AddFilter(MessageFilter* filter);
240 void OnDispatchConnected(); 229 void OnDispatchConnected();
241 void OnDispatchError(); 230 void OnDispatchError();
242 231
243 scoped_refptr<base::MessageLoopProxy> listener_message_loop_; 232 scoped_refptr<base::MessageLoopProxy> listener_message_loop_;
244 Channel::Listener* listener_; 233 Channel::Listener* listener_;
245 234
246 // List of filters. This is only accessed on the IPC thread. 235 // List of filters. This is only accessed on the IPC thread.
(...skipping 14 matching lines...) Expand all
261 Context* context() { return context_; } 250 Context* context() { return context_; }
262 251
263 OutgoingMessageFilter* outgoing_message_filter() { 252 OutgoingMessageFilter* outgoing_message_filter() {
264 return outgoing_message_filter_; 253 return outgoing_message_filter_;
265 } 254 }
266 255
267 private: 256 private:
268 friend class SendTask; 257 friend class SendTask;
269 258
270 void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, 259 void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode,
271 base::MessageLoopProxy* ipc_thread_loop, bool create_pipe_now, 260 base::MessageLoopProxy* ipc_thread_loop, bool create_pipe_now);
272 bool needs_override_peer_pid);
273 261
274 // By maintaining this indirection (ref-counted) to our internal state, we 262 // By maintaining this indirection (ref-counted) to our internal state, we
275 // can safely be destroyed while the background thread continues to do stuff 263 // can safely be destroyed while the background thread continues to do stuff
276 // that involves this data. 264 // that involves this data.
277 scoped_refptr<Context> context_; 265 scoped_refptr<Context> context_;
278 266
279 OutgoingMessageFilter* outgoing_message_filter_; 267 OutgoingMessageFilter* outgoing_message_filter_;
280 }; 268 };
281 269
282 } // namespace IPC 270 } // namespace IPC
283 271
284 #endif // IPC_IPC_CHANNEL_PROXY_H_ 272 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698