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

Unified Diff: mojo/common/common_custom_types_struct_traits.cc

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_struct_traits.h ('k') | mojo/common/common_custom_types_unittest.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.cc
diff --git a/mojo/common/common_custom_types_struct_traits.cc b/mojo/common/common_custom_types_struct_traits.cc
index 91fc9524d2b3b14a4ef788c7f6dc8f03e0db1947..21026d4d78e9ce3d6486d4435d9b74f3057ae05c 100644
--- a/mojo/common/common_custom_types_struct_traits.cc
+++ b/mojo/common/common_custom_types_struct_traits.cc
@@ -27,4 +27,20 @@ bool StructTraits<mojo::common::mojom::VersionDataView, base::Version>::Read(
return out->IsValid();
}
+// static
+bool StructTraits<mojo::common::mojom::UnguessableTokenDataView,
+ base::UnguessableToken>::
+ Read(mojo::common::mojom::UnguessableTokenDataView data,
+ base::UnguessableToken* out) {
+ uint64_t high = data.high();
+ uint64_t low = data.low();
+
+ // Receiving a zeroed UnguessableToken is a security issue.
+ if (high == 0 && low == 0)
+ return false;
+
+ *out = base::UnguessableToken::Deserialize(high, low);
+ return true;
+}
+
} // namespace mojo
« no previous file with comments | « mojo/common/common_custom_types_struct_traits.h ('k') | mojo/common/common_custom_types_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698