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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 2316963005: Reworks Channel pausing behavior (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
« no previous file with comments | « ipc/ipc_channel_mojo_unittest.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 <map> 10 #include <map>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. If |create_paused| is true, outgoing messages will continue to be 116 // thread.
117 // queued until Unpause() is called.
118 void Init(const IPC::ChannelHandle& channel_handle, 117 void Init(const IPC::ChannelHandle& channel_handle,
119 Channel::Mode mode, 118 Channel::Mode mode,
120 bool create_pipe_now, 119 bool create_pipe_now);
121 bool create_paused = false);
122 void Init(std::unique_ptr<ChannelFactory> factory, 120 void Init(std::unique_ptr<ChannelFactory> factory,
123 bool create_pipe_now, 121 bool create_pipe_now);
124 bool create_paused = false);
125 122
126 // Unpause the channel. Only useful if Init was called with |create_paused|. 123 // Pause the channel. Subsequent calls to Send() will be internally queued
127 // If |flush| is true the channel will be flushed as soon as it's unpaused. 124 // until Unpause() is called. Queued messages will not be sent until the
128 // Otherwise you must explicitly call Flush() to flush messages which were 125 // channel is flushed.
129 // queued while the channel was paused. 126 void Pause();
127
128 // Unpause the channel. If |flush| is true the channel will be flushed as soon
129 // as it's unpaused (see Flush() below.) Otherwise you must explicitly call
130 // Flush() to flush messages which were queued while the channel was paused.
130 void Unpause(bool flush); 131 void Unpause(bool flush);
131 132
132 // Flush the channel. This sends any messages which were queued before calling 133 // Flush the channel. This sends any messages which were queued before calling
133 // Connect. Only useful if Unpause(false) was called previously. 134 // Connect. Only useful if Unpause(false) was called previously.
134 void Flush(); 135 void Flush();
135 136
136 // Close the IPC::Channel. This operation completes asynchronously, once the 137 // Close the IPC::Channel. This operation completes asynchronously, once the
137 // background thread processes the command to close the channel. It is ok to 138 // background thread processes the command to close the channel. It is ok to
138 // call this method multiple times. Redundant calls are ignored. 139 // call this method multiple times. Redundant calls are ignored.
139 // 140 //
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 void OnChannelConnected(int32_t peer_pid) override; 282 void OnChannelConnected(int32_t peer_pid) override;
282 void OnChannelError() override; 283 void OnChannelError() override;
283 284
284 // Like OnMessageReceived but doesn't try the filters. 285 // Like OnMessageReceived but doesn't try the filters.
285 bool OnMessageReceivedNoFilter(const Message& message); 286 bool OnMessageReceivedNoFilter(const Message& message);
286 287
287 // Gives the filters a chance at processing |message|. 288 // Gives the filters a chance at processing |message|.
288 // Returns true if the message was processed, false otherwise. 289 // Returns true if the message was processed, false otherwise.
289 bool TryFilters(const Message& message); 290 bool TryFilters(const Message& message);
290 291
292 void PauseChannel();
291 void UnpauseChannel(bool flush); 293 void UnpauseChannel(bool flush);
292 void FlushChannel(); 294 void FlushChannel();
293 295
294 // Like Open and Close, but called on the IPC thread. 296 // Like Open and Close, but called on the IPC thread.
295 virtual void OnChannelOpened(bool pause); 297 virtual void OnChannelOpened();
296 virtual void OnChannelClosed(); 298 virtual void OnChannelClosed();
297 299
298 // Called on the consumers thread when the ChannelProxy is closed. At that 300 // Called on the consumers thread when the ChannelProxy is closed. At that
299 // point the consumer is telling us that they don't want to receive any 301 // point the consumer is telling us that they don't want to receive any
300 // more messages, so we honor that wish by forgetting them! 302 // more messages, so we honor that wish by forgetting them!
301 virtual void Clear(); 303 virtual void Clear();
302 304
303 private: 305 private:
304 friend class ChannelProxy; 306 friend class ChannelProxy;
305 friend class IpcSecurityTestUtil; 307 friend class IpcSecurityTestUtil;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 bool did_init_; 424 bool did_init_;
423 425
424 #if defined(ENABLE_IPC_FUZZER) 426 #if defined(ENABLE_IPC_FUZZER)
425 OutgoingMessageFilter* outgoing_message_filter_; 427 OutgoingMessageFilter* outgoing_message_filter_;
426 #endif 428 #endif
427 }; 429 };
428 430
429 } // namespace IPC 431 } // namespace IPC
430 432
431 #endif // IPC_IPC_CHANNEL_PROXY_H_ 433 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_mojo_unittest.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698