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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 975903002: Add a flag to dump IPC messages sent from the renderer to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove BUILD.gn changes, since the IPC fuzzer doesn't work with gn Created 5 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 unified diff | Download patch
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // the consumer of IPC::ChannelProxy the ability to respond to incoming 50 // the consumer of IPC::ChannelProxy the ability to respond to incoming
51 // messages on this background thread instead of on their own thread, which may 51 // messages on this background thread instead of on their own thread, which may
52 // be bogged down with other processing. The result can be greatly improved 52 // be bogged down with other processing. The result can be greatly improved
53 // latency for messages that can be handled on a background thread. 53 // latency for messages that can be handled on a background thread.
54 // 54 //
55 // The consumer of IPC::ChannelProxy is responsible for allocating the Thread 55 // The consumer of IPC::ChannelProxy is responsible for allocating the Thread
56 // instance where the IPC::Channel will be created and operated. 56 // instance where the IPC::Channel will be created and operated.
57 // 57 //
58 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { 58 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
59 public: 59 public:
60 #if defined(ENABLE_IPC_FUZZER)
61 // Interface for a filter to be imposed on outgoing messages which can
62 // re-write the message. Used for testing.
63 class OutgoingMessageFilter {
64 public:
65 virtual Message* Rewrite(Message* message) = 0;
66 };
67 #endif
68
60 // Initializes a channel proxy. The channel_handle and mode parameters are 69 // Initializes a channel proxy. The channel_handle and mode parameters are
61 // passed directly to the underlying IPC::Channel. The listener is called on 70 // passed directly to the underlying IPC::Channel. The listener is called on
62 // the thread that creates the ChannelProxy. The filter's OnMessageReceived 71 // the thread that creates the ChannelProxy. The filter's OnMessageReceived
63 // method is called on the thread where the IPC::Channel is running. The 72 // method is called on the thread where the IPC::Channel is running. The
64 // filter may be null if the consumer is not interested in handling messages 73 // filter may be null if the consumer is not interested in handling messages
65 // on the background thread. Any message not handled by the filter will be 74 // on the background thread. Any message not handled by the filter will be
66 // dispatched to the listener. The given task runner correspond to a thread 75 // dispatched to the listener. The given task runner correspond to a thread
67 // on which IPC::Channel is created and used (e.g. IO thread). 76 // on which IPC::Channel is created and used (e.g. IO thread).
68 static scoped_ptr<ChannelProxy> Create( 77 static scoped_ptr<ChannelProxy> Create(
69 const IPC::ChannelHandle& channel_handle, 78 const IPC::ChannelHandle& channel_handle,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Ordinarily, messages sent to the ChannelProxy are routed to the matching 114 // Ordinarily, messages sent to the ChannelProxy are routed to the matching
106 // listener on the worker thread. This API allows code to intercept messages 115 // listener on the worker thread. This API allows code to intercept messages
107 // before they are sent to the worker thread. 116 // before they are sent to the worker thread.
108 // If you call this before the target process is launched, then you're 117 // If you call this before the target process is launched, then you're
109 // guaranteed to not miss any messages. But if you call this anytime after, 118 // guaranteed to not miss any messages. But if you call this anytime after,
110 // then some messages might be missed since the filter is added internally on 119 // then some messages might be missed since the filter is added internally on
111 // the IO thread. 120 // the IO thread.
112 void AddFilter(MessageFilter* filter); 121 void AddFilter(MessageFilter* filter);
113 void RemoveFilter(MessageFilter* filter); 122 void RemoveFilter(MessageFilter* filter);
114 123
124 #if defined(ENABLE_IPC_FUZZER)
125 void set_outgoing_message_filter(OutgoingMessageFilter* filter) {
126 outgoing_message_filter_ = filter;
127 }
128 #endif
129
115 // Set the task runner on which dispatched messages are posted. Both the new 130 // Set the task runner on which dispatched messages are posted. Both the new
116 // task runner and the existing task runner must run on the same thread, and 131 // task runner and the existing task runner must run on the same thread, and
117 // must belong to the calling thread. 132 // must belong to the calling thread.
118 void SetListenerTaskRunner( 133 void SetListenerTaskRunner(
119 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner); 134 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner);
120 135
121 // Called to clear the pointer to the IPC task runner when it's going away. 136 // Called to clear the pointer to the IPC task runner when it's going away.
122 void ClearIPCTaskRunner(); 137 void ClearIPCTaskRunner();
123 138
124 // Get the process ID for the connected peer. 139 // Get the process ID for the connected peer.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // Lock for pending_filters_. 240 // Lock for pending_filters_.
226 base::Lock pending_filters_lock_; 241 base::Lock pending_filters_lock_;
227 242
228 // Cached copy of the peer process ID. Set on IPC but read on both IPC and 243 // Cached copy of the peer process ID. Set on IPC but read on both IPC and
229 // listener threads. 244 // listener threads.
230 base::ProcessId peer_pid_; 245 base::ProcessId peer_pid_;
231 }; 246 };
232 247
233 Context* context() { return context_.get(); } 248 Context* context() { return context_.get(); }
234 249
250 #if defined(ENABLE_IPC_FUZZER)
251 OutgoingMessageFilter* outgoing_message_filter() const {
252 return outgoing_message_filter_;
253 }
254 #endif
255
235 private: 256 private:
236 friend class IpcSecurityTestUtil; 257 friend class IpcSecurityTestUtil;
237 258
238 // By maintaining this indirection (ref-counted) to our internal state, we 259 // By maintaining this indirection (ref-counted) to our internal state, we
239 // can safely be destroyed while the background thread continues to do stuff 260 // can safely be destroyed while the background thread continues to do stuff
240 // that involves this data. 261 // that involves this data.
241 scoped_refptr<Context> context_; 262 scoped_refptr<Context> context_;
242 263
243 // Whether the channel has been initialized. 264 // Whether the channel has been initialized.
244 bool did_init_; 265 bool did_init_;
266
267 #if defined(ENABLE_IPC_FUZZER)
268 OutgoingMessageFilter* outgoing_message_filter_;
269 #endif
245 }; 270 };
246 271
247 } // namespace IPC 272 } // namespace IPC
248 273
249 #endif // IPC_IPC_CHANNEL_PROXY_H_ 274 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698