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

Unified Diff: mojo/public/cpp/bindings/lib/message_builder.cc

Issue 1524613002: [mojo] Use base::Pickle for Message storage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: happy compiler happy robots Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/message_builder.h ('k') | mojo/public/cpp/bindings/lib/message_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/message_builder.cc
diff --git a/mojo/public/cpp/bindings/lib/message_builder.cc b/mojo/public/cpp/bindings/lib/message_builder.cc
index 25f1862e47ea8b1fba531f70cd5a0ebbd7eaa332..5319f4be2f83052cb978b5c6bca822065847baa8 100644
--- a/mojo/public/cpp/bindings/lib/message_builder.cc
+++ b/mojo/public/cpp/bindings/lib/message_builder.cc
@@ -17,10 +17,10 @@ void Allocate(Buffer* buf, Header** header) {
}
MessageBuilder::MessageBuilder(uint32_t name, size_t payload_size) {
- Initialize(sizeof(MessageHeader) + payload_size);
+ InitializeMessage(sizeof(MessageHeader) + payload_size);
MessageHeader* header;
- Allocate(&buf_, &header);
+ Allocate(message_.buffer(), &header);
header->version = 0;
header->name = name;
}
@@ -30,18 +30,19 @@ MessageBuilder::~MessageBuilder() {
MessageBuilder::MessageBuilder() {}
-void MessageBuilder::Initialize(size_t size) {
- message_.AllocData(static_cast<uint32_t>(Align(size)));
- buf_.Initialize(message_.mutable_data(), message_.data_num_bytes());
+void MessageBuilder::InitializeMessage(size_t size) {
+ message_.Initialize(static_cast<uint32_t>(Align(size)),
+ true /* zero_initialized */);
}
MessageWithRequestIDBuilder::MessageWithRequestIDBuilder(uint32_t name,
size_t payload_size,
uint32_t flags,
uint64_t request_id) {
- Initialize(sizeof(MessageHeaderWithRequestID) + payload_size);
+ InitializeMessage(sizeof(MessageHeaderWithRequestID) + payload_size);
+
MessageHeaderWithRequestID* header;
- Allocate(&buf_, &header);
+ Allocate(message_.buffer(), &header);
header->version = 1;
header->name = name;
header->flags = flags;
« no previous file with comments | « mojo/public/cpp/bindings/lib/message_builder.h ('k') | mojo/public/cpp/bindings/lib/message_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698