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

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

Issue 2259283003: Mojo C++ bindings: share DataView class between chromium and blink variants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@92_change_traits_param
Patch Set: . Created 4 years, 4 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 | « mojo/public/cpp/bindings/lib/serialization.h ('k') | mojo/public/cpp/bindings/map_data_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/serialization.h ('k') | mojo/public/cpp/bindings/map_data_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698