OLD | NEW |
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 |
11 #include <limits> | 11 #include <limits> |
12 #include <type_traits> | 12 #include <type_traits> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 17 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
18 #include "mojo/public/cpp/bindings/lib/serialization_forward.h" | 18 #include "mojo/public/cpp/bindings/lib/serialization_forward.h" |
19 #include "mojo/public/cpp/bindings/lib/template_util.h" | 19 #include "mojo/public/cpp/bindings/lib/template_util.h" |
20 #include "mojo/public/cpp/bindings/lib/validation_errors.h" | 20 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
21 | 21 |
| 22 namespace WTF { |
| 23 class String; |
| 24 } |
| 25 |
22 namespace mojo { | 26 namespace mojo { |
23 namespace internal { | 27 namespace internal { |
24 | 28 |
25 template <typename ArrayType, | 29 template <typename ArrayType, |
26 typename ElementType, | 30 typename ElementType, |
27 typename ElementDataType, | 31 typename ElementDataType, |
28 bool is_union = IsUnionDataType< | 32 bool is_union = IsUnionDataType< |
29 typename RemovePointer<ElementDataType>::type>::value> | 33 typename RemovePointer<ElementDataType>::type>::value> |
30 struct ArraySerializer; | 34 struct ArraySerializer; |
31 | 35 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (!Deserialize_(input->at(i), &result[i], context)) | 188 if (!Deserialize_(input->at(i), &result[i], context)) |
185 success = false; | 189 success = false; |
186 } | 190 } |
187 output->Swap(&result); | 191 output->Swap(&result); |
188 return success; | 192 return success; |
189 } | 193 } |
190 | 194 |
191 private: | 195 private: |
192 template <typename T, | 196 template <typename T, |
193 bool is_array = IsSpecializationOf<Array, T>::value, | 197 bool is_array = IsSpecializationOf<Array, T>::value, |
194 bool is_string = std::is_same<T, String>::value> | 198 bool is_string = std::is_same<T, String>::value || |
| 199 std::is_same<T, WTF::String>::value> |
195 struct SerializeCaller { | 200 struct SerializeCaller { |
196 static void Run(T input, | 201 static void Run(T input, |
197 Buffer* buf, | 202 Buffer* buf, |
198 typename WrapperTraits<T>::DataType* output, | 203 typename WrapperTraits<T>::DataType* output, |
199 const ArrayValidateParams* validate_params, | 204 const ArrayValidateParams* validate_params, |
200 SerializationContext* context) { | 205 SerializationContext* context) { |
201 DCHECK(!validate_params) | 206 DCHECK(!validate_params) |
202 << "Struct type should not have array validate params"; | 207 << "Struct type should not have array validate params"; |
203 | 208 |
204 Serialize_(std::move(input), buf, output, context); | 209 Serialize_(std::move(input), buf, output, context); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 *output = nullptr; | 446 *output = nullptr; |
442 return true; | 447 return true; |
443 } | 448 } |
444 }; | 449 }; |
445 | 450 |
446 } // namespace internal | 451 } // namespace internal |
447 | 452 |
448 } // namespace mojo | 453 } // namespace mojo |
449 | 454 |
450 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ | 455 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ |
OLD | NEW |