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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 2068343003: Revert "Send input event IPCs directly from the UI thread" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 | « content/public/test/mock_render_process_host.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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // Close the IPC::Channel. This operation completes asynchronously, once the 116 // Close the IPC::Channel. This operation completes asynchronously, once the
117 // background thread processes the command to close the channel. It is ok to 117 // background thread processes the command to close the channel. It is ok to
118 // call this method multiple times. Redundant calls are ignored. 118 // call this method multiple times. Redundant calls are ignored.
119 // 119 //
120 // WARNING: MessageFilter objects held by the ChannelProxy is also 120 // WARNING: MessageFilter objects held by the ChannelProxy is also
121 // released asynchronously, and it may in fact have its final reference 121 // released asynchronously, and it may in fact have its final reference
122 // released on the background thread. The caller should be careful to deal 122 // released on the background thread. The caller should be careful to deal
123 // with / allow for this possibility. 123 // with / allow for this possibility.
124 void Close(); 124 void Close();
125 125
126 // DEPRECATED: Please use either SendNow or SendOnIPCThread to make ordering 126 // Send a message asynchronously. The message is routed to the background
127 // expectations explicit. 127 // thread where it is passed to the IPC::Channel's Send method.
128 //
129 // This is an alias for for SendOnIPCThread.
130 bool Send(Message* message) override; 128 bool Send(Message* message) override;
131 129
132 // Send a message as soon as possible. This method may send the message
133 // immediately, or it may defer and send on the IPC thread. Use this when you
134 // you don't care about strict ordering of the send operation with respect to
135 // tasks on the IPC thread. This is most commonly what you want.
136 virtual bool SendNow(std::unique_ptr<Message> message);
137
138 // Send a message from the IPC thread. This immediately posts a task to the
139 // IPC thread task runner to send the message. Use this when you're posting
140 // other related tasks to the IPC thread and you need to guarantee that the
141 // send operation is ordered with respect to those tasks.
142 virtual bool SendOnIPCThread(std::unique_ptr<Message> message);
143
144 // Used to intercept messages as they are received on the background thread. 130 // Used to intercept messages as they are received on the background thread.
145 // 131 //
146 // Ordinarily, messages sent to the ChannelProxy are routed to the matching 132 // Ordinarily, messages sent to the ChannelProxy are routed to the matching
147 // listener on the worker thread. This API allows code to intercept messages 133 // listener on the worker thread. This API allows code to intercept messages
148 // before they are sent to the worker thread. 134 // before they are sent to the worker thread.
149 // If you call this before the target process is launched, then you're 135 // If you call this before the target process is launched, then you're
150 // guaranteed to not miss any messages. But if you call this anytime after, 136 // guaranteed to not miss any messages. But if you call this anytime after,
151 // then some messages might be missed since the filter is added internally on 137 // then some messages might be missed since the filter is added internally on
152 // the IO thread. 138 // the IO thread.
153 void AddFilter(MessageFilter* filter); 139 void AddFilter(MessageFilter* filter);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 void ClearIPCTaskRunner(); 174 void ClearIPCTaskRunner();
189 base::SingleThreadTaskRunner* ipc_task_runner() const { 175 base::SingleThreadTaskRunner* ipc_task_runner() const {
190 return ipc_task_runner_.get(); 176 return ipc_task_runner_.get();
191 } 177 }
192 const std::string& channel_id() const { return channel_id_; } 178 const std::string& channel_id() const { return channel_id_; }
193 179
194 // Dispatches a message on the listener thread. 180 // Dispatches a message on the listener thread.
195 void OnDispatchMessage(const Message& message); 181 void OnDispatchMessage(const Message& message);
196 182
197 // Sends |message| from appropriate thread. 183 // Sends |message| from appropriate thread.
198 bool Send(std::unique_ptr<Message> message, bool force_io_thread); 184 void Send(Message* message);
199 185
200 // Indicates if the underlying channel's Send is thread-safe. 186 // Indicates if the underlying channel's Send is thread-safe.
201 bool IsChannelSendThreadSafe() const; 187 bool IsChannelSendThreadSafe() const;
202 188
203 protected: 189 protected:
204 friend class base::RefCountedThreadSafe<Context>; 190 friend class base::RefCountedThreadSafe<Context>;
205 ~Context() override; 191 ~Context() override;
206 192
207 // IPC::Listener methods: 193 // IPC::Listener methods:
208 bool OnMessageReceived(const Message& message) override; 194 bool OnMessageReceived(const Message& message) override;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 void OnSendMessage(std::unique_ptr<Message> message_ptr); 228 void OnSendMessage(std::unique_ptr<Message> message_ptr);
243 void OnAddFilter(); 229 void OnAddFilter();
244 void OnRemoveFilter(MessageFilter* filter); 230 void OnRemoveFilter(MessageFilter* filter);
245 231
246 // Methods called on the listener thread. 232 // Methods called on the listener thread.
247 void AddFilter(MessageFilter* filter); 233 void AddFilter(MessageFilter* filter);
248 void OnDispatchConnected(); 234 void OnDispatchConnected();
249 void OnDispatchError(); 235 void OnDispatchError();
250 void OnDispatchBadMessage(const Message& message); 236 void OnDispatchBadMessage(const Message& message);
251 237
238 void SendFromThisThread(Message* message);
252 void ClearChannel(); 239 void ClearChannel();
253 240
254 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; 241 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_;
255 Listener* listener_; 242 Listener* listener_;
256 243
257 // List of filters. This is only accessed on the IPC thread. 244 // List of filters. This is only accessed on the IPC thread.
258 std::vector<scoped_refptr<MessageFilter> > filters_; 245 std::vector<scoped_refptr<MessageFilter> > filters_;
259 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; 246 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
260 247
261 // Note, channel_ may be set on the Listener thread or the IPC thread. 248 // Note, channel_ may be set on the Listener thread or the IPC thread.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 289
303 protected: 290 protected:
304 bool did_init() const { return did_init_; } 291 bool did_init() const { return did_init_; }
305 292
306 private: 293 private:
307 friend class IpcSecurityTestUtil; 294 friend class IpcSecurityTestUtil;
308 295
309 // Always called once immediately after Init. 296 // Always called once immediately after Init.
310 virtual void OnChannelInit(); 297 virtual void OnChannelInit();
311 298
312 bool SendImpl(std::unique_ptr<Message> message, bool force_io_thread);
313
314 // By maintaining this indirection (ref-counted) to our internal state, we 299 // By maintaining this indirection (ref-counted) to our internal state, we
315 // can safely be destroyed while the background thread continues to do stuff 300 // can safely be destroyed while the background thread continues to do stuff
316 // that involves this data. 301 // that involves this data.
317 scoped_refptr<Context> context_; 302 scoped_refptr<Context> context_;
318 303
319 // Whether the channel has been initialized. 304 // Whether the channel has been initialized.
320 bool did_init_; 305 bool did_init_;
321 306
322 #if defined(ENABLE_IPC_FUZZER) 307 #if defined(ENABLE_IPC_FUZZER)
323 OutgoingMessageFilter* outgoing_message_filter_; 308 OutgoingMessageFilter* outgoing_message_filter_;
324 #endif 309 #endif
325 }; 310 };
326 311
327 } // namespace IPC 312 } // namespace IPC
328 313
329 #endif // IPC_IPC_CHANNEL_PROXY_H_ 314 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « content/public/test/mock_render_process_host.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698