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

Unified Diff: ipc/ipc_message_utils.cc

Issue 2333443002: Add base::UnguessableToken (Closed)
Patch Set: Addressing comments. 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
Index: ipc/ipc_message_utils.cc
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index 60c12ab60f96f879259612c993acf89d0c749cd0..c7f4fae24f938ef08209536fa681d8cfd18a921c 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -9,6 +9,7 @@
#include "base/files/file_path.h"
#include "base/json/json_writer.h"
+#include "base/nonce.h"
#include "base/strings/nullable_string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -998,6 +999,30 @@ void ParamTraits<base::TimeTicks>::Log(const param_type& p, std::string* l) {
ParamTraits<int64_t>::Log(p.ToInternalValue(), l);
}
+void ParamTraits<base::Nonce>::GetSize(base::PickleSizer* sizer,
+ const param_type& p) {
+ sizer->AddBytes(sizeof(param_type));
+}
+
+void ParamTraits<base::Nonce>::Write(base::Pickle* m, const param_type& p) {
+ m->WriteBytes(reinterpret_cast<const char*>(&p), sizeof(param_type));
+}
+
+bool ParamTraits<base::Nonce>::Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ const char* data;
+ if (!iter->ReadBytes(&data, sizeof(param_type)))
+ return false;
+
+ memcpy(r, data, sizeof(param_type));
Tom Sepez 2016/09/13 18:20:41 Yes, this works, but I'm less thrilled with copyin
tguilbert 2016/09/13 20:20:19 Done.
+ return true;
+}
+
+void ParamTraits<base::Nonce>::Log(const param_type& p, std::string* l) {
+ l->append(p.ToString());
+}
+
void ParamTraits<IPC::ChannelHandle>::GetSize(base::PickleSizer* sizer,
const param_type& p) {
GetParamSize(sizer, p.name);

Powered by Google App Engine
This is Rietveld 408576698