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

Unified Diff: ipc/ipc_channel.h

Issue 2137353002: Adds associated interface support to IPC::Channel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@channel-bindings-1
Patch Set: rebase Created 4 years, 5 months 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
« no previous file with comments | « ipc/ipc.mojom ('k') | ipc/ipc_channel_common.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel.h
diff --git a/ipc/ipc_channel.h b/ipc/ipc_channel.h
index 09baf6cf14044ecc32315789b9ee84915bea36b6..1c834014630fcebe2863c6d9f9f271f776defa18 100644
--- a/ipc/ipc_channel.h
+++ b/ipc/ipc_channel.h
@@ -18,6 +18,10 @@
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_endpoint.h"
#include "ipc/ipc_message.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"
#if defined(OS_POSIX)
#include <sys/types.h>
@@ -181,6 +185,49 @@ class IPC_EXPORT Channel : public Endpoint {
// Get its own process id. This value is told to the peer.
virtual base::ProcessId GetSelfPID() const = 0;
yzshen1 2016/07/13 17:38:42 It seems cleaner to me to group associated interfa
+ // Accesses the AssociatedGroup used to associate new interface endpoints with
+ // this Channel.
+ //
+ // NOTE: Not all implementations support this.
+ virtual mojo::AssociatedGroup* GetAssociatedGroup();
+
+ // Adds an interface factory to this channel for interface |name|.
+ //
+ // NOTE: Not all implementations support this.
+ using GenericAssociatedInterfaceFactory =
+ base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>;
+ virtual void AddGenericAssociatedInterface(
+ const std::string& name,
+ const GenericAssociatedInterfaceFactory& factory);
+
+ template <typename Interface>
+ using AssociatedInterfaceFactory =
+ base::Callback<void(mojo::AssociatedInterfaceRequest<Interface>)>;
+
+ template <typename Interface>
+ void AddAssociatedInterface(
+ const AssociatedInterfaceFactory<Interface>& factory) {
+ AddGenericAssociatedInterface(
+ Interface::Name_,
+ base::Bind(&BindAssociatedInterfaceRequest<Interface>, factory));
+ }
+
+ // Requests an associated interface from the remote endpoint.
+ //
+ // NOTE: Not all implementations support this.
+ virtual void GetGenericRemoteAssociatedInterface(
+ const std::string& name,
+ mojo::ScopedInterfaceEndpointHandle handle);
+
+ // Acquires an associated interface proxied to the remote endpoint.
+ template <typename Interface>
+ void GetRemoteAssociatedInterface(
+ mojo::AssociatedInterfacePtr<Interface>* proxy) {
+ mojo::AssociatedInterfaceRequest<Interface> request =
+ mojo::GetProxy(proxy, GetAssociatedGroup());
+ GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle());
+ }
+
// Overridden from ipc::Sender.
// Send a message over the Channel to the listener on the other end.
//
@@ -279,6 +326,15 @@ class IPC_EXPORT Channel : public Endpoint {
void WillConnect();
private:
+ template <typename Interface>
+ static void BindAssociatedInterfaceRequest(
+ const AssociatedInterfaceFactory<Interface>& factory,
+ mojo::ScopedInterfaceEndpointHandle handle) {
+ mojo::AssociatedInterfaceRequest<Interface> request;
+ request.Bind(std::move(handle));
+ factory.Run(std::move(request));
+ }
+
bool did_start_connect_ = false;
};
« no previous file with comments | « ipc/ipc.mojom ('k') | ipc/ipc_channel_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698