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

Side by Side 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 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h"
11 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
10 #include "mojo/public/cpp/bindings/interface_ptr.h" 12 #include "mojo/public/cpp/bindings/interface_ptr.h"
11 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 13 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
12 #include "mojo/public/cpp/system/core.h" 14 #include "mojo/public/cpp/system/core.h"
13 15
14 namespace mojo { 16 namespace mojo {
15 namespace internal { 17 namespace internal {
16 18
19 class MultiplexRouter;
20
17 // Please note that this is a different value than |mojo::kInvalidHandleValue|, 21 // Please note that this is a different value than |mojo::kInvalidHandleValue|,
18 // which is the "decoded" invalid handle. 22 // which is the "decoded" invalid handle.
19 const MojoHandle kEncodedInvalidHandleValue = static_cast<MojoHandle>(-1); 23 const MojoHandle kEncodedInvalidHandleValue = static_cast<MojoHandle>(-1);
20 24
21 size_t Align(size_t size); 25 size_t Align(size_t size);
22 char* AlignPointer(char* ptr); 26 char* AlignPointer(char* ptr);
23 27
24 bool IsAligned(const void* ptr); 28 bool IsAligned(const void* ptr);
25 29
26 // Pointers are encoded as relative offsets. The offsets are relative to the 30 // Pointers are encoded as relative offsets. The offsets are relative to the
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 output->version = info.version(); 82 output->version = info.version();
79 } 83 }
80 84
81 template <typename T> 85 template <typename T>
82 inline void InterfaceDataToPointer(Interface_Data* input, 86 inline void InterfaceDataToPointer(Interface_Data* input,
83 InterfacePtr<T>* output) { 87 InterfacePtr<T>* output) {
84 output->Bind(InterfacePtrInfo<T>( 88 output->Bind(InterfacePtrInfo<T>(
85 MakeScopedHandle(FetchAndReset(&input->handle)), input->version)); 89 MakeScopedHandle(FetchAndReset(&input->handle)), input->version));
86 } 90 }
87 91
92 template <typename T>
93 inline void AssociatedInterfacePtrInfoToData(
94 AssociatedInterfacePtrInfo<T> input,
95 AssociatedInterface_Data* output) {
96 output->version = input.version();
97 output->interface_id =
98 AssociatedInterfacePtrInfoHelper::PassHandle(&input).release();
99 }
100
101 template <typename T>
102 inline void AssociatedInterfaceDataToPtrInfo(
103 AssociatedInterface_Data* input,
104 AssociatedInterfacePtrInfo<T>* output,
105 MultiplexRouter* router) {
106 AssociatedInterfacePtrInfoHelper::SetHandle(
107 output,
108 router->CreateLocalEndpointHandle(FetchAndReset(&input->interface_id)));
109 output->set_version(input->version);
110 }
111
112 // Context information for serialization/deserialization routines.
113 struct SerializationContext {
114 SerializationContext();
115 explicit SerializationContext(scoped_refptr<MultiplexRouter> in_router);
116
117 ~SerializationContext();
118
119 // Used to serialize/deserialize associated interface pointers and requests.
120 scoped_refptr<MultiplexRouter> router;
121 };
122
88 } // namespace internal 123 } // namespace internal
89 } // namespace mojo 124 } // namespace mojo
90 125
91 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ 126 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_
OLDNEW
« 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