Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(792)

Unified Diff: ipc/ipc_channel_proxy.h

Issue 2522333002: Provide a Mojo equivalent of ThreadSafeSender. (Closed)
Patch Set: Addresses @tsepez comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ipc/ipc_channel_proxy.h
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h
index 5765630a2582349a9b470785eef7c4ae6842bd0f..3a94f330cc2335a673727d54eb3d17e25f9dd86b 100644
--- a/ipc/ipc_channel_proxy.h
+++ b/ipc/ipc_channel_proxy.h
@@ -230,6 +230,19 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
}
#endif
+ 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));
+ }
+
// Called to clear the pointer to the IPC task runner when it's going away.
void ClearIPCTaskRunner();
@@ -239,7 +252,6 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
// to the internal state.
explicit ChannelProxy(Context* context);
-
// Used internally to hold state that is referenced on the IPC thread.
class Context : public base::RefCountedThreadSafe<Context>,
public Listener {
@@ -304,6 +316,14 @@ 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);
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | mojo/public/cpp/bindings/tests/associated_interface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698