| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 // Initializes a channel proxy. The channel_handle and mode parameters are | 77 // Initializes a channel proxy. The channel_handle and mode parameters are |
| 78 // passed directly to the underlying IPC::Channel. The listener is called on | 78 // passed directly to the underlying IPC::Channel. The listener is called on |
| 79 // the thread that creates the ChannelProxy. The filter's OnMessageReceived | 79 // the thread that creates the ChannelProxy. The filter's OnMessageReceived |
| 80 // method is called on the thread where the IPC::Channel is running. The | 80 // method is called on the thread where the IPC::Channel is running. The |
| 81 // filter may be null if the consumer is not interested in handling messages | 81 // filter may be null if the consumer is not interested in handling messages |
| 82 // on the background thread. Any message not handled by the filter will be | 82 // on the background thread. Any message not handled by the filter will be |
| 83 // dispatched to the listener. The given task runner correspond to a thread | 83 // dispatched to the listener. The given task runner correspond to a thread |
| 84 // on which IPC::Channel is created and used (e.g. IO thread). | 84 // on which IPC::Channel is created and used (e.g. IO thread). |
| 85 // TODO(erikchen): Remove default parameter for |broker|. It exists only to |
| 86 // make the upcoming refactor decomposable into smaller CLs. |
| 87 // http://crbug.com/493414. |
| 85 static scoped_ptr<ChannelProxy> Create( | 88 static scoped_ptr<ChannelProxy> Create( |
| 86 const IPC::ChannelHandle& channel_handle, | 89 const IPC::ChannelHandle& channel_handle, |
| 87 Channel::Mode mode, | 90 Channel::Mode mode, |
| 88 Listener* listener, | 91 Listener* listener, |
| 89 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); | 92 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, |
| 93 AttachmentBroker* broker = nullptr); |
| 90 | 94 |
| 91 static scoped_ptr<ChannelProxy> Create( | 95 static scoped_ptr<ChannelProxy> Create( |
| 92 scoped_ptr<ChannelFactory> factory, | 96 scoped_ptr<ChannelFactory> factory, |
| 93 Listener* listener, | 97 Listener* listener, |
| 94 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); | 98 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); |
| 95 | 99 |
| 96 ~ChannelProxy() override; | 100 ~ChannelProxy() override; |
| 97 | 101 |
| 98 // Initializes the channel proxy. Only call this once to initialize a channel | 102 // Initializes the channel proxy. Only call this once to initialize a channel |
| 99 // proxy that was not initialized in its constructor. If create_pipe_now is | 103 // proxy that was not initialized in its constructor. If create_pipe_now is |
| 100 // true, the pipe is created synchronously. Otherwise it's created on the IO | 104 // true, the pipe is created synchronously. Otherwise it's created on the IO |
| 101 // thread. | 105 // thread. |
| 102 void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, | 106 // TODO(erikchen): Remove default parameter for |broker|. It exists only to |
| 103 bool create_pipe_now); | 107 // make the upcoming refactor decomposable into smaller CLs. |
| 108 // http://crbug.com/493414. |
| 109 void Init(const IPC::ChannelHandle& channel_handle, |
| 110 Channel::Mode mode, |
| 111 bool create_pipe_now, |
| 112 AttachmentBroker* broker = nullptr); |
| 104 void Init(scoped_ptr<ChannelFactory> factory, bool create_pipe_now); | 113 void Init(scoped_ptr<ChannelFactory> factory, bool create_pipe_now); |
| 105 | 114 |
| 106 // Close the IPC::Channel. This operation completes asynchronously, once the | 115 // Close the IPC::Channel. This operation completes asynchronously, once the |
| 107 // background thread processes the command to close the channel. It is ok to | 116 // background thread processes the command to close the channel. It is ok to |
| 108 // call this method multiple times. Redundant calls are ignored. | 117 // call this method multiple times. Redundant calls are ignored. |
| 109 // | 118 // |
| 110 // WARNING: MessageFilter objects held by the ChannelProxy is also | 119 // WARNING: MessageFilter objects held by the ChannelProxy is also |
| 111 // released asynchronously, and it may in fact have its final reference | 120 // released asynchronously, and it may in fact have its final reference |
| 112 // released on the background thread. The caller should be careful to deal | 121 // released on the background thread. The caller should be careful to deal |
| 113 // with / allow for this possibility. | 122 // with / allow for this possibility. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 bool did_init_; | 296 bool did_init_; |
| 288 | 297 |
| 289 #if defined(ENABLE_IPC_FUZZER) | 298 #if defined(ENABLE_IPC_FUZZER) |
| 290 OutgoingMessageFilter* outgoing_message_filter_; | 299 OutgoingMessageFilter* outgoing_message_filter_; |
| 291 #endif | 300 #endif |
| 292 }; | 301 }; |
| 293 | 302 |
| 294 } // namespace IPC | 303 } // namespace IPC |
| 295 | 304 |
| 296 #endif // IPC_IPC_CHANNEL_PROXY_H_ | 305 #endif // IPC_IPC_CHANNEL_PROXY_H_ |
| OLD | NEW |