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