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

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

Issue 23913008: C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows build error. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/bindings/lib/message_builder.h ('k') | mojo/public/bindings/sample/generated/sample_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/lib/message_builder.cc
diff --git a/mojo/public/bindings/lib/message_builder.cc b/mojo/public/bindings/lib/message_builder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f861a6b0d1e92645aa9a330bb53207dc53698a15
--- /dev/null
+++ b/mojo/public/bindings/lib/message_builder.cc
@@ -0,0 +1,26 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/public/bindings/lib/message_builder.h"
+
+#include "mojo/public/bindings/lib/message.h"
+
+namespace mojo {
+
+MessageBuilder::MessageBuilder(uint32_t message_name, size_t payload_size)
+ : buf_(sizeof(MessageHeader) + payload_size) {
+ MessageHeader* header =
+ static_cast<MessageHeader*>(buf_.Allocate(sizeof(MessageHeader)));
+ header->num_bytes = static_cast<uint32_t>(buf_.size());
+ header->name = message_name;
+}
+
+MessageBuilder::~MessageBuilder() {
+}
+
+MessageData* MessageBuilder::Finish() {
+ return static_cast<MessageData*>(buf_.Leak());
+}
+
+} // namespace mojo
« no previous file with comments | « mojo/public/bindings/lib/message_builder.h ('k') | mojo/public/bindings/sample/generated/sample_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698