| 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_ARRAY_SERIALIZATION_TRAITS_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <string.h> // For |memcpy()|. | 9 #include <string.h> // For |memcpy()|. |
| 10 | 10 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 static_assert( | 391 static_assert( |
| 392 std::is_same<F, Array_Data<uint8_t>*>::value, | 392 std::is_same<F, Array_Data<uint8_t>*>::value, |
| 393 "Native-only type array must deserialize from array of byte arrays."); | 393 "Native-only type array must deserialize from array of byte arrays."); |
| 394 DCHECK(input); | 394 DCHECK(input); |
| 395 | 395 |
| 396 ArrayType result(input->size()); | 396 ArrayType result(input->size()); |
| 397 bool success = true; | 397 bool success = true; |
| 398 for (size_t i = 0; i < input->size(); ++i) { | 398 for (size_t i = 0; i < input->size(); ++i) { |
| 399 // We don't short-circuit on failure since we can't know what the native | 399 // We don't short-circuit on failure since we can't know what the native |
| 400 // type's ParamTraits' expectations are. | 400 // type's ParamTraits' expectations are. |
| 401 success = | 401 if (!DeserializeNative_(input->at(i), &result[i], context)) |
| 402 success && DeserializeNative_(input->at(i), &result[i], context); | 402 success = false; |
| 403 } | 403 } |
| 404 output->Swap(&result); | 404 output->Swap(&result); |
| 405 return success; | 405 return success; |
| 406 } | 406 } |
| 407 }; | 407 }; |
| 408 | 408 |
| 409 template <typename ArrayType> | 409 template <typename ArrayType> |
| 410 struct ArraySerializationImpl { | 410 struct ArraySerializationImpl { |
| 411 using Strategy = ArraySerializationStrategy<ArrayType>; | 411 using Strategy = ArraySerializationStrategy<ArrayType>; |
| 412 | 412 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 *output = nullptr; | 447 *output = nullptr; |
| 448 return true; | 448 return true; |
| 449 } | 449 } |
| 450 }; | 450 }; |
| 451 | 451 |
| 452 } // namespace internal | 452 } // namespace internal |
| 453 | 453 |
| 454 } // namespace mojo | 454 } // namespace mojo |
| 455 | 455 |
| 456 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ | 456 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ |
| OLD | NEW |