Index: ipc/ipc_channel_proxy.h |
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h |
index bda83bb18854299b58c977b6a5a349e76cf4e15b..a64de871f7a9cbbd33adcf9921c1f724724b3390 100644 |
--- a/ipc/ipc_channel_proxy.h |
+++ b/ipc/ipc_channel_proxy.h |
@@ -22,8 +22,10 @@ |
#include "ipc/ipc_listener.h" |
#include "ipc/ipc_sender.h" |
#include "mojo/public/cpp/bindings/associated_group.h" |
+#include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
#include "mojo/public/cpp/bindings/associated_interface_request.h" |
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
+#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" |
namespace base { |
class SingleThreadTaskRunner; |
@@ -209,17 +211,22 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { |
} |
#endif |
+ // Creates a ThreadSafeAssociatedInterfacePtr for |Interface|. This object |
+ // may be used to send messages on the interface from any thread and those |
+ // messages will remain ordered with respect to other messages sent on the |
+ // same thread over other ThreadSafeAssociatedInterfacePtrs associated with |
+ // the same Channel. |
template <typename Interface> |
- using AssociatedInterfaceRetrievedCallback = |
- base::Callback<void(mojo::AssociatedInterfacePtr<Interface>)>; |
- // Creates an AssociatedInterfacePtr to |Interface| on the IO thread and |
- // passes it to |callback|, also invoked on the IO thread. |
- template <typename Interface> |
- void RetrieveAssociatedInterfaceOnIOThread( |
- const AssociatedInterfaceRetrievedCallback<Interface>& callback) { |
- context_->ipc_task_runner()->PostTask( |
- FROM_HERE, base::Bind(&Context::RetrieveAssociatedInterface<Interface>, |
- context_, callback)); |
+ void GetThreadSafeRemoteAssociatedInterface( |
yzshen1
2017/02/01 18:57:55
I guess the change I proposed is orthogonal:
I am
|
+ scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>>* |
+ out_ptr) { |
+ DCHECK(GetAssociatedGroup()); |
+ mojo::AssociatedInterfacePtr<Interface> ptr; |
+ mojo::AssociatedInterfaceRequest<Interface> request = |
+ mojo::MakeRequest(&ptr, GetAssociatedGroup()); |
+ *out_ptr = mojo::ThreadSafeAssociatedInterfacePtr<Interface>::Create( |
+ ptr.PassInterface(), ipc_task_runner()); |
+ GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle()); |
} |
base::SingleThreadTaskRunner* ipc_task_runner() const { |
@@ -299,14 +306,6 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { |
void OnSendMessage(std::unique_ptr<Message> message_ptr); |
void OnAddFilter(); |
void OnRemoveFilter(MessageFilter* filter); |
- template <typename Interface> |
- void RetrieveAssociatedInterface( |
- const AssociatedInterfaceRetrievedCallback<Interface>& callback) { |
- mojo::AssociatedInterfacePtr<Interface> interface_ptr; |
- channel_->GetAssociatedInterfaceSupport()->GetRemoteAssociatedInterface( |
- &interface_ptr); |
- callback.Run(std::move(interface_ptr)); |
- } |
// Methods called on the listener thread. |
void AddFilter(MessageFilter* filter); |