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 #include "mojo/public/cpp/bindings/lib/native_struct_serialization.h" | 5 #include "mojo/public/cpp/bindings/lib/native_struct_serialization.h" |
6 | 6 |
7 #include "mojo/public/cpp/bindings/lib/serialization.h" | 7 #include "mojo/public/cpp/bindings/lib/serialization.h" |
8 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 namespace internal { | 10 namespace internal { |
(...skipping 12 matching lines...) Expand all Loading... |
23 const NativeStructPtr& input, | 23 const NativeStructPtr& input, |
24 Buffer* buffer, | 24 Buffer* buffer, |
25 NativeStruct_Data** output, | 25 NativeStruct_Data** output, |
26 SerializationContext* context) { | 26 SerializationContext* context) { |
27 if (!input) { | 27 if (!input) { |
28 *output = nullptr; | 28 *output = nullptr; |
29 return; | 29 return; |
30 } | 30 } |
31 | 31 |
32 Array_Data<uint8_t>* data = nullptr; | 32 Array_Data<uint8_t>* data = nullptr; |
33 const ArrayValidateParams params(0, false, nullptr); | 33 const ContainerValidateParams params(0, false, nullptr); |
34 internal::Serialize<Array<uint8_t>>(input->data, buffer, &data, ¶ms, | 34 internal::Serialize<Array<uint8_t>>(input->data, buffer, &data, ¶ms, |
35 context); | 35 context); |
36 *output = reinterpret_cast<NativeStruct_Data*>(data); | 36 *output = reinterpret_cast<NativeStruct_Data*>(data); |
37 } | 37 } |
38 | 38 |
39 // static | 39 // static |
40 bool UnmappedNativeStructSerializerImpl::Deserialize( | 40 bool UnmappedNativeStructSerializerImpl::Deserialize( |
41 NativeStruct_Data* input, | 41 NativeStruct_Data* input, |
42 NativeStructPtr* output, | 42 NativeStructPtr* output, |
43 SerializationContext* context) { | 43 SerializationContext* context) { |
44 Array_Data<uint8_t>* data = reinterpret_cast<Array_Data<uint8_t>*>(input); | 44 Array_Data<uint8_t>* data = reinterpret_cast<Array_Data<uint8_t>*>(input); |
45 | 45 |
46 NativeStructPtr result(NativeStruct::New()); | 46 NativeStructPtr result(NativeStruct::New()); |
47 if (!internal::Deserialize<Array<uint8_t>>(data, &result->data, context)) { | 47 if (!internal::Deserialize<Array<uint8_t>>(data, &result->data, context)) { |
48 output = nullptr; | 48 output = nullptr; |
49 return false; | 49 return false; |
50 } | 50 } |
51 if (!result->data) | 51 if (!result->data) |
52 *output = nullptr; | 52 *output = nullptr; |
53 else | 53 else |
54 result.Swap(output); | 54 result.Swap(output); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 } // namespace internal | 58 } // namespace internal |
59 } // namespace mojo | 59 } // namespace mojo |
OLD | NEW |