Adds associated interface support to IPC::Channel
Provides a way of registering associated interface bindings with
an IPC::Channel endpoint and acquiring proxies to remote interfaces
on the other side.
Support for this is exposed by IPC::Channel but only implemented
in IPC::ChannelMojo.
This is part a series of CLs to support Channel-associated interfaces.
BUG=612500
Committed: https://crrev.com/dc88e5075878f16cde23b910d2ce19aa862129e4
Review-Url: https://codereview.chromium.org/2137353002
Cr-Original-Commit-Position: refs/heads/master@{#405316}
Cr-Commit-Position: refs/heads/master@{#405364}
diff --git a/ipc/ipc_message_pipe_reader.h b/ipc/ipc_message_pipe_reader.h
index b15579d..5aec440 100644
--- a/ipc/ipc_message_pipe_reader.h
+++ b/ipc/ipc_message_pipe_reader.h
@@ -15,8 +15,10 @@
#include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "ipc/ipc.mojom.h"
+#include "ipc/ipc_export.h"
#include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
+#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/message_pipe.h"
@@ -41,12 +43,15 @@
// be called on any thread. All |Delegate| functions will be called on the IO
// thread.
//
-class MessagePipeReader : public mojom::Channel {
+class IPC_EXPORT MessagePipeReader : public NON_EXPORTED_BASE(mojom::Channel) {
public:
class Delegate {
public:
virtual void OnMessageReceived(const Message& message) = 0;
virtual void OnPipeError() = 0;
+ virtual void OnAssociatedInterfaceRequest(
+ const std::string& name,
+ mojo::ScopedInterfaceEndpointHandle handle) = 0;
};
// Delay the object deletion using the current message loop.
@@ -91,6 +96,10 @@
// thread.
bool Send(std::unique_ptr<Message> message);
+ // Requests an associated interface from the other end of the pipe.
+ void GetRemoteInterface(const std::string& name,
+ mojo::ScopedInterfaceEndpointHandle handle);
+
base::ProcessId GetPeerPid() const { return peer_pid_; }
protected:
@@ -101,6 +110,9 @@
// mojom::Channel:
void Receive(mojo::Array<uint8_t> data,
mojo::Array<mojom::SerializedHandlePtr> handles) override;
+ void GetAssociatedInterface(
+ const mojo::String& name,
+ mojom::GenericInterfaceAssociatedRequest request) override;
// |delegate_| is null once the message pipe is closed.
Delegate* delegate_;