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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (!Deserialize_(input->at(i), &result[i], context)) | 179 if (!Deserialize_(input->at(i), &result[i], context)) |
176 success = false; | 180 success = false; |
177 } | 181 } |
178 output->Swap(&result); | 182 output->Swap(&result); |
179 return success; | 183 return success; |
180 } | 184 } |
181 | 185 |
182 private: | 186 private: |
183 template <typename T, | 187 template <typename T, |
184 bool is_array = IsSpecializationOf<Array, T>::value, | 188 bool is_array = IsSpecializationOf<Array, T>::value, |
185 bool is_string = std::is_same<T, String>::value> | 189 bool is_string = std::is_same<T, String>::value || |
| 190 std::is_same<T, WTF::String>::value> |
186 struct SerializeCaller { | 191 struct SerializeCaller { |
187 static void Run(T input, | 192 static void Run(T input, |
188 Buffer* buf, | 193 Buffer* buf, |
189 typename WrapperTraits<T>::DataType* output, | 194 typename WrapperTraits<T>::DataType* output, |
190 const ArrayValidateParams* validate_params) { | 195 const ArrayValidateParams* validate_params) { |
191 DCHECK(!validate_params) | 196 DCHECK(!validate_params) |
192 << "Struct type should not have array validate params"; | 197 << "Struct type should not have array validate params"; |
193 | 198 |
194 Serialize_(std::move(input), buf, output); | 199 Serialize_(std::move(input), buf, output); |
195 } | 200 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 *output = nullptr; | 424 *output = nullptr; |
420 return true; | 425 return true; |
421 } | 426 } |
422 }; | 427 }; |
423 | 428 |
424 } // namespace internal | 429 } // namespace internal |
425 | 430 |
426 } // namespace mojo | 431 } // namespace mojo |
427 | 432 |
428 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ | 433 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_SERIALIZATION_TRAITS_H_ |
OLD | NEW |