| 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/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/nullable_string16.h" | 10 #include "base/nullable_string16.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 return true; | 397 return true; |
| 398 } | 398 } |
| 399 | 399 |
| 400 void ParamTraits<std::vector<unsigned char> >::Log(const param_type& p, | 400 void ParamTraits<std::vector<unsigned char> >::Log(const param_type& p, |
| 401 std::string* l) { | 401 std::string* l) { |
| 402 LogBytes(p, l); | 402 LogBytes(p, l); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void ParamTraits<std::vector<bool> >::Write(Message* m, const param_type& p) { | 405 void ParamTraits<std::vector<bool> >::Write(Message* m, const param_type& p) { |
| 406 WriteParam(m, static_cast<int>(p.size())); | 406 WriteParam(m, static_cast<int>(p.size())); |
| 407 // Cast to bool below is required because libc++'s |
| 408 // vector<bool>::const_reference is different from bool, and we want to avoid |
| 409 // writing an extra specialization of ParamTraits for it. |
| 407 for (size_t i = 0; i < p.size(); i++) | 410 for (size_t i = 0; i < p.size(); i++) |
| 408 WriteParam(m, p[i]); | 411 WriteParam(m, static_cast<bool>(p[i])); |
| 409 } | 412 } |
| 410 | 413 |
| 411 bool ParamTraits<std::vector<bool> >::Read(const Message* m, | 414 bool ParamTraits<std::vector<bool> >::Read(const Message* m, |
| 412 PickleIterator* iter, | 415 PickleIterator* iter, |
| 413 param_type* r) { | 416 param_type* r) { |
| 414 int size; | 417 int size; |
| 415 // ReadLength() checks for < 0 itself. | 418 // ReadLength() checks for < 0 itself. |
| 416 if (!m->ReadLength(iter, &size)) | 419 if (!m->ReadLength(iter, &size)) |
| 417 return false; | 420 return false; |
| 418 r->resize(size); | 421 r->resize(size); |
| 419 for (int i = 0; i < size; i++) { | 422 for (int i = 0; i < size; i++) { |
| 420 bool value; | 423 bool value; |
| 421 if (!ReadParam(m, iter, &value)) | 424 if (!ReadParam(m, iter, &value)) |
| 422 return false; | 425 return false; |
| 423 (*r)[i] = value; | 426 (*r)[i] = value; |
| 424 } | 427 } |
| 425 return true; | 428 return true; |
| 426 } | 429 } |
| 427 | 430 |
| 428 void ParamTraits<std::vector<bool> >::Log(const param_type& p, std::string* l) { | 431 void ParamTraits<std::vector<bool> >::Log(const param_type& p, std::string* l) { |
| 429 for (size_t i = 0; i < p.size(); ++i) { | 432 for (size_t i = 0; i < p.size(); ++i) { |
| 430 if (i != 0) | 433 if (i != 0) |
| 431 l->push_back(' '); | 434 l->push_back(' '); |
| 432 LogParam((p[i]), l); | 435 LogParam(static_cast<bool>(p[i]), l); |
| 433 } | 436 } |
| 434 } | 437 } |
| 435 | 438 |
| 436 void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) { | 439 void ParamTraits<DictionaryValue>::Write(Message* m, const param_type& p) { |
| 437 WriteValue(m, &p, 0); | 440 WriteValue(m, &p, 0); |
| 438 } | 441 } |
| 439 | 442 |
| 440 bool ParamTraits<DictionaryValue>::Read( | 443 bool ParamTraits<DictionaryValue>::Read( |
| 441 const Message* m, PickleIterator* iter, param_type* r) { | 444 const Message* m, PickleIterator* iter, param_type* r) { |
| 442 int type; | 445 int type; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 return result; | 818 return result; |
| 816 } | 819 } |
| 817 | 820 |
| 818 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 821 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
| 819 l->append("<MSG>"); | 822 l->append("<MSG>"); |
| 820 } | 823 } |
| 821 | 824 |
| 822 #endif // OS_WIN | 825 #endif // OS_WIN |
| 823 | 826 |
| 824 } // namespace IPC | 827 } // namespace IPC |
| OLD | NEW |