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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 auto request = mojo::MakeRequest(&ptr_info); | 218 auto request = mojo::MakeRequest(&ptr_info); |
219 GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle()); | 219 GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle()); |
220 *out_ptr = mojo::ThreadSafeAssociatedInterfacePtr<Interface>::Create( | 220 *out_ptr = mojo::ThreadSafeAssociatedInterfacePtr<Interface>::Create( |
221 std::move(ptr_info), ipc_task_runner()); | 221 std::move(ptr_info), ipc_task_runner()); |
222 } | 222 } |
223 | 223 |
224 base::SingleThreadTaskRunner* ipc_task_runner() const { | 224 base::SingleThreadTaskRunner* ipc_task_runner() const { |
225 return context_->ipc_task_runner(); | 225 return context_->ipc_task_runner(); |
226 } | 226 } |
227 | 227 |
| 228 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner_refptr() |
| 229 const { |
| 230 return context_->ipc_task_runner_refptr(); |
| 231 } |
| 232 |
228 // Called to clear the pointer to the IPC task runner when it's going away. | 233 // Called to clear the pointer to the IPC task runner when it's going away. |
229 void ClearIPCTaskRunner(); | 234 void ClearIPCTaskRunner(); |
230 | 235 |
231 protected: | 236 protected: |
232 class Context; | 237 class Context; |
233 // A subclass uses this constructor if it needs to add more information | 238 // A subclass uses this constructor if it needs to add more information |
234 // to the internal state. | 239 // to the internal state. |
235 explicit ChannelProxy(Context* context); | 240 explicit ChannelProxy(Context* context); |
236 | 241 |
237 // Used internally to hold state that is referenced on the IPC thread. | 242 // Used internally to hold state that is referenced on the IPC thread. |
238 class Context : public base::RefCountedThreadSafe<Context>, | 243 class Context : public base::RefCountedThreadSafe<Context>, |
239 public Listener { | 244 public Listener { |
240 public: | 245 public: |
241 Context(Listener* listener, | 246 Context(Listener* listener, |
242 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_thread); | 247 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_thread); |
243 void ClearIPCTaskRunner(); | 248 void ClearIPCTaskRunner(); |
244 base::SingleThreadTaskRunner* ipc_task_runner() const { | 249 base::SingleThreadTaskRunner* ipc_task_runner() const { |
245 return ipc_task_runner_.get(); | 250 return ipc_task_runner_.get(); |
246 } | 251 } |
| 252 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner_refptr() |
| 253 const { |
| 254 return ipc_task_runner_; |
| 255 } |
| 256 |
247 // Dispatches a message on the listener thread. | 257 // Dispatches a message on the listener thread. |
248 void OnDispatchMessage(const Message& message); | 258 void OnDispatchMessage(const Message& message); |
249 | 259 |
250 // Sends |message| from appropriate thread. | 260 // Sends |message| from appropriate thread. |
251 void Send(Message* message); | 261 void Send(Message* message); |
252 | 262 |
253 protected: | 263 protected: |
254 friend class base::RefCountedThreadSafe<Context>; | 264 friend class base::RefCountedThreadSafe<Context>; |
255 ~Context() override; | 265 ~Context() override; |
256 | 266 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 bool did_init_; | 404 bool did_init_; |
395 | 405 |
396 #if defined(ENABLE_IPC_FUZZER) | 406 #if defined(ENABLE_IPC_FUZZER) |
397 OutgoingMessageFilter* outgoing_message_filter_; | 407 OutgoingMessageFilter* outgoing_message_filter_; |
398 #endif | 408 #endif |
399 }; | 409 }; |
400 | 410 |
401 } // namespace IPC | 411 } // namespace IPC |
402 | 412 |
403 #endif // IPC_IPC_CHANNEL_PROXY_H_ | 413 #endif // IPC_IPC_CHANNEL_PROXY_H_ |
OLD | NEW |