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

Unified Diff: mojo/public/bindings/generated/sample_service_proxy.cc

Issue 23913008: C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
Index: mojo/public/bindings/generated/sample_service_proxy.cc
diff --git a/mojo/public/bindings/generated/sample_service_proxy.cc b/mojo/public/bindings/generated/sample_service_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d059e25944e5a83eb829ca1d77ac655874e3996e
--- /dev/null
+++ b/mojo/public/bindings/generated/sample_service_proxy.cc
@@ -0,0 +1,52 @@
+// 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/generated/sample_service_proxy.h"
+
+#include "mojo/public/bindings/generated/sample_service_internal.h"
+
+namespace sample {
+
+ServiceProxy::ServiceProxy(mojo::MessageSender* sender)
+ : sender_(sender) {
+}
+
+void ServiceProxy::Frobinate(const Foo* foo, bool baz, mojo::Handle port) {
+ mojo::MessageBuffer buf;
+
+ // TODO: We should allocate the MessageHeader here to reserve space.
+
+ // We now go about allocating the anonymous Frobinate_Params struct. It
+ // holds the parameters to the Frobinate message.
+ //
+ // Notice how foo is cloned. This causes a copy of foo to be generated
+ // within the same buffer as the Frobinate_Params struct. That's what we
+ // need in order to generate a continguous blob of message data.
+
+ internal::Service_Frobinate_Params* params =
viettrungluu 2013/10/02 01:17:06 I wonder if in the case that params is small (and
+ buf.New<internal::Service_Frobinate_Params>();
+ params->set_foo(mojo::internal::Clone(foo, &buf));
+ params->set_baz(baz);
+ params->set_port(port);
+
+ // NOTE: If foo happened to be a graph with cycles, then Clone would not
+ // have returned.
+
+ // Last step before sending the message is to encode pointers and handles
+ // so that messages become hermetic. Pointers become offsets and handles
+ // becomes indices into the handles array.
+
+ std::vector<mojo::Handle> handles;
+ mojo::internal::EncodePointersAndHandles(params, &handles);
+
+ mojo::Message message;
+ message.name = internal::kService_Frobinate_Name;
+ message.data_start = buf.data();
viettrungluu 2013/10/02 01:17:06 ... which makes me think that MessageBuffer should
+ message.data_end = buf.data() + buf.size();
+ message.handles.swap(handles);
+
+ sender_->Send(message);
+}
+
+} // namespace sample
« no previous file with comments | « mojo/public/bindings/generated/sample_service_proxy.h ('k') | mojo/public/bindings/generated/sample_service_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698