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/strings/nullable_string16.h" | 10 #include "base/strings/nullable_string16.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Helper for ReadValue that reads a DictionaryValue into a pre-allocated | 127 // Helper for ReadValue that reads a DictionaryValue into a pre-allocated |
128 // object. | 128 // object. |
129 bool ReadDictionaryValue(const Message* m, PickleIterator* iter, | 129 bool ReadDictionaryValue(const Message* m, PickleIterator* iter, |
130 base::DictionaryValue* value, int recursion) { | 130 base::DictionaryValue* value, int recursion) { |
131 int size; | 131 int size; |
132 if (!ReadParam(m, iter, &size)) | 132 if (!ReadParam(m, iter, &size)) |
133 return false; | 133 return false; |
134 | 134 |
135 for (int i = 0; i < size; ++i) { | 135 for (int i = 0; i < size; ++i) { |
136 std::string key; | 136 std::string key; |
137 Value* subval; | 137 base::Value* subval; |
138 if (!ReadParam(m, iter, &key) || | 138 if (!ReadParam(m, iter, &key) || |
139 !ReadValue(m, iter, &subval, recursion + 1)) | 139 !ReadValue(m, iter, &subval, recursion + 1)) |
140 return false; | 140 return false; |
141 value->SetWithoutPathExpansion(key, subval); | 141 value->SetWithoutPathExpansion(key, subval); |
142 } | 142 } |
143 | 143 |
144 return true; | 144 return true; |
145 } | 145 } |
146 | 146 |
147 // Helper for ReadValue that reads a ReadListValue into a pre-allocated | 147 // Helper for ReadValue that reads a ReadListValue into a pre-allocated |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 439 } |
440 | 440 |
441 void ParamTraits<base::DictionaryValue>::Write(Message* m, | 441 void ParamTraits<base::DictionaryValue>::Write(Message* m, |
442 const param_type& p) { | 442 const param_type& p) { |
443 WriteValue(m, &p, 0); | 443 WriteValue(m, &p, 0); |
444 } | 444 } |
445 | 445 |
446 bool ParamTraits<base::DictionaryValue>::Read( | 446 bool ParamTraits<base::DictionaryValue>::Read( |
447 const Message* m, PickleIterator* iter, param_type* r) { | 447 const Message* m, PickleIterator* iter, param_type* r) { |
448 int type; | 448 int type; |
449 if (!ReadParam(m, iter, &type) || type != Value::TYPE_DICTIONARY) | 449 if (!ReadParam(m, iter, &type) || type != base::Value::TYPE_DICTIONARY) |
450 return false; | 450 return false; |
451 | 451 |
452 return ReadDictionaryValue(m, iter, r, 0); | 452 return ReadDictionaryValue(m, iter, r, 0); |
453 } | 453 } |
454 | 454 |
455 void ParamTraits<base::DictionaryValue>::Log(const param_type& p, | 455 void ParamTraits<base::DictionaryValue>::Log(const param_type& p, |
456 std::string* l) { | 456 std::string* l) { |
457 std::string json; | 457 std::string json; |
458 base::JSONWriter::Write(&p, &json); | 458 base::JSONWriter::Write(&p, &json); |
459 l->append(json); | 459 l->append(json); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 ParamTraits<base::FilePath::StringType>::Log(p.value(), l); | 510 ParamTraits<base::FilePath::StringType>::Log(p.value(), l); |
511 } | 511 } |
512 | 512 |
513 void ParamTraits<base::ListValue>::Write(Message* m, const param_type& p) { | 513 void ParamTraits<base::ListValue>::Write(Message* m, const param_type& p) { |
514 WriteValue(m, &p, 0); | 514 WriteValue(m, &p, 0); |
515 } | 515 } |
516 | 516 |
517 bool ParamTraits<base::ListValue>::Read( | 517 bool ParamTraits<base::ListValue>::Read( |
518 const Message* m, PickleIterator* iter, param_type* r) { | 518 const Message* m, PickleIterator* iter, param_type* r) { |
519 int type; | 519 int type; |
520 if (!ReadParam(m, iter, &type) || type != Value::TYPE_LIST) | 520 if (!ReadParam(m, iter, &type) || type != base::Value::TYPE_LIST) |
521 return false; | 521 return false; |
522 | 522 |
523 return ReadListValue(m, iter, r, 0); | 523 return ReadListValue(m, iter, r, 0); |
524 } | 524 } |
525 | 525 |
526 void ParamTraits<base::ListValue>::Log(const param_type& p, std::string* l) { | 526 void ParamTraits<base::ListValue>::Log(const param_type& p, std::string* l) { |
527 std::string json; | 527 std::string json; |
528 base::JSONWriter::Write(&p, &json); | 528 base::JSONWriter::Write(&p, &json); |
529 l->append(json); | 529 l->append(json); |
530 } | 530 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 return result; | 825 return result; |
826 } | 826 } |
827 | 827 |
828 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 828 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
829 l->append("<MSG>"); | 829 l->append("<MSG>"); |
830 } | 830 } |
831 | 831 |
832 #endif // OS_WIN | 832 #endif // OS_WIN |
833 | 833 |
834 } // namespace IPC | 834 } // namespace IPC |
OLD | NEW |