| 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_SERIALIZATION_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_H_ |
| 7 | 7 |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/array_traits_carray.h" | 10 #include "mojo/public/cpp/bindings/array_traits_carray.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 // Please see comments in StructSerializeImpl. | 78 // Please see comments in StructSerializeImpl. |
| 79 bool need_copy = !IsAligned(input_buffer); | 79 bool need_copy = !IsAligned(input_buffer); |
| 80 | 80 |
| 81 if (need_copy) { | 81 if (need_copy) { |
| 82 input_buffer = malloc(input.size()); | 82 input_buffer = malloc(input.size()); |
| 83 DCHECK(IsAligned(input_buffer)); | 83 DCHECK(IsAligned(input_buffer)); |
| 84 memcpy(input_buffer, &input.front(), input.size()); | 84 memcpy(input_buffer, &input.front(), input.size()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 ValidationContext validation_context(input_buffer, input.size(), 0); | 87 ValidationContext validation_context(input_buffer, input.size(), 0, 0); |
| 88 bool result = false; | 88 bool result = false; |
| 89 if (DataType::Validate(input_buffer, &validation_context)) { | 89 if (DataType::Validate(input_buffer, &validation_context)) { |
| 90 auto data = reinterpret_cast<DataType*>(input_buffer); | 90 auto data = reinterpret_cast<DataType*>(input_buffer); |
| 91 SerializationContext context; | 91 SerializationContext context; |
| 92 result = Deserialize<MojomType>(data, output, &context); | 92 result = Deserialize<MojomType>(data, output, &context); |
| 93 } | 93 } |
| 94 | 94 |
| 95 if (need_copy) | 95 if (need_copy) |
| 96 free(input_buffer); | 96 free(input_buffer); |
| 97 | 97 |
| 98 return result; | 98 return result; |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace internal | 101 } // namespace internal |
| 102 } // namespace mojo | 102 } // namespace mojo |
| 103 | 103 |
| 104 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_H_ | 104 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_H_ |
| OLD | NEW |