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 "dbus/message.h" | 5 #include "dbus/message.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 std::string value; | 166 std::string value; |
167 if (!reader->PopString(&value)) | 167 if (!reader->PopString(&value)) |
168 return kBrokenMessage; | 168 return kBrokenMessage; |
169 // Truncate if the string is longer than the limit. | 169 // Truncate if the string is longer than the limit. |
170 const size_t kTruncateLength = 100; | 170 const size_t kTruncateLength = 100; |
171 if (value.size() < kTruncateLength) { | 171 if (value.size() < kTruncateLength) { |
172 output += indent + "string \"" + value + "\"\n"; | 172 output += indent + "string \"" + value + "\"\n"; |
173 } else { | 173 } else { |
174 std::string truncated; | 174 std::string truncated; |
175 TruncateUTF8ToByteSize(value, kTruncateLength, &truncated); | 175 TruncateUTF8ToByteSize(value, kTruncateLength, &truncated); |
176 base::StringAppendF(&truncated, "... (%"PRIuS" bytes in total)", | 176 base::StringAppendF(&truncated, "... (%" PRIuS " bytes in total)", |
177 value.size()); | 177 value.size()); |
178 output += indent + "string \"" + truncated + "\"\n"; | 178 output += indent + "string \"" + truncated + "\"\n"; |
179 } | 179 } |
180 break; | 180 break; |
181 } | 181 } |
182 case OBJECT_PATH: { | 182 case OBJECT_PATH: { |
183 ObjectPath value; | 183 ObjectPath value; |
184 if (!reader->PopObjectPath(&value)) | 184 if (!reader->PopObjectPath(&value)) |
185 return kBrokenMessage; | 185 return kBrokenMessage; |
186 output += indent + "object_path \"" + value.value() + "\"\n"; | 186 output += indent + "object_path \"" + value.value() + "\"\n"; |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); | 979 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); |
980 if (!success) | 980 if (!success) |
981 return false; | 981 return false; |
982 | 982 |
983 value->PutValue(fd); | 983 value->PutValue(fd); |
984 // NB: the caller must check validity before using the value | 984 // NB: the caller must check validity before using the value |
985 return true; | 985 return true; |
986 } | 986 } |
987 | 987 |
988 } // namespace dbus | 988 } // namespace dbus |
OLD | NEW |