OLD | NEW |
---|---|
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/file_path.h" | 7 #include "base/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/nullable_string16.h" | 10 #include "base/nullable_string16.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 if (data_size) | 419 if (data_size) |
420 memcpy(&r->front(), data, data_size); | 420 memcpy(&r->front(), data, data_size); |
421 return true; | 421 return true; |
422 } | 422 } |
423 | 423 |
424 void ParamTraits<std::vector<unsigned char> >::Log(const param_type& p, | 424 void ParamTraits<std::vector<unsigned char> >::Log(const param_type& p, |
425 std::string* l) { | 425 std::string* l) { |
426 LogBytes(p, l); | 426 LogBytes(p, l); |
427 } | 427 } |
428 | 428 |
429 void ParamTraits<std::vector<signed char> >::Write(Message* m, | |
apatrick_chromium
2012/11/09 19:19:04
Are you sure you need explicit ParamTraits for std
no sievers
2012/11/09 21:53:02
It has the ipc traits for char and unsigned char.
piman
2012/11/09 22:02:01
It will work though use an int for each char (i.e.
no sievers
2012/11/19 20:30:44
I switched it to using strings.
| |
430 const param_type& p) { | |
431 if (p.empty()) { | |
432 m->WriteData(NULL, 0); | |
433 } else { | |
434 m->WriteData(reinterpret_cast<const char*>(&p.front()), | |
435 static_cast<int>(p.size())); | |
436 } | |
437 } | |
438 | |
439 bool ParamTraits<std::vector<signed char> >::Read(const Message* m, | |
440 PickleIterator* iter, | |
441 param_type* r) { | |
442 const char *data; | |
443 int data_size = 0; | |
444 if (!m->ReadData(iter, &data, &data_size) || data_size < 0) | |
445 return false; | |
446 r->resize(data_size); | |
447 if (data_size) | |
448 memcpy(&r->front(), data, data_size); | |
449 return true; | |
450 } | |
451 | |
452 void ParamTraits<std::vector<signed char> >::Log(const param_type& p, | |
453 std::string* l) { | |
454 LogBytes(p, l); | |
455 } | |
456 | |
429 void ParamTraits<std::vector<bool> >::Write(Message* m, const param_type& p) { | 457 void ParamTraits<std::vector<bool> >::Write(Message* m, const param_type& p) { |
430 WriteParam(m, static_cast<int>(p.size())); | 458 WriteParam(m, static_cast<int>(p.size())); |
431 for (size_t i = 0; i < p.size(); i++) | 459 for (size_t i = 0; i < p.size(); i++) |
432 WriteParam(m, p[i]); | 460 WriteParam(m, p[i]); |
433 } | 461 } |
434 | 462 |
435 bool ParamTraits<std::vector<bool> >::Read(const Message* m, | 463 bool ParamTraits<std::vector<bool> >::Read(const Message* m, |
436 PickleIterator* iter, | 464 PickleIterator* iter, |
437 param_type* r) { | 465 param_type* r) { |
438 int size; | 466 int size; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 return result; | 868 return result; |
841 } | 869 } |
842 | 870 |
843 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 871 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
844 l->append("<MSG>"); | 872 l->append("<MSG>"); |
845 } | 873 } |
846 | 874 |
847 #endif // OS_WIN | 875 #endif // OS_WIN |
848 | 876 |
849 } // namespace IPC | 877 } // namespace IPC |
OLD | NEW |