Index: mojo/common/common_custom_types_struct_traits.h |
diff --git a/mojo/common/common_custom_types_struct_traits.h b/mojo/common/common_custom_types_struct_traits.h |
index 37fc5ca298a024430ca3d4e61c437d766a9749ea..706aef2428bb1942e9b43c54a78caf9caeaff2c8 100644 |
--- a/mojo/common/common_custom_types_struct_traits.h |
+++ b/mojo/common/common_custom_types_struct_traits.h |
@@ -5,6 +5,7 @@ |
#ifndef MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ |
#define MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ |
+#include "base/nonce.h" |
#include "base/version.h" |
#include "mojo/common/common_custom_types.mojom-shared.h" |
@@ -23,6 +24,22 @@ struct StructTraits<mojo::common::mojom::VersionDataView, base::Version> { |
base::Version* out); |
}; |
+template <> |
+struct StructTraits<mojo::common::mojom::NonceDataView, base::Nonce> { |
+ static bool IsNull(const base::Nonce& nonce) { return nonce.is_empty(); } |
+ |
+ static void SetToNull(base::Nonce* out) { *out = base::Nonce(); } |
dcheng
2016/09/13 23:19:06
Do we actually need to support nullability? I'd su
tguilbert
2016/09/14 22:40:48
Done.
|
+ |
+ static uint64_t high(const base::Nonce& nonce) { return nonce.high(); } |
+ |
+ static uint64_t low(const base::Nonce& nonce) { return nonce.low(); } |
+ |
+ static bool Read(mojo::common::mojom::NonceDataView data, base::Nonce* out) { |
+ *out = base::Nonce::Deserialize(data.high(), data.low()); |
+ return !out->is_empty(); |
+ } |
+}; |
+ |
} // namespace mojo |
#endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ |