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

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

Issue 2136593002: CompositorFrame: Implement ParamTraits versus StructTraits deserialization test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/serialization.h
diff --git a/mojo/public/cpp/bindings/lib/serialization.h b/mojo/public/cpp/bindings/lib/serialization.h
index 5274adf1a57f32667b5353a9bf3b2b2f188ba339..6d7dd8e5cde032a783c2167d2ef5849de60afce1 100644
--- a/mojo/public/cpp/bindings/lib/serialization.h
+++ b/mojo/public/cpp/bindings/lib/serialization.h
@@ -67,7 +67,7 @@ DataArrayType StructSerializeImpl(UserType* input) {
}
template <typename MojomType, typename DataArrayType, typename UserType>
-bool StructDeserializeImpl(DataArrayType input, UserType* output) {
+bool StructDeserializeImpl(const DataArrayType& input, UserType* output) {
static_assert(BelongsTo<MojomType, MojomTypeCategory::STRUCT>::value,
"Unexpected type.");
using DataType = typename MojomType::Struct::Data_;
@@ -75,7 +75,10 @@ bool StructDeserializeImpl(DataArrayType input, UserType* output) {
if (input.is_null())
return false;
- void* input_buffer = input.empty() ? nullptr : &input.front();
+ void* input_buffer =
+ input.empty()
+ ? nullptr
+ : const_cast<void*>(reinterpret_cast<const void*>(&input.front()));
// Please see comments in StructSerializeImpl.
bool need_copy = !IsAligned(input_buffer);

Powered by Google App Engine
This is Rietveld 408576698