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

Side by Side Diff: dbus/message.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 months 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
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | dbus/message_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 case MESSAGE_METHOD_CALL: 80 case MESSAGE_METHOD_CALL:
81 return "MESSAGE_METHOD_CALL"; 81 return "MESSAGE_METHOD_CALL";
82 case MESSAGE_METHOD_RETURN: 82 case MESSAGE_METHOD_RETURN:
83 return "MESSAGE_METHOD_RETURN"; 83 return "MESSAGE_METHOD_RETURN";
84 case MESSAGE_SIGNAL: 84 case MESSAGE_SIGNAL:
85 return "MESSAGE_SIGNAL"; 85 return "MESSAGE_SIGNAL";
86 case MESSAGE_ERROR: 86 case MESSAGE_ERROR:
87 return "MESSAGE_ERROR"; 87 return "MESSAGE_ERROR";
88 } 88 }
89 NOTREACHED(); 89 NOTREACHED();
90 return ""; 90 return std::string();
91 } 91 }
92 92
93 std::string Message::ToStringInternal(const std::string& indent, 93 std::string Message::ToStringInternal(const std::string& indent,
94 MessageReader* reader) { 94 MessageReader* reader) {
95 const char* kBrokenMessage = "[broken message]"; 95 const char* kBrokenMessage = "[broken message]";
96 std::string output; 96 std::string output;
97 while (reader->HasMoreData()) { 97 while (reader->HasMoreData()) {
98 const DataType type = reader->GetDataType(); 98 const DataType type = reader->GetDataType();
99 switch (type) { 99 switch (type) {
100 case BYTE: { 100 case BYTE: {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // 244 //
245 // destination: com.example.Service 245 // destination: com.example.Service
246 // path: /com/example/Object 246 // path: /com/example/Object
247 // interface: com.example.Interface 247 // interface: com.example.Interface
248 // member: SomeMethod 248 // member: SomeMethod
249 // 249 //
250 // string \"payload\" 250 // string \"payload\"
251 // ... 251 // ...
252 std::string Message::ToString() { 252 std::string Message::ToString() {
253 if (!raw_message_) 253 if (!raw_message_)
254 return ""; 254 return std::string();
255 255
256 // Generate headers first. 256 // Generate headers first.
257 std::string headers; 257 std::string headers;
258 AppendStringHeader("message_type", GetMessageTypeAsString(), &headers); 258 AppendStringHeader("message_type", GetMessageTypeAsString(), &headers);
259 AppendStringHeader("destination", GetDestination(), &headers); 259 AppendStringHeader("destination", GetDestination(), &headers);
260 AppendStringHeader("path", GetPath().value(), &headers); 260 AppendStringHeader("path", GetPath().value(), &headers);
261 AppendStringHeader("interface", GetInterface(), &headers); 261 AppendStringHeader("interface", GetInterface(), &headers);
262 AppendStringHeader("member", GetMember(), &headers); 262 AppendStringHeader("member", GetMember(), &headers);
263 AppendStringHeader("error_name", GetErrorName(), &headers); 263 AppendStringHeader("error_name", GetErrorName(), &headers);
264 AppendStringHeader("sender", GetSender(), &headers); 264 AppendStringHeader("sender", GetSender(), &headers);
265 AppendStringHeader("signature", GetSignature(), &headers); 265 AppendStringHeader("signature", GetSignature(), &headers);
266 AppendUint32Header("serial", GetSerial(), &headers); 266 AppendUint32Header("serial", GetSerial(), &headers);
267 AppendUint32Header("reply_serial", GetReplySerial(), &headers); 267 AppendUint32Header("reply_serial", GetReplySerial(), &headers);
268 268
269 // Generate the payload. 269 // Generate the payload.
270 MessageReader reader(this); 270 MessageReader reader(this);
271 return headers + "\n" + ToStringInternal("", &reader); 271 return headers + "\n" + ToStringInternal(std::string(), &reader);
272 } 272 }
273 273
274 bool Message::SetDestination(const std::string& destination) { 274 bool Message::SetDestination(const std::string& destination) {
275 return dbus_message_set_destination(raw_message_, destination.c_str()); 275 return dbus_message_set_destination(raw_message_, destination.c_str());
276 } 276 }
277 277
278 bool Message::SetPath(const ObjectPath& path) { 278 bool Message::SetPath(const ObjectPath& path) {
279 return dbus_message_set_path(raw_message_, path.value().c_str()); 279 return dbus_message_set_path(raw_message_, path.value().c_str());
280 } 280 }
281 281
(...skipping 697 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
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | dbus/message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698