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

Unified Diff: mojo/public/cpp/bindings/lib/array_serialization.h

Issue 1956603002: Mojo C++ bindings: switch union to use the new serialization interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20_array_serializer
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/array_serialization.h
diff --git a/mojo/public/cpp/bindings/lib/array_serialization.h b/mojo/public/cpp/bindings/lib/array_serialization.h
index 1961a0bbec2bb09abef66333f249af7195415db4..b5caa1b44882586e220aff20846c7856e890f4c4 100644
--- a/mojo/public/cpp/bindings/lib/array_serialization.h
+++ b/mojo/public/cpp/bindings/lib/array_serialization.h
@@ -295,6 +295,7 @@ struct ArraySerializer<MojomType,
ArraySerializerType::UNION> {
using UserType = typename std::remove_const<MaybeConstUserType>::type;
using Data = typename MojomType::Data_;
+ using Element = typename MojomType::Element;
using Traits = ArrayTraits<UserType>;
static_assert(std::is_same<typename MojomType::Element,
@@ -306,10 +307,10 @@ struct ArraySerializer<MojomType,
size_t element_count = Traits::GetSize(input);
size_t size = sizeof(Data);
for (size_t i = 0; i < element_count; ++i) {
- // Call GetSerializedSize_ with |inlined| set to false, so that it will
- // account for both the data in the union and the space in the array used
- // to hold the union.
- size += GetSerializedSize_(Traits::GetAt(input, i), false, context);
+ // Call with |inlined| set to false, so that it will account for both the
+ // data in the union and the space in the array used to hold the union.
+ size +=
+ PrepareToSerialize<Element>(Traits::GetAt(input, i), false, context);
}
return size;
}
@@ -322,8 +323,7 @@ struct ArraySerializer<MojomType,
size_t size = Traits::GetSize(input);
for (size_t i = 0; i < size; ++i) {
typename Data::Element* result = output->storage() + i;
- SerializeUnion_(std::move(Traits::GetAt(input, i)), buf, &result, true,
- context);
+ Serialize<Element>(Traits::GetAt(input, i), buf, &result, true, context);
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!validate_params->element_is_nullable && output->at(i).is_null(),
VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
@@ -341,8 +341,10 @@ struct ArraySerializer<MojomType,
// Note that we rely on complete deserialization taking place in order to
// transfer ownership of all encoded handles. Therefore we don't
// short-circuit on failure here.
- if (!Deserialize_(&input->at(i), &Traits::GetAt(*output, i), context))
+ if (!Deserialize<Element>(&input->at(i), &Traits::GetAt(*output, i),
+ context)) {
success = false;
+ }
}
return success;
}

Powered by Google App Engine
This is Rietveld 408576698