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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return ipc_task_runner_.get(); | 258 return ipc_task_runner_.get(); |
259 } | 259 } |
260 const std::string& channel_id() const { return channel_id_; } | 260 const std::string& channel_id() const { return channel_id_; } |
261 | 261 |
262 // Dispatches a message on the listener thread. | 262 // Dispatches a message on the listener thread. |
263 void OnDispatchMessage(const Message& message); | 263 void OnDispatchMessage(const Message& message); |
264 | 264 |
265 // Sends |message| from appropriate thread. | 265 // Sends |message| from appropriate thread. |
266 void Send(Message* message); | 266 void Send(Message* message); |
267 | 267 |
268 // Indicates if the underlying channel's Send is thread-safe. | |
269 bool IsChannelSendThreadSafe() const; | |
270 | |
271 // Requests a remote associated interface on the IPC thread. | 268 // Requests a remote associated interface on the IPC thread. |
272 void GetRemoteAssociatedInterface( | 269 void GetRemoteAssociatedInterface( |
273 const std::string& name, | 270 const std::string& name, |
274 mojo::ScopedInterfaceEndpointHandle handle); | 271 mojo::ScopedInterfaceEndpointHandle handle); |
275 | 272 |
276 protected: | 273 protected: |
277 friend class base::RefCountedThreadSafe<Context>; | 274 friend class base::RefCountedThreadSafe<Context>; |
278 ~Context() override; | 275 ~Context() override; |
279 | 276 |
280 // IPC::Listener methods: | 277 // IPC::Listener methods: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 322 |
326 // Methods called on the listener thread. | 323 // Methods called on the listener thread. |
327 void AddFilter(MessageFilter* filter); | 324 void AddFilter(MessageFilter* filter); |
328 void OnDispatchConnected(); | 325 void OnDispatchConnected(); |
329 void OnDispatchError(); | 326 void OnDispatchError(); |
330 void OnDispatchBadMessage(const Message& message); | 327 void OnDispatchBadMessage(const Message& message); |
331 void OnDispatchAssociatedInterfaceRequest( | 328 void OnDispatchAssociatedInterfaceRequest( |
332 const std::string& interface_name, | 329 const std::string& interface_name, |
333 mojo::ScopedInterfaceEndpointHandle handle); | 330 mojo::ScopedInterfaceEndpointHandle handle); |
334 | 331 |
335 void SendFromThisThread(Message* message); | |
336 void ClearChannel(); | 332 void ClearChannel(); |
337 | 333 |
338 mojo::AssociatedGroup* associated_group() { return &associated_group_; } | 334 mojo::AssociatedGroup* associated_group() { return &associated_group_; } |
339 | 335 |
340 void AddGenericAssociatedInterface( | 336 void AddGenericAssociatedInterface( |
341 const std::string& name, | 337 const std::string& name, |
342 const GenericAssociatedInterfaceFactory& factory); | 338 const GenericAssociatedInterfaceFactory& factory); |
343 void AddGenericAssociatedInterfaceForIOThread( | 339 void AddGenericAssociatedInterfaceForIOThread( |
344 const std::string& name, | 340 const std::string& name, |
345 const GenericAssociatedInterfaceFactory& factory); | 341 const GenericAssociatedInterfaceFactory& factory); |
346 | 342 |
347 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; | 343 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; |
348 Listener* listener_; | 344 Listener* listener_; |
349 | 345 |
350 // List of filters. This is only accessed on the IPC thread. | 346 // List of filters. This is only accessed on the IPC thread. |
351 std::vector<scoped_refptr<MessageFilter> > filters_; | 347 std::vector<scoped_refptr<MessageFilter> > filters_; |
352 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; | 348 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; |
353 | 349 |
354 // Note, channel_ may be set on the Listener thread or the IPC thread. | 350 // Note, channel_ may be set on the Listener thread or the IPC thread. |
355 // But once it has been set, it must only be read or cleared on the IPC | 351 // But once it has been set, it must only be read or cleared on the IPC |
356 // thread. | 352 // thread. |
357 // One exception is the thread-safe send. See the class comment. | 353 // One exception is the thread-safe send. See the class comment. |
358 std::unique_ptr<Channel> channel_; | 354 std::unique_ptr<Channel> channel_; |
359 std::string channel_id_; | 355 std::string channel_id_; |
360 bool channel_connected_called_; | 356 bool channel_connected_called_; |
361 | 357 |
362 // Lock for |channel_| value. This is only relevant in the context of | 358 // Lock for |channel_| value. This is only relevant in the context of |
363 // thread-safe send. | 359 // thread-safe send. |
364 base::Lock channel_lifetime_lock_; | 360 base::Lock channel_lifetime_lock_; |
365 // Indicates the thread-safe send availability. This is constant once | |
366 // |channel_| is set. | |
367 bool channel_send_thread_safe_; | |
368 | 361 |
369 // Routes a given message to a proper subset of |filters_|, depending | 362 // Routes a given message to a proper subset of |filters_|, depending |
370 // on which message classes a filter might support. | 363 // on which message classes a filter might support. |
371 std::unique_ptr<MessageFilterRouter> message_filter_router_; | 364 std::unique_ptr<MessageFilterRouter> message_filter_router_; |
372 | 365 |
373 // Holds filters between the AddFilter call on the listerner thread and the | 366 // Holds filters between the AddFilter call on the listerner thread and the |
374 // IPC thread when they're added to filters_. | 367 // IPC thread when they're added to filters_. |
375 std::vector<scoped_refptr<MessageFilter> > pending_filters_; | 368 std::vector<scoped_refptr<MessageFilter> > pending_filters_; |
376 // Lock for pending_filters_. | 369 // Lock for pending_filters_. |
377 base::Lock pending_filters_lock_; | 370 base::Lock pending_filters_lock_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 bool did_init_; | 423 bool did_init_; |
431 | 424 |
432 #if defined(ENABLE_IPC_FUZZER) | 425 #if defined(ENABLE_IPC_FUZZER) |
433 OutgoingMessageFilter* outgoing_message_filter_; | 426 OutgoingMessageFilter* outgoing_message_filter_; |
434 #endif | 427 #endif |
435 }; | 428 }; |
436 | 429 |
437 } // namespace IPC | 430 } // namespace IPC |
438 | 431 |
439 #endif // IPC_IPC_CHANNEL_PROXY_H_ | 432 #endif // IPC_IPC_CHANNEL_PROXY_H_ |
OLD | NEW |