Index: dbus/message.cc |
diff --git a/dbus/message.cc b/dbus/message.cc |
index 2750cb187a08329d1e196c6d54817d41180ee54b..a6f8178442366c690e1b5332adea9bca3eda9f25 100644 |
--- a/dbus/message.cc |
+++ b/dbus/message.cc |
@@ -4,6 +4,8 @@ |
#include "dbus/message.h" |
+#include <string> |
+ |
#include "base/basictypes.h" |
#include "base/format_macros.h" |
#include "base/logging.h" |
@@ -592,6 +594,18 @@ void MessageWriter::AppendArrayOfObjectPaths( |
CloseContainer(&array_writer); |
} |
+bool MessageWriter::AppendProtocolBuffer( |
+ const google::protobuf::MessageLite& protobuf) { |
+ std::string serialized_proto; |
+ if (!protobuf.SerializeToString(&serialized_proto)) { |
+ LOG(ERROR) << "Unable to serialize supplied protocol buffer"; |
+ return false; |
+ } |
+ AppendArrayOfBytes(reinterpret_cast<const uint8*>(serialized_proto.data()), |
+ serialized_proto.size()); |
+ return true; |
+} |
+ |
void MessageWriter::AppendVariantOfByte(uint8 value) { |
AppendVariantOfBasic(DBUS_TYPE_BYTE, &value); |
} |
@@ -799,6 +813,21 @@ bool MessageReader::PopArrayOfObjectPaths( |
return true; |
} |
+bool MessageReader::PopProtocolBuffer(google::protobuf::MessageLite* protobuf) { |
+ DCHECK(protobuf != NULL); |
+ char* serialized_buf; |
+ size_t buf_size; |
satorux1
2012/01/31 21:42:31
Please initialize them.
char* serialized_buf = NU
rharrison
2012/02/01 19:03:20
Done.
|
+ if (!PopArrayOfBytes(reinterpret_cast<uint8**>(&serialized_buf), &buf_size)) { |
+ LOG(ERROR) << "Error reading array of bytes"; |
+ return false; |
+ } |
+ if (!protobuf->ParseFromArray(serialized_buf, buf_size)) { |
+ LOG(ERROR) << "Failed to parse protocol buffer from array"; |
+ return false; |
+ } |
+ return true; |
+} |
+ |
bool MessageReader::PopVariantOfByte(uint8* value) { |
return PopVariantOfBasic(DBUS_TYPE_BYTE, value); |
} |