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

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

Issue 2112093002: Mojo C++ bindings: Merge EncodePointers/DecodePointers into Serialize/Deserialize, respectively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@61_array_fix
Patch Set: . 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 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_NATIVE_STRUCT_DATA_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "mojo/public/cpp/bindings/lib/array_internal.h" 10 #include "mojo/public/cpp/bindings/lib/array_internal.h"
11 #include "mojo/public/cpp/system/handle.h" 11 #include "mojo/public/cpp/system/handle.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace internal { 14 namespace internal {
15 15
16 class Buffer; 16 class Buffer;
17 class ValidationContext; 17 class ValidationContext;
18 18
19 class NativeStruct_Data { 19 class NativeStruct_Data {
20 public: 20 public:
21 static bool Validate(const void* data, ValidationContext* validation_context); 21 static bool Validate(const void* data, ValidationContext* validation_context);
22 22
23 void EncodePointers() {}
24 void DecodePointers() {}
25
26 // Unlike normal structs, the memory layout is exactly the same as an array 23 // Unlike normal structs, the memory layout is exactly the same as an array
27 // of uint8_t. 24 // of uint8_t.
28 Array_Data<uint8_t> data; 25 Array_Data<uint8_t> data;
29 26
30 private: 27 private:
31 NativeStruct_Data() = delete; 28 NativeStruct_Data() = delete;
32 ~NativeStruct_Data() = delete; 29 ~NativeStruct_Data() = delete;
33 }; 30 };
34 31
35 static_assert(sizeof(Array_Data<uint8_t>) == sizeof(NativeStruct_Data), 32 static_assert(sizeof(Array_Data<uint8_t>) == sizeof(NativeStruct_Data),
36 "Mismatched NativeStruct_Data and Array_Data<uint8_t> size"); 33 "Mismatched NativeStruct_Data and Array_Data<uint8_t> size");
37 34
38 } // namespace internal 35 } // namespace internal
39 } // namespace mojo 36 } // namespace mojo
40 37
41 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_ 38 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/map_serialization.h ('k') | mojo/public/cpp/bindings/lib/pipe_control_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698