| 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..fed22201e9e3648e15ff7472dc55026270633ed8 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/unguessable_token.h"
|
| #include "base/version.h"
|
| #include "mojo/common/common_custom_types.mojom-shared.h"
|
|
|
| @@ -23,6 +24,40 @@ 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) {
|
| + DCHECK(token);
|
| + uint64_t high, low;
|
| + token.Serialize(&high, &low);
|
| + return high;
|
| + }
|
| +
|
| + static uint64_t low(const base::UnguessableToken& token) {
|
| + DCHECK(token);
|
| + uint64_t high, low;
|
| + token.Serialize(&high, &low);
|
| + return low;
|
| + }
|
| +
|
| + static bool Read(mojo::common::mojom::UnguessableTokenDataView data,
|
| + base::UnguessableToken* out) {
|
| + uint64_t high = data.high();
|
| + uint64_t low = data.low();
|
| +
|
| + *out = base::UnguessableToken::Deserialize(high, low);
|
| +
|
| + // Receiving a zeroed UnguessableToken is a security issue.
|
| + return !out->is_empty();
|
| + }
|
| +};
|
| +
|
| template <>
|
| struct StructTraits<mojo::common::mojom::TimeDeltaDataView, base::TimeDelta> {
|
| static int64_t microseconds(const base::TimeDelta& delta) {
|
|
|