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

Unified Diff: mojo/public/cpp/bindings/lib/bindings_serialization.h

Issue 1475813002: Mojo C++ bindings: support passing associated interface pointers/requests in method parameter lists… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@25_use_multiplex_router
Patch Set: Created 5 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: mojo/public/cpp/bindings/lib/bindings_serialization.h
diff --git a/mojo/public/cpp/bindings/lib/bindings_serialization.h b/mojo/public/cpp/bindings/lib/bindings_serialization.h
index 5e2f9a775ca89e8fa11243304c7d3173627488e4..0da7d965105cc0c87fd671b4f52c22904a5c3d91 100644
--- a/mojo/public/cpp/bindings/lib/bindings_serialization.h
+++ b/mojo/public/cpp/bindings/lib/bindings_serialization.h
@@ -7,6 +7,8 @@
#include <vector>
+#include "base/memory/ref_counted.h"
+#include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/system/core.h"
@@ -14,6 +16,8 @@
namespace mojo {
namespace internal {
+class MultiplexRouter;
+
// Please note that this is a different value than |mojo::kInvalidHandleValue|,
// which is the "decoded" invalid handle.
const MojoHandle kEncodedInvalidHandleValue = static_cast<MojoHandle>(-1);
@@ -85,6 +89,37 @@ inline void InterfaceDataToPointer(Interface_Data* input,
MakeScopedHandle(FetchAndReset(&input->handle)), input->version));
}
+template <typename T>
+inline void AssociatedInterfacePtrInfoToData(
+ AssociatedInterfacePtrInfo<T> input,
+ AssociatedInterface_Data* output) {
+ output->version = input.version();
+ output->interface_id =
+ AssociatedInterfacePtrInfoHelper::PassHandle(&input).release();
+}
+
+template <typename T>
+inline void AssociatedInterfaceDataToPtrInfo(
+ AssociatedInterface_Data* input,
+ AssociatedInterfacePtrInfo<T>* output,
+ MultiplexRouter* router) {
+ AssociatedInterfacePtrInfoHelper::SetHandle(
+ output,
+ router->CreateLocalEndpointHandle(FetchAndReset(&input->interface_id)));
+ output->set_version(input->version);
+}
+
+// Context information for serialization/deserialization routines.
+struct SerializationContext {
+ SerializationContext();
+ explicit SerializationContext(scoped_refptr<MultiplexRouter> in_router);
+
+ ~SerializationContext();
+
+ // Used to serialize/deserialize associated interface pointers and requests.
+ scoped_refptr<MultiplexRouter> router;
+};
+
} // namespace internal
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/binding_state.h ('k') | mojo/public/cpp/bindings/lib/bindings_serialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698