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

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

Issue 1857343004: Mojo: Don't short-circuit when failing to deserialize arrays of native types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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
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
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_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698