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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 StringPrintf(" and %u more bytes", | 44 StringPrintf(" and %u more bytes", |
45 static_cast<unsigned>(data.size() - kMaxBytesToLog))); | 45 static_cast<unsigned>(data.size() - kMaxBytesToLog))); |
46 } | 46 } |
47 #endif | 47 #endif |
48 } | 48 } |
49 | 49 |
50 bool ReadValue(const Message* m, PickleIterator* iter, Value** value, | 50 bool ReadValue(const Message* m, PickleIterator* iter, Value** value, |
51 int recursion); | 51 int recursion); |
52 | 52 |
53 void WriteValue(Message* m, const Value* value, int recursion) { | 53 void WriteValue(Message* m, const Value* value, int recursion) { |
| 54 bool result; |
54 if (recursion > kMaxRecursionDepth) { | 55 if (recursion > kMaxRecursionDepth) { |
55 LOG(WARNING) << "Max recursion depth hit in WriteValue."; | 56 LOG(WARNING) << "Max recursion depth hit in WriteValue."; |
56 return; | 57 return; |
57 } | 58 } |
58 | 59 |
59 m->WriteInt(value->GetType()); | 60 m->WriteInt(value->GetType()); |
60 | 61 |
61 switch (value->GetType()) { | 62 switch (value->GetType()) { |
62 case Value::TYPE_NULL: | 63 case Value::TYPE_NULL: |
63 break; | 64 break; |
64 case Value::TYPE_BOOLEAN: { | 65 case Value::TYPE_BOOLEAN: { |
65 bool val; | 66 bool val; |
66 value->GetAsBoolean(&val); | 67 result = value->GetAsBoolean(&val); |
| 68 DCHECK(result); |
67 WriteParam(m, val); | 69 WriteParam(m, val); |
68 break; | 70 break; |
69 } | 71 } |
70 case Value::TYPE_INTEGER: { | 72 case Value::TYPE_INTEGER: { |
71 int val; | 73 int val; |
72 value->GetAsInteger(&val); | 74 result = value->GetAsInteger(&val); |
| 75 DCHECK(result); |
73 WriteParam(m, val); | 76 WriteParam(m, val); |
74 break; | 77 break; |
75 } | 78 } |
76 case Value::TYPE_DOUBLE: { | 79 case Value::TYPE_DOUBLE: { |
77 double val; | 80 double val; |
78 value->GetAsDouble(&val); | 81 result = value->GetAsDouble(&val); |
| 82 DCHECK(result); |
79 WriteParam(m, val); | 83 WriteParam(m, val); |
80 break; | 84 break; |
81 } | 85 } |
82 case Value::TYPE_STRING: { | 86 case Value::TYPE_STRING: { |
83 std::string val; | 87 std::string val; |
84 value->GetAsString(&val); | 88 result = value->GetAsString(&val); |
| 89 DCHECK(result); |
85 WriteParam(m, val); | 90 WriteParam(m, val); |
86 break; | 91 break; |
87 } | 92 } |
88 case Value::TYPE_BINARY: { | 93 case Value::TYPE_BINARY: { |
89 const base::BinaryValue* binary = | 94 const base::BinaryValue* binary = |
90 static_cast<const base::BinaryValue*>(value); | 95 static_cast<const base::BinaryValue*>(value); |
91 m->WriteData(binary->GetBuffer(), static_cast<int>(binary->GetSize())); | 96 m->WriteData(binary->GetBuffer(), static_cast<int>(binary->GetSize())); |
92 break; | 97 break; |
93 } | 98 } |
94 case Value::TYPE_DICTIONARY: { | 99 case Value::TYPE_DICTIONARY: { |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 return result; | 840 return result; |
836 } | 841 } |
837 | 842 |
838 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 843 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
839 l->append("<MSG>"); | 844 l->append("<MSG>"); |
840 } | 845 } |
841 | 846 |
842 #endif // OS_WIN | 847 #endif // OS_WIN |
843 | 848 |
844 } // namespace IPC | 849 } // namespace IPC |
OLD | NEW |