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

Side by Side Diff: mojo/public/cpp/bindings/lib/serialization_util.h

Issue 2100683002: Mojo C++ Bindings: Extract AssociatedGroupController from MultiplexRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops more gyp ugh 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 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_SERIALIZATION_UTIL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <queue> 11 #include <queue>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" 15 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
16 #include "mojo/public/cpp/bindings/interface_ptr.h" 16 #include "mojo/public/cpp/bindings/interface_ptr.h"
17 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 17 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
18 #include "mojo/public/cpp/bindings/lib/serialization_context.h" 18 #include "mojo/public/cpp/bindings/lib/serialization_context.h"
19 #include "mojo/public/cpp/system/handle.h" 19 #include "mojo/public/cpp/system/handle.h"
20 20
21 namespace mojo { 21 namespace mojo {
22
23 class AssociatedGroupController;
24
22 namespace internal { 25 namespace internal {
23 26
24 class MultiplexRouter;
25
26 size_t Align(size_t size); 27 size_t Align(size_t size);
27 char* AlignPointer(char* ptr); 28 char* AlignPointer(char* ptr);
28 29
29 bool IsAligned(const void* ptr); 30 bool IsAligned(const void* ptr);
30 31
31 // Pointers are encoded as relative offsets. The offsets are relative to the 32 // Pointers are encoded as relative offsets. The offsets are relative to the
32 // address of where the offset value is stored, such that the pointer may be 33 // address of where the offset value is stored, such that the pointer may be
33 // recovered with the expression: 34 // recovered with the expression:
34 // 35 //
35 // ptr = reinterpret_cast<char*>(offset) + *offset 36 // ptr = reinterpret_cast<char*>(offset) + *offset
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 AssociatedInterfacePtrInfo<T> input, 70 AssociatedInterfacePtrInfo<T> input,
70 AssociatedInterface_Data* output) { 71 AssociatedInterface_Data* output) {
71 output->version = input.version(); 72 output->version = input.version();
72 output->interface_id = input.PassHandle().release(); 73 output->interface_id = input.PassHandle().release();
73 } 74 }
74 75
75 template <typename T> 76 template <typename T>
76 inline void AssociatedInterfaceDataToPtrInfo( 77 inline void AssociatedInterfaceDataToPtrInfo(
77 AssociatedInterface_Data* input, 78 AssociatedInterface_Data* input,
78 AssociatedInterfacePtrInfo<T>* output, 79 AssociatedInterfacePtrInfo<T>* output,
79 MultiplexRouter* router) { 80 AssociatedGroupController* group_controller) {
80 output->set_handle( 81 output->set_handle(group_controller->CreateLocalEndpointHandle(
81 router->CreateLocalEndpointHandle(FetchAndReset(&input->interface_id))); 82 FetchAndReset(&input->interface_id)));
82 output->set_version(input->version); 83 output->set_version(input->version);
83 } 84 }
84 85
85 template <typename T> 86 template <typename T>
86 inline void InterfacePointerToData(InterfacePtr<T> input, 87 inline void InterfacePointerToData(InterfacePtr<T> input,
87 Interface_Data* output, 88 Interface_Data* output,
88 SerializationContext* context) { 89 SerializationContext* context) {
89 InterfacePtrInfo<T> info = input.PassInterface(); 90 InterfacePtrInfo<T> info = input.PassInterface();
90 output->handle = context->handles.AddHandle(info.PassHandle().release()); 91 output->handle = context->handles.AddHandle(info.PassHandle().release());
91 output->version = info.version(); 92 output->version = info.version();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 typename std::enable_if< 287 typename std::enable_if<
287 !HasGetDataMethod<Traits, MaybeConstUserType>::value>::type* = nullptr> 288 !HasGetDataMethod<Traits, MaybeConstUserType>::value>::type* = nullptr>
288 void* CallGetDataIfExists(MaybeConstUserType& input) { 289 void* CallGetDataIfExists(MaybeConstUserType& input) {
289 return nullptr; 290 return nullptr;
290 } 291 }
291 292
292 } // namespace internal 293 } // namespace internal
293 } // namespace mojo 294 } // namespace mojo
294 295
295 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ 296 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/serialization_context.cc ('k') | mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698