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/i18n/rtl.h" |
10 #include "base/process/process_handle.h" | |
11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
12 #include "base/unguessable_token.h" | 11 #include "base/unguessable_token.h" |
13 #include "base/version.h" | 12 #include "base/version.h" |
14 #include "mojo/common/file.mojom-shared.h" | 13 #include "mojo/common/file.mojom-shared.h" |
15 #include "mojo/common/mojo_common_export.h" | 14 #include "mojo/common/mojo_common_export.h" |
16 #include "mojo/common/process_id.mojom-shared.h" | |
17 #include "mojo/common/string16.mojom-shared.h" | 15 #include "mojo/common/string16.mojom-shared.h" |
18 #include "mojo/common/text_direction.mojom-shared.h" | 16 #include "mojo/common/text_direction.mojom-shared.h" |
19 #include "mojo/common/time.mojom-shared.h" | 17 #include "mojo/common/time.mojom-shared.h" |
20 #include "mojo/common/unguessable_token.mojom-shared.h" | 18 #include "mojo/common/unguessable_token.mojom-shared.h" |
21 #include "mojo/common/version.mojom-shared.h" | 19 #include "mojo/common/version.mojom-shared.h" |
22 | 20 |
23 namespace mojo { | 21 namespace mojo { |
24 | 22 |
25 template <> | 23 template <> |
26 struct StructTraits<common::mojom::String16DataView, base::string16> { | 24 struct StructTraits<common::mojom::String16DataView, base::string16> { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 56 |
59 static uint64_t low(const base::UnguessableToken& token) { | 57 static uint64_t low(const base::UnguessableToken& token) { |
60 return token.GetLowForSerialization(); | 58 return token.GetLowForSerialization(); |
61 } | 59 } |
62 | 60 |
63 static bool Read(common::mojom::UnguessableTokenDataView data, | 61 static bool Read(common::mojom::UnguessableTokenDataView data, |
64 base::UnguessableToken* out); | 62 base::UnguessableToken* out); |
65 }; | 63 }; |
66 | 64 |
67 template <> | 65 template <> |
68 struct StructTraits<common::mojom::ProcessIdDataView, base::ProcessId> { | |
69 static uint32_t pid(const base::ProcessId& process_id) { | |
70 return static_cast<uint32_t>(process_id); | |
71 } | |
72 | |
73 static bool Read(common::mojom::ProcessIdDataView data, | |
74 base::ProcessId* process_id) { | |
75 *process_id = static_cast<base::ProcessId>(data.pid()); | |
76 return true; | |
77 } | |
78 }; | |
79 | |
80 template <> | |
81 struct StructTraits<common::mojom::TimeDeltaDataView, base::TimeDelta> { | 66 struct StructTraits<common::mojom::TimeDeltaDataView, base::TimeDelta> { |
82 static int64_t microseconds(const base::TimeDelta& delta) { | 67 static int64_t microseconds(const base::TimeDelta& delta) { |
83 return delta.InMicroseconds(); | 68 return delta.InMicroseconds(); |
84 } | 69 } |
85 | 70 |
86 static bool Read(common::mojom::TimeDeltaDataView data, | 71 static bool Read(common::mojom::TimeDeltaDataView data, |
87 base::TimeDelta* delta) { | 72 base::TimeDelta* delta) { |
88 *delta = base::TimeDelta::FromMicroseconds(data.microseconds()); | 73 *delta = base::TimeDelta::FromMicroseconds(data.microseconds()); |
89 return true; | 74 return true; |
90 } | 75 } |
(...skipping 13 matching lines...) Expand all Loading... |
104 struct EnumTraits<common::mojom::TextDirection, base::i18n::TextDirection> { | 89 struct EnumTraits<common::mojom::TextDirection, base::i18n::TextDirection> { |
105 static common::mojom::TextDirection ToMojom( | 90 static common::mojom::TextDirection ToMojom( |
106 base::i18n::TextDirection text_direction); | 91 base::i18n::TextDirection text_direction); |
107 static bool FromMojom(common::mojom::TextDirection input, | 92 static bool FromMojom(common::mojom::TextDirection input, |
108 base::i18n::TextDirection* out); | 93 base::i18n::TextDirection* out); |
109 }; | 94 }; |
110 | 95 |
111 } // namespace mojo | 96 } // namespace mojo |
112 | 97 |
113 #endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ | 98 #endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ |
OLD | NEW |