Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: dbus/message.cc

Issue 102843002: Move RemoveChars, ReplaceChars, TrimString, and TruncateUTF8ToByteSize to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 case STRING: { 165 case STRING: {
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 base::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;
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698