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_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ | 5 #ifndef MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ |
6 #define MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ | 6 #define MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/i18n/rtl.h" |
9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
10 #include "base/unguessable_token.h" | 11 #include "base/unguessable_token.h" |
11 #include "base/version.h" | 12 #include "base/version.h" |
12 #include "mojo/common/file.mojom-shared.h" | 13 #include "mojo/common/file.mojom-shared.h" |
13 #include "mojo/common/mojo_common_export.h" | 14 #include "mojo/common/mojo_common_export.h" |
14 #include "mojo/common/string16.mojom-shared.h" | 15 #include "mojo/common/string16.mojom-shared.h" |
| 16 #include "mojo/common/text_direction.mojom-shared.h" |
15 #include "mojo/common/time.mojom-shared.h" | 17 #include "mojo/common/time.mojom-shared.h" |
16 #include "mojo/common/unguessable_token.mojom-shared.h" | 18 #include "mojo/common/unguessable_token.mojom-shared.h" |
17 #include "mojo/common/version.mojom-shared.h" | 19 #include "mojo/common/version.mojom-shared.h" |
18 | 20 |
19 namespace mojo { | 21 namespace mojo { |
20 | 22 |
21 template <> | 23 template <> |
22 struct StructTraits<common::mojom::String16DataView, base::string16> { | 24 struct StructTraits<common::mojom::String16DataView, base::string16> { |
23 static ConstCArray<uint16_t> data(const base::string16& str) { | 25 static ConstCArray<uint16_t> data(const base::string16& str) { |
24 return ConstCArray<uint16_t>(str.size(), | 26 return ConstCArray<uint16_t>(str.size(), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 template <> | 78 template <> |
77 struct StructTraits<common::mojom::FileDataView, base::File> { | 79 struct StructTraits<common::mojom::FileDataView, base::File> { |
78 static bool IsNull(const base::File& file) { return !file.IsValid(); } | 80 static bool IsNull(const base::File& file) { return !file.IsValid(); } |
79 | 81 |
80 static void SetToNull(base::File* file) { *file = base::File(); } | 82 static void SetToNull(base::File* file) { *file = base::File(); } |
81 | 83 |
82 static mojo::ScopedHandle fd(base::File& file); | 84 static mojo::ScopedHandle fd(base::File& file); |
83 static bool Read(common::mojom::FileDataView data, base::File* file); | 85 static bool Read(common::mojom::FileDataView data, base::File* file); |
84 }; | 86 }; |
85 | 87 |
| 88 template <> |
| 89 struct EnumTraits<common::mojom::TextDirection, base::i18n::TextDirection> { |
| 90 static common::mojom::TextDirection ToMojom( |
| 91 base::i18n::TextDirection text_direction); |
| 92 static bool FromMojom(common::mojom::TextDirection input, |
| 93 base::i18n::TextDirection* out); |
| 94 }; |
| 95 |
86 } // namespace mojo | 96 } // namespace mojo |
87 | 97 |
88 #endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ | 98 #endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ |
OLD | NEW |