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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { | 57 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { |
58 public: | 58 public: |
59 // Initializes a channel proxy. The channel_handle and mode parameters are | 59 // Initializes a channel proxy. The channel_handle and mode parameters are |
60 // passed directly to the underlying IPC::Channel. The listener is called on | 60 // passed directly to the underlying IPC::Channel. The listener is called on |
61 // the thread that creates the ChannelProxy. The filter's OnMessageReceived | 61 // the thread that creates the ChannelProxy. The filter's OnMessageReceived |
62 // method is called on the thread where the IPC::Channel is running. The | 62 // method is called on the thread where the IPC::Channel is running. The |
63 // filter may be null if the consumer is not interested in handling messages | 63 // filter may be null if the consumer is not interested in handling messages |
64 // on the background thread. Any message not handled by the filter will be | 64 // on the background thread. Any message not handled by the filter will be |
65 // dispatched to the listener. The given task runner correspond to a thread | 65 // dispatched to the listener. The given task runner correspond to a thread |
66 // on which IPC::Channel is created and used (e.g. IO thread). | 66 // on which IPC::Channel is created and used (e.g. IO thread). |
67 ChannelProxy(const IPC::ChannelHandle& channel_handle, | 67 static scoped_ptr<ChannelProxy> Create( |
68 Channel::Mode mode, | 68 const IPC::ChannelHandle& channel_handle, |
69 Listener* listener, | 69 Channel::Mode mode, |
70 base::SingleThreadTaskRunner* ipc_task_runner); | 70 Listener* listener, |
71 base::SingleThreadTaskRunner* ipc_task_runner); | |
72 | |
73 // This Create() does not create underlying channel and let Init() do it. | |
jam
2014/06/03 17:30:41
i dont think this is needed if the other code wher
Hajime Morrita
2014/06/03 18:01:59
Unfortunately we cannot remove this as ppapi_dispa
jam
2014/06/03 20:37:31
ah you're right, what about the ChannelProxy::Crea
| |
74 static scoped_ptr<ChannelProxy> Create( | |
75 Listener* listener, | |
76 base::SingleThreadTaskRunner* ipc_task_runner); | |
71 | 77 |
72 virtual ~ChannelProxy(); | 78 virtual ~ChannelProxy(); |
73 | 79 |
74 // Initializes the channel proxy. Only call this once to initialize a channel | 80 // Initializes the channel proxy. Only call this once to initialize a channel |
75 // proxy that was not initialized in its constructor. If create_pipe_now is | 81 // proxy that was not initialized in its constructor. If create_pipe_now is |
76 // true, the pipe is created synchronously. Otherwise it's created on the IO | 82 // true, the pipe is created synchronously. Otherwise it's created on the IO |
77 // thread. | 83 // thread. |
78 void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, | 84 void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, |
79 bool create_pipe_now); | 85 bool create_pipe_now); |
80 | 86 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 int TakeClientFileDescriptor(); | 123 int TakeClientFileDescriptor(); |
118 bool GetPeerEuid(uid_t* peer_euid) const; | 124 bool GetPeerEuid(uid_t* peer_euid) const; |
119 #endif // defined(OS_POSIX) | 125 #endif // defined(OS_POSIX) |
120 | 126 |
121 protected: | 127 protected: |
122 class Context; | 128 class Context; |
123 // A subclass uses this constructor if it needs to add more information | 129 // A subclass uses this constructor if it needs to add more information |
124 // to the internal state. | 130 // to the internal state. |
125 ChannelProxy(Context* context); | 131 ChannelProxy(Context* context); |
126 | 132 |
133 ChannelProxy(Listener* listener, | |
134 base::SingleThreadTaskRunner* ipc_task_runner); | |
135 | |
127 // Used internally to hold state that is referenced on the IPC thread. | 136 // Used internally to hold state that is referenced on the IPC thread. |
128 class Context : public base::RefCountedThreadSafe<Context>, | 137 class Context : public base::RefCountedThreadSafe<Context>, |
129 public Listener { | 138 public Listener { |
130 public: | 139 public: |
131 Context(Listener* listener, base::SingleThreadTaskRunner* ipc_thread); | 140 Context(Listener* listener, base::SingleThreadTaskRunner* ipc_thread); |
132 void ClearIPCTaskRunner(); | 141 void ClearIPCTaskRunner(); |
133 base::SingleThreadTaskRunner* ipc_task_runner() const { | 142 base::SingleThreadTaskRunner* ipc_task_runner() const { |
134 return ipc_task_runner_.get(); | 143 return ipc_task_runner_.get(); |
135 } | 144 } |
136 const std::string& channel_id() const { return channel_id_; } | 145 const std::string& channel_id() const { return channel_id_; } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 // that involves this data. | 230 // that involves this data. |
222 scoped_refptr<Context> context_; | 231 scoped_refptr<Context> context_; |
223 | 232 |
224 // Whether the channel has been initialized. | 233 // Whether the channel has been initialized. |
225 bool did_init_; | 234 bool did_init_; |
226 }; | 235 }; |
227 | 236 |
228 } // namespace IPC | 237 } // namespace IPC |
229 | 238 |
230 #endif // IPC_IPC_CHANNEL_PROXY_H_ | 239 #endif // IPC_IPC_CHANNEL_PROXY_H_ |
OLD | NEW |