| OLD | NEW |
| 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 Loading... |
| 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 |create_paused| is true, outgoing messages will continue to be |
| 117 // queued until Unpause() is called. |
| 117 void Init(const IPC::ChannelHandle& channel_handle, | 118 void Init(const IPC::ChannelHandle& channel_handle, |
| 118 Channel::Mode mode, | 119 Channel::Mode mode, |
| 119 bool create_pipe_now); | 120 bool create_pipe_now, |
| 120 void Init(std::unique_ptr<ChannelFactory> factory, bool create_pipe_now); | 121 bool create_paused = false); |
| 122 void Init(std::unique_ptr<ChannelFactory> factory, |
| 123 bool create_pipe_now, |
| 124 bool create_paused = false); |
| 125 |
| 126 // Unpause the channel. Only useful if Init was called with |create_paused|. |
| 127 // If |flush| is true the channel will be flushed as soon as it's unpaused. |
| 128 // Otherwise you must explicitly call Flush() to flush messages which were |
| 129 // queued while the channel was paused. |
| 130 void Unpause(bool flush); |
| 131 |
| 132 // Flush the channel. This sends any messages which were queued before calling |
| 133 // Connect. Only useful if Unpause(false) was called previously. |
| 134 void Flush(); |
| 121 | 135 |
| 122 // Close the IPC::Channel. This operation completes asynchronously, once the | 136 // Close the IPC::Channel. This operation completes asynchronously, once the |
| 123 // background thread processes the command to close the channel. It is ok to | 137 // background thread processes the command to close the channel. It is ok to |
| 124 // call this method multiple times. Redundant calls are ignored. | 138 // call this method multiple times. Redundant calls are ignored. |
| 125 // | 139 // |
| 126 // WARNING: MessageFilter objects held by the ChannelProxy is also | 140 // WARNING: MessageFilter objects held by the ChannelProxy is also |
| 127 // released asynchronously, and it may in fact have its final reference | 141 // released asynchronously, and it may in fact have its final reference |
| 128 // released on the background thread. The caller should be careful to deal | 142 // released on the background thread. The caller should be careful to deal |
| 129 // with / allow for this possibility. | 143 // with / allow for this possibility. |
| 130 void Close(); | 144 void Close(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 void OnChannelConnected(int32_t peer_pid) override; | 281 void OnChannelConnected(int32_t peer_pid) override; |
| 268 void OnChannelError() override; | 282 void OnChannelError() override; |
| 269 | 283 |
| 270 // Like OnMessageReceived but doesn't try the filters. | 284 // Like OnMessageReceived but doesn't try the filters. |
| 271 bool OnMessageReceivedNoFilter(const Message& message); | 285 bool OnMessageReceivedNoFilter(const Message& message); |
| 272 | 286 |
| 273 // Gives the filters a chance at processing |message|. | 287 // Gives the filters a chance at processing |message|. |
| 274 // Returns true if the message was processed, false otherwise. | 288 // Returns true if the message was processed, false otherwise. |
| 275 bool TryFilters(const Message& message); | 289 bool TryFilters(const Message& message); |
| 276 | 290 |
| 291 void UnpauseChannel(bool flush); |
| 292 void FlushChannel(); |
| 293 |
| 277 // Like Open and Close, but called on the IPC thread. | 294 // Like Open and Close, but called on the IPC thread. |
| 278 virtual void OnChannelOpened(); | 295 virtual void OnChannelOpened(bool pause); |
| 279 virtual void OnChannelClosed(); | 296 virtual void OnChannelClosed(); |
| 280 | 297 |
| 281 // Called on the consumers thread when the ChannelProxy is closed. At that | 298 // 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 | 299 // 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! | 300 // more messages, so we honor that wish by forgetting them! |
| 284 virtual void Clear(); | 301 virtual void Clear(); |
| 285 | 302 |
| 286 private: | 303 private: |
| 287 friend class ChannelProxy; | 304 friend class ChannelProxy; |
| 288 friend class IpcSecurityTestUtil; | 305 friend class IpcSecurityTestUtil; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 bool did_init_; | 422 bool did_init_; |
| 406 | 423 |
| 407 #if defined(ENABLE_IPC_FUZZER) | 424 #if defined(ENABLE_IPC_FUZZER) |
| 408 OutgoingMessageFilter* outgoing_message_filter_; | 425 OutgoingMessageFilter* outgoing_message_filter_; |
| 409 #endif | 426 #endif |
| 410 }; | 427 }; |
| 411 | 428 |
| 412 } // namespace IPC | 429 } // namespace IPC |
| 413 | 430 |
| 414 #endif // IPC_IPC_CHANNEL_PROXY_H_ | 431 #endif // IPC_IPC_CHANNEL_PROXY_H_ |
| OLD | NEW |