OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_HANDLE_INTERFACE_SERIALIZATION_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_HANDLE_INTERFACE_SERIALIZATION_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_HANDLE_INTERFACE_SERIALIZATION_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_HANDLE_INTERFACE_SERIALIZATION_H_ |
7 | 7 |
| 8 #include "mojo/public/cpp/bindings/associated_group_controller.h" |
8 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" | 9 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
9 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 10 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
10 #include "mojo/public/cpp/bindings/interface_ptr.h" | 11 #include "mojo/public/cpp/bindings/interface_ptr.h" |
11 #include "mojo/public/cpp/bindings/interface_request.h" | 12 #include "mojo/public/cpp/bindings/interface_request.h" |
12 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" | 13 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
13 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | |
14 #include "mojo/public/cpp/bindings/lib/serialization_context.h" | 14 #include "mojo/public/cpp/bindings/lib/serialization_context.h" |
15 #include "mojo/public/cpp/bindings/lib/serialization_forward.h" | 15 #include "mojo/public/cpp/bindings/lib/serialization_forward.h" |
16 #include "mojo/public/cpp/system/handle.h" | 16 #include "mojo/public/cpp/system/handle.h" |
17 | 17 |
18 namespace mojo { | 18 namespace mojo { |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 template <typename T> | 21 template <typename T> |
22 struct Serializer<AssociatedInterfacePtrInfo<T>, | 22 struct Serializer<AssociatedInterfacePtrInfo<T>, |
23 AssociatedInterfacePtrInfo<T>> { | 23 AssociatedInterfacePtrInfo<T>> { |
24 static void Serialize(AssociatedInterfacePtrInfo<T>& input, | 24 static void Serialize(AssociatedInterfacePtrInfo<T>& input, |
25 AssociatedInterface_Data* output, | 25 AssociatedInterface_Data* output, |
26 SerializationContext* context) { | 26 SerializationContext* context) { |
27 DCHECK(!input.handle().is_valid() || !input.handle().is_local()); | 27 DCHECK(!input.handle().is_valid() || !input.handle().is_local()); |
28 DCHECK_EQ(input.handle().router(), context->router.get()); | 28 DCHECK_EQ(input.handle().group_controller(), |
| 29 context->group_controller.get()); |
29 output->version = input.version(); | 30 output->version = input.version(); |
30 output->interface_id = input.PassHandle().release(); | 31 output->interface_id = input.PassHandle().release(); |
31 } | 32 } |
32 | 33 |
33 static bool Deserialize(AssociatedInterface_Data* input, | 34 static bool Deserialize(AssociatedInterface_Data* input, |
34 AssociatedInterfacePtrInfo<T>* output, | 35 AssociatedInterfacePtrInfo<T>* output, |
35 SerializationContext* context) { | 36 SerializationContext* context) { |
36 output->set_handle(context->router->CreateLocalEndpointHandle( | 37 output->set_handle(context->group_controller->CreateLocalEndpointHandle( |
37 FetchAndReset(&input->interface_id))); | 38 FetchAndReset(&input->interface_id))); |
38 output->set_version(input->version); | 39 output->set_version(input->version); |
39 return true; | 40 return true; |
40 } | 41 } |
41 }; | 42 }; |
42 | 43 |
43 template <typename T> | 44 template <typename T> |
44 struct Serializer<AssociatedInterfaceRequest<T>, | 45 struct Serializer<AssociatedInterfaceRequest<T>, |
45 AssociatedInterfaceRequest<T>> { | 46 AssociatedInterfaceRequest<T>> { |
46 static void Serialize(AssociatedInterfaceRequest<T>& input, | 47 static void Serialize(AssociatedInterfaceRequest<T>& input, |
47 AssociatedInterfaceRequest_Data* output, | 48 AssociatedInterfaceRequest_Data* output, |
48 SerializationContext* context) { | 49 SerializationContext* context) { |
49 DCHECK(!input.handle().is_valid() || !input.handle().is_local()); | 50 DCHECK(!input.handle().is_valid() || !input.handle().is_local()); |
50 DCHECK_EQ(input.handle().router(), context->router.get()); | 51 DCHECK_EQ(input.handle().group_controller(), |
| 52 context->group_controller.get()); |
51 output->interface_id = input.PassHandle().release(); | 53 output->interface_id = input.PassHandle().release(); |
52 } | 54 } |
53 | 55 |
54 static bool Deserialize(AssociatedInterfaceRequest_Data* input, | 56 static bool Deserialize(AssociatedInterfaceRequest_Data* input, |
55 AssociatedInterfaceRequest<T>* output, | 57 AssociatedInterfaceRequest<T>* output, |
56 SerializationContext* context) { | 58 SerializationContext* context) { |
57 output->Bind(context->router->CreateLocalEndpointHandle( | 59 output->Bind(context->group_controller->CreateLocalEndpointHandle( |
58 FetchAndReset(&input->interface_id))); | 60 FetchAndReset(&input->interface_id))); |
59 return true; | 61 return true; |
60 } | 62 } |
61 }; | 63 }; |
62 | 64 |
63 template <typename T> | 65 template <typename T> |
64 struct Serializer<InterfacePtr<T>, InterfacePtr<T>> { | 66 struct Serializer<InterfacePtr<T>, InterfacePtr<T>> { |
65 static void Serialize(InterfacePtr<T>& input, | 67 static void Serialize(InterfacePtr<T>& input, |
66 Interface_Data* output, | 68 Interface_Data* output, |
67 SerializationContext* context) { | 69 SerializationContext* context) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 SerializationContext* context) { | 111 SerializationContext* context) { |
110 *output = context->handles.TakeHandleAs<T>(*input); | 112 *output = context->handles.TakeHandleAs<T>(*input); |
111 return true; | 113 return true; |
112 } | 114 } |
113 }; | 115 }; |
114 | 116 |
115 } // namespace internal | 117 } // namespace internal |
116 } // namespace mojo | 118 } // namespace mojo |
117 | 119 |
118 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_HANDLE_INTERFACE_SERIALIZATION_H_ | 120 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_HANDLE_INTERFACE_SERIALIZATION_H_ |
OLD | NEW |