| 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_SYNC_MESSAGE_FILTER_H_ | 5 #ifndef IPC_IPC_SYNC_MESSAGE_FILTER_H_ |
| 6 #define IPC_IPC_SYNC_MESSAGE_FILTER_H_ | 6 #define IPC_IPC_SYNC_MESSAGE_FILTER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "base/synchronization/waitable_event_watcher.h" | 15 #include "base/synchronization/waitable_event_watcher.h" |
| 16 #include "ipc/ipc_sender.h" | 16 #include "ipc/ipc_sender.h" |
| 17 #include "ipc/ipc_sync_message.h" | 17 #include "ipc/ipc_sync_message.h" |
| 18 #include "ipc/message_filter.h" | 18 #include "ipc/message_filter.h" |
| 19 #include "ipc/mojo_event.h" | 19 #include "ipc/mojo_event.h" |
| 20 #include "mojo/public/cpp/bindings/associated_group.h" | |
| 21 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 20 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| 22 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 21 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
| 23 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" | 22 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
| 24 | 23 |
| 25 namespace base { | 24 namespace base { |
| 26 class SingleThreadTaskRunner; | 25 class SingleThreadTaskRunner; |
| 27 class WaitableEvent; | 26 class WaitableEvent; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace IPC { | 29 namespace IPC { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 48 | 47 |
| 49 // Binds an associated interface proxy to an interface in the browser process. | 48 // Binds an associated interface proxy to an interface in the browser process. |
| 50 // Interfaces acquired through this method are associated with the IPC Channel | 49 // Interfaces acquired through this method are associated with the IPC Channel |
| 51 // and as such retain FIFO with legacy IPC messages. | 50 // and as such retain FIFO with legacy IPC messages. |
| 52 // | 51 // |
| 53 // NOTE: This must ONLY be called on the Channel's thread, after | 52 // NOTE: This must ONLY be called on the Channel's thread, after |
| 54 // OnFilterAdded. | 53 // OnFilterAdded. |
| 55 template <typename Interface> | 54 template <typename Interface> |
| 56 void GetRemoteAssociatedInterface( | 55 void GetRemoteAssociatedInterface( |
| 57 mojo::AssociatedInterfacePtr<Interface>* proxy) { | 56 mojo::AssociatedInterfacePtr<Interface>* proxy) { |
| 58 mojo::AssociatedInterfaceRequest<Interface> request = | 57 auto request = mojo::MakeRequest(proxy); |
| 59 mojo::MakeRequest(proxy, &channel_associated_group_); | |
| 60 GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle()); | 58 GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle()); |
| 61 } | 59 } |
| 62 | 60 |
| 63 protected: | 61 protected: |
| 64 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event); | 62 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event); |
| 65 ~SyncMessageFilter() override; | 63 ~SyncMessageFilter() override; |
| 66 | 64 |
| 67 private: | 65 private: |
| 68 class IOMessageLoopObserver; | 66 class IOMessageLoopObserver; |
| 69 | 67 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // Used to asynchronously watch |shutdown_event_| on the IO thread and forward | 103 // Used to asynchronously watch |shutdown_event_| on the IO thread and forward |
| 106 // to |shutdown_mojo_event_| (see below.) | 104 // to |shutdown_mojo_event_| (see below.) |
| 107 base::WaitableEventWatcher shutdown_watcher_; | 105 base::WaitableEventWatcher shutdown_watcher_; |
| 108 | 106 |
| 109 // A Mojo event which can be watched for shutdown. Signals are forwarded to | 107 // A Mojo event which can be watched for shutdown. Signals are forwarded to |
| 110 // this event asynchronously from |shutdown_event_|. | 108 // this event asynchronously from |shutdown_event_|. |
| 111 MojoEvent shutdown_mojo_event_; | 109 MojoEvent shutdown_mojo_event_; |
| 112 | 110 |
| 113 scoped_refptr<IOMessageLoopObserver> io_message_loop_observer_; | 111 scoped_refptr<IOMessageLoopObserver> io_message_loop_observer_; |
| 114 | 112 |
| 115 // The AssociatedGroup for the underlying channel, used to construct new | |
| 116 // associated interface endpoints. | |
| 117 mojo::AssociatedGroup channel_associated_group_; | |
| 118 | |
| 119 base::WeakPtrFactory<SyncMessageFilter> weak_factory_; | 113 base::WeakPtrFactory<SyncMessageFilter> weak_factory_; |
| 120 | 114 |
| 121 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); | 115 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter); |
| 122 }; | 116 }; |
| 123 | 117 |
| 124 } // namespace IPC | 118 } // namespace IPC |
| 125 | 119 |
| 126 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ | 120 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_ |
| OLD | NEW |