| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_STRING_SERIALIZATION_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_STRING_SERIALIZATION_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_STRING_SERIALIZATION_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_STRING_SERIALIZATION_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 11 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
| 12 #include "mojo/public/cpp/bindings/lib/serialization_forward.h" | 12 #include "mojo/public/cpp/bindings/lib/serialization_forward.h" |
| 13 #include "mojo/public/cpp/bindings/lib/serialization_util.h" | 13 #include "mojo/public/cpp/bindings/lib/serialization_util.h" |
| 14 #include "mojo/public/cpp/bindings/string.h" | 14 #include "mojo/public/cpp/bindings/string_data_view.h" |
| 15 #include "mojo/public/cpp/bindings/string_traits.h" | 15 #include "mojo/public/cpp/bindings/string_traits.h" |
| 16 | 16 |
| 17 namespace mojo { | 17 namespace mojo { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 template <typename MaybeConstUserType> | 20 template <typename MaybeConstUserType> |
| 21 struct Serializer<String, MaybeConstUserType> { | 21 struct Serializer<StringDataView, MaybeConstUserType> { |
| 22 using UserType = typename std::remove_const<MaybeConstUserType>::type; | 22 using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| 23 using Traits = StringTraits<UserType>; | 23 using Traits = StringTraits<UserType>; |
| 24 | 24 |
| 25 static size_t PrepareToSerialize(MaybeConstUserType& input, | 25 static size_t PrepareToSerialize(MaybeConstUserType& input, |
| 26 SerializationContext* context) { | 26 SerializationContext* context) { |
| 27 if (CallIsNullIfExists<Traits>(input)) | 27 if (CallIsNullIfExists<Traits>(input)) |
| 28 return 0; | 28 return 0; |
| 29 | 29 |
| 30 void* custom_context = CustomContextHelper<Traits>::SetUp(input, context); | 30 void* custom_context = CustomContextHelper<Traits>::SetUp(input, context); |
| 31 return Align(sizeof(String_Data) + | 31 return Align(sizeof(String_Data) + |
| (...skipping 29 matching lines...) Expand all Loading... |
| 61 if (!input) | 61 if (!input) |
| 62 return CallSetToNullIfExists<Traits>(output); | 62 return CallSetToNullIfExists<Traits>(output); |
| 63 return Traits::Read(StringDataView(input, context), output); | 63 return Traits::Read(StringDataView(input, context), output); |
| 64 } | 64 } |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace internal | 67 } // namespace internal |
| 68 } // namespace mojo | 68 } // namespace mojo |
| 69 | 69 |
| 70 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_STRING_SERIALIZATION_H_ | 70 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_STRING_SERIALIZATION_H_ |
| OLD | NEW |