| 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/strings/utf_string_conversions.h" |
| 8 #include "base/unguessable_token.h" | 9 #include "base/unguessable_token.h" |
| 9 #include "base/version.h" | 10 #include "base/version.h" |
| 10 #include "mojo/common/common_custom_types.mojom-shared.h" | 11 #include "mojo/common/common_custom_types.mojom-shared.h" |
| 11 #include "mojo/common/mojo_common_export.h" | 12 #include "mojo/common/mojo_common_export.h" |
| 12 | 13 |
| 13 namespace mojo { | 14 namespace mojo { |
| 14 | 15 |
| 15 template <> | 16 template <> |
| 17 struct StructTraits<mojo::common::mojom::String16DataView, base::string16> { |
| 18 static mojo::ConstCArray<uint16_t> data(const base::string16& str); |
| 19 static bool Read(mojo::common::mojom::String16DataView data, |
| 20 base::string16* out); |
| 21 }; |
| 22 |
| 23 template <> |
| 16 struct StructTraits<mojo::common::mojom::VersionDataView, base::Version> { | 24 struct StructTraits<mojo::common::mojom::VersionDataView, base::Version> { |
| 17 static bool IsNull(const base::Version& version) { | 25 static bool IsNull(const base::Version& version) { |
| 18 return !version.IsValid(); | 26 return !version.IsValid(); |
| 19 } | 27 } |
| 20 static void SetToNull(base::Version* out) { | 28 static void SetToNull(base::Version* out) { |
| 21 *out = base::Version(std::string()); | 29 *out = base::Version(std::string()); |
| 22 } | 30 } |
| 23 static const std::vector<uint32_t>& components(const base::Version& version); | 31 static const std::vector<uint32_t>& components(const base::Version& version); |
| 24 static bool Read(mojo::common::mojom::VersionDataView data, | 32 static bool Read(mojo::common::mojom::VersionDataView data, |
| 25 base::Version* out); | 33 base::Version* out); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 static bool Read(mojo::common::mojom::TimeDeltaDataView data, | 62 static bool Read(mojo::common::mojom::TimeDeltaDataView data, |
| 55 base::TimeDelta* delta) { | 63 base::TimeDelta* delta) { |
| 56 *delta = base::TimeDelta::FromMicroseconds(data.microseconds()); | 64 *delta = base::TimeDelta::FromMicroseconds(data.microseconds()); |
| 57 return true; | 65 return true; |
| 58 } | 66 } |
| 59 }; | 67 }; |
| 60 | 68 |
| 61 } // namespace mojo | 69 } // namespace mojo |
| 62 | 70 |
| 63 #endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ | 71 #endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ |
| OLD | NEW |