Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: mojo/common/common_custom_types_struct_traits.h

Issue 2333443002: Add base::UnguessableToken (Closed)
Patch Set: Removed MOJO_COMMON_EXPORT Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/common/common_custom_types.typemap ('k') | mojo/common/common_custom_types_struct_traits.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5244cf7a2a6108280136a03f9a3bc385c49a5cb2..82e5a8a7a9a5b285b8937b9a77279d7e58fd6879 100644
--- a/mojo/common/common_custom_types_struct_traits.h
+++ b/mojo/common/common_custom_types_struct_traits.h
@@ -5,8 +5,10 @@
#ifndef MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_
#define MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_
+#include "base/unguessable_token.h"
#include "base/version.h"
#include "mojo/common/common_custom_types.mojom-shared.h"
+#include "mojo/common/mojo_common_export.h"
namespace mojo {
@@ -23,6 +25,26 @@ struct StructTraits<mojo::common::mojom::VersionDataView, base::Version> {
base::Version* out);
};
+// If base::UnguessableToken is no longer 128 bits, the logic below and the
+// mojom::UnguessableToken type should be updated.
+static_assert(sizeof(base::UnguessableToken) == 2 * sizeof(uint64_t),
+ "base::UnguessableToken should be of size 2 * sizeof(uint64_t).");
+
+template <>
+struct StructTraits<mojo::common::mojom::UnguessableTokenDataView,
+ base::UnguessableToken> {
+ static uint64_t high(const base::UnguessableToken& token) {
+ return token.GetHighForSerialization();
+ }
+
+ static uint64_t low(const base::UnguessableToken& token) {
+ return token.GetLowForSerialization();
+ }
+
+ static bool Read(mojo::common::mojom::UnguessableTokenDataView data,
+ base::UnguessableToken* out);
+};
+
template <>
struct StructTraits<mojo::common::mojom::TimeDeltaDataView, base::TimeDelta> {
static int64_t microseconds(const base::TimeDelta& delta) {
« no previous file with comments | « mojo/common/common_custom_types.typemap ('k') | mojo/common/common_custom_types_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698