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

Side by Side Diff: ipc/ipc_message_utils.cc

Issue 1418743006: ipc: Add ParamTraits<signed char> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Created 5 years, 1 month 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
« ipc/ipc_message_utils.h ('K') | « ipc/ipc_message_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/nullable_string16.h" 10 #include "base/strings/nullable_string16.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if (!iter->ReadBytes(&data, sizeof(param_type))) 285 if (!iter->ReadBytes(&data, sizeof(param_type)))
286 return false; 286 return false;
287 memcpy(r, data, sizeof(param_type)); 287 memcpy(r, data, sizeof(param_type));
288 return true; 288 return true;
289 } 289 }
290 290
291 void ParamTraits<unsigned char>::Log(const param_type& p, std::string* l) { 291 void ParamTraits<unsigned char>::Log(const param_type& p, std::string* l) {
292 l->append(base::UintToString(p)); 292 l->append(base::UintToString(p));
293 } 293 }
294 294
295 void ParamTraits<signed char>::Write(Message* m, const param_type& p) {
296 m->WriteBytes(&p, sizeof(param_type));
297 }
298
299 bool ParamTraits<signed char>::Read(const Message* m,
300 base::PickleIterator* iter,
301 param_type* r) {
302 const char* data;
303 if (!iter->ReadBytes(&data, sizeof(param_type)))
304 return false;
305 memcpy(r, data, sizeof(param_type));
306 return true;
307 }
308
309 void ParamTraits<signed char>::Log(const param_type& p, std::string* l) {
310 l->append(base::IntToString(p));
311 }
312
295 void ParamTraits<unsigned short>::Write(Message* m, const param_type& p) { 313 void ParamTraits<unsigned short>::Write(Message* m, const param_type& p) {
296 m->WriteBytes(&p, sizeof(param_type)); 314 m->WriteBytes(&p, sizeof(param_type));
297 } 315 }
298 316
299 bool ParamTraits<unsigned short>::Read(const Message* m, 317 bool ParamTraits<unsigned short>::Read(const Message* m,
300 base::PickleIterator* iter, 318 base::PickleIterator* iter,
301 param_type* r) { 319 param_type* r) {
302 const char* data; 320 const char* data;
303 if (!iter->ReadBytes(&data, sizeof(param_type))) 321 if (!iter->ReadBytes(&data, sizeof(param_type)))
304 return false; 322 return false;
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 return result; 1057 return result;
1040 } 1058 }
1041 1059
1042 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { 1060 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) {
1043 l->append("<MSG>"); 1061 l->append("<MSG>");
1044 } 1062 }
1045 1063
1046 #endif // OS_WIN 1064 #endif // OS_WIN
1047 1065
1048 } // namespace IPC 1066 } // namespace IPC
OLDNEW
« ipc/ipc_message_utils.h ('K') | « ipc/ipc_message_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698