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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_message_utils.h" 5 #include "ipc/ipc_message_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/nonce.h"
12 #include "base/strings/nullable_string16.h" 13 #include "base/strings/nullable_string16.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "ipc/ipc_channel_handle.h" 19 #include "ipc/ipc_channel_handle.h"
19 #include "ipc/ipc_message_attachment.h" 20 #include "ipc/ipc_message_attachment.h"
20 #include "ipc/ipc_message_attachment_set.h" 21 #include "ipc/ipc_message_attachment_set.h"
21 #include "ipc/ipc_mojo_param_traits.h" 22 #include "ipc/ipc_mojo_param_traits.h"
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 if (ret) 992 if (ret)
992 *r = base::TimeTicks::FromInternalValue(value); 993 *r = base::TimeTicks::FromInternalValue(value);
993 994
994 return ret; 995 return ret;
995 } 996 }
996 997
997 void ParamTraits<base::TimeTicks>::Log(const param_type& p, std::string* l) { 998 void ParamTraits<base::TimeTicks>::Log(const param_type& p, std::string* l) {
998 ParamTraits<int64_t>::Log(p.ToInternalValue(), l); 999 ParamTraits<int64_t>::Log(p.ToInternalValue(), l);
999 } 1000 }
1000 1001
1002 void ParamTraits<base::Nonce>::GetSize(base::PickleSizer* sizer,
1003 const param_type& p) {
1004 sizer->AddBytes(sizeof(param_type));
1005 }
1006
1007 void ParamTraits<base::Nonce>::Write(base::Pickle* m, const param_type& p) {
1008 m->WriteBytes(reinterpret_cast<const char*>(&p), sizeof(param_type));
1009 }
1010
1011 bool ParamTraits<base::Nonce>::Read(const base::Pickle* m,
1012 base::PickleIterator* iter,
1013 param_type* r) {
1014 const char* data;
1015 if (!iter->ReadBytes(&data, sizeof(param_type)))
1016 return false;
1017
1018 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.
1019 return true;
1020 }
1021
1022 void ParamTraits<base::Nonce>::Log(const param_type& p, std::string* l) {
1023 l->append(p.ToString());
1024 }
1025
1001 void ParamTraits<IPC::ChannelHandle>::GetSize(base::PickleSizer* sizer, 1026 void ParamTraits<IPC::ChannelHandle>::GetSize(base::PickleSizer* sizer,
1002 const param_type& p) { 1027 const param_type& p) {
1003 GetParamSize(sizer, p.name); 1028 GetParamSize(sizer, p.name);
1004 #if defined(OS_POSIX) 1029 #if defined(OS_POSIX)
1005 GetParamSize(sizer, p.socket); 1030 GetParamSize(sizer, p.socket);
1006 #endif 1031 #endif
1007 GetParamSize(sizer, p.mojo_handle); 1032 GetParamSize(sizer, p.mojo_handle);
1008 } 1033 }
1009 1034
1010 void ParamTraits<IPC::ChannelHandle>::Write(base::Pickle* m, 1035 void ParamTraits<IPC::ChannelHandle>::Write(base::Pickle* m,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 return result; 1236 return result;
1212 } 1237 }
1213 1238
1214 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { 1239 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) {
1215 l->append("<MSG>"); 1240 l->append("<MSG>");
1216 } 1241 }
1217 1242
1218 #endif // OS_WIN 1243 #endif // OS_WIN
1219 1244
1220 } // namespace IPC 1245 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698