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