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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 2301123004: Mojo Channel: Fix deferred proxy dispatch; support paused channels (Closed)
Patch Set: Created 4 years, 3 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
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 <map> 10 #include <map>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); 104 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner);
105 105
106 // Constructs a ChannelProxy without initializing it. 106 // Constructs a ChannelProxy without initializing it.
107 ChannelProxy( 107 ChannelProxy(
108 Listener* listener, 108 Listener* listener,
109 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); 109 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner);
110 110
111 ~ChannelProxy() override; 111 ~ChannelProxy() override;
112 112
113 // Initializes the channel proxy. Only call this once to initialize a channel 113 // Initializes the channel proxy. Only call this once to initialize a channel
114 // proxy that was not initialized in its constructor. If create_pipe_now is 114 // proxy that was not initialized in its constructor. If |create_pipe_now| is
115 // true, the pipe is created synchronously. Otherwise it's created on the IO 115 // true, the pipe is created synchronously. Otherwise it's created on the IO
116 // thread. 116 // thread. If |connect_now| is true, pipe connection is initiated immediately.
yzshen1 2016/09/02 22:03:36 this comment seems outdated.
Ken Rockot(use gerrit already) 2016/09/06 17:21:27 Oops, yes, updated
117 // Otherwise, Connect() must be explicitly called before the channel will
118 // actually send or receive any messages. Send() et al are safe to call before
119 // connection; outgoing messages are queued internally and will be flushed as
120 // soon as connection is complete.
117 void Init(const IPC::ChannelHandle& channel_handle, 121 void Init(const IPC::ChannelHandle& channel_handle,
118 Channel::Mode mode, 122 Channel::Mode mode,
119 bool create_pipe_now); 123 bool create_pipe_now,
120 void Init(std::unique_ptr<ChannelFactory> factory, bool create_pipe_now); 124 bool create_paused = false);
125 void Init(std::unique_ptr<ChannelFactory> factory,
126 bool create_pipe_now,
127 bool create_paused = false);
128
129 // Unpause the channel. Only useful if Init was called with |create_paused|.
130 // If |flush| is true the channel will be flushed as soon as it's unpaused.
131 // Otherwise you must explicitly call Flush() to flush messages which were
132 // queued while the channel was paused.
133 void Unpause(bool flush);
134
135 // Flush the channel. This sends any messages which were queued before calling
136 // Connect. Only useful if Unpause(false) was called previously.
137 void Flush();
121 138
122 // Close the IPC::Channel. This operation completes asynchronously, once the 139 // Close the IPC::Channel. This operation completes asynchronously, once the
123 // background thread processes the command to close the channel. It is ok to 140 // background thread processes the command to close the channel. It is ok to
124 // call this method multiple times. Redundant calls are ignored. 141 // call this method multiple times. Redundant calls are ignored.
125 // 142 //
126 // WARNING: MessageFilter objects held by the ChannelProxy is also 143 // WARNING: MessageFilter objects held by the ChannelProxy is also
127 // released asynchronously, and it may in fact have its final reference 144 // released asynchronously, and it may in fact have its final reference
128 // released on the background thread. The caller should be careful to deal 145 // released on the background thread. The caller should be careful to deal
129 // with / allow for this possibility. 146 // with / allow for this possibility.
130 void Close(); 147 void Close();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void OnChannelConnected(int32_t peer_pid) override; 284 void OnChannelConnected(int32_t peer_pid) override;
268 void OnChannelError() override; 285 void OnChannelError() override;
269 286
270 // Like OnMessageReceived but doesn't try the filters. 287 // Like OnMessageReceived but doesn't try the filters.
271 bool OnMessageReceivedNoFilter(const Message& message); 288 bool OnMessageReceivedNoFilter(const Message& message);
272 289
273 // Gives the filters a chance at processing |message|. 290 // Gives the filters a chance at processing |message|.
274 // Returns true if the message was processed, false otherwise. 291 // Returns true if the message was processed, false otherwise.
275 bool TryFilters(const Message& message); 292 bool TryFilters(const Message& message);
276 293
294 void UnpauseChannel(bool flush);
295 void FlushChannel();
296
277 // Like Open and Close, but called on the IPC thread. 297 // Like Open and Close, but called on the IPC thread.
278 virtual void OnChannelOpened(); 298 virtual void OnChannelOpened(bool pause);
279 virtual void OnChannelClosed(); 299 virtual void OnChannelClosed();
280 300
281 // Called on the consumers thread when the ChannelProxy is closed. At that 301 // Called on the consumers thread when the ChannelProxy is closed. At that
282 // point the consumer is telling us that they don't want to receive any 302 // point the consumer is telling us that they don't want to receive any
283 // more messages, so we honor that wish by forgetting them! 303 // more messages, so we honor that wish by forgetting them!
284 virtual void Clear(); 304 virtual void Clear();
285 305
286 private: 306 private:
287 friend class ChannelProxy; 307 friend class ChannelProxy;
288 friend class IpcSecurityTestUtil; 308 friend class IpcSecurityTestUtil;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 bool did_init_; 425 bool did_init_;
406 426
407 #if defined(ENABLE_IPC_FUZZER) 427 #if defined(ENABLE_IPC_FUZZER)
408 OutgoingMessageFilter* outgoing_message_filter_; 428 OutgoingMessageFilter* outgoing_message_filter_;
409 #endif 429 #endif
410 }; 430 };
411 431
412 } // namespace IPC 432 } // namespace IPC
413 433
414 #endif // IPC_IPC_CHANNEL_PROXY_H_ 434 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698