summaryrefslogtreecommitdiffstats
path: root/mojo/examples/dbus_echo
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-29 19:00:36 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-29 19:00:36 +0000
commit2b4e10f4dcd668a1e0ba3b800672e1ba4e6909de (patch)
treed17edf8877cdb821d779b71fe34cdf3a31bc98e9 /mojo/examples/dbus_echo
parent27ac8181e1fc50ef07518148b113028f39d41faa (diff)
downloadchromium_src-2b4e10f4dcd668a1e0ba3b800672e1ba4e6909de.zip
chromium_src-2b4e10f4dcd668a1e0ba3b800672e1ba4e6909de.tar.gz
chromium_src-2b4e10f4dcd668a1e0ba3b800672e1ba4e6909de.tar.bz2
Mojo: more idiomatic C++ bindings
This change eliminates AllocationScope in favor of heap allocating the "wrapper" classes, which are now no longer wrappers in the true sense but rather deep copies of the archived structs. We still use the term "wrapper" in the code generator. With this design, the fact that structs are encoded as pointers (that may be null) is more apparent. For example, a Foo struct may be allocated and stored in a FooPtr. The FooPtr implements move-only semantics. This is because some of the members of Foo may be move-only (e.g., handles). Strings are now just thin wrappers around std::string that impose nullability and a more restrictive API. It is not possible to mutate the elements of a string after it has been created. String acts like a pointer to a possibly null array of characters, which is very similar to a char*. Arrays are now just thin wrappers around std::vector that impose nullability and a more restrictive API. Unlike String, Array does support mutation of its elements after creation, but there is no support for resizing an array. (We can add support for push_back and resize if needed.) BUG=365922 R=yzshen@chromium.org Review URL: https://codereview.chromium.org/294833002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273527 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/examples/dbus_echo')
-rw-r--r--mojo/examples/dbus_echo/dbus_echo_app.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/mojo/examples/dbus_echo/dbus_echo_app.cc b/mojo/examples/dbus_echo/dbus_echo_app.cc
index 0ccccc6..5a9b80f 100644
--- a/mojo/examples/dbus_echo/dbus_echo_app.cc
+++ b/mojo/examples/dbus_echo/dbus_echo_app.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/logging.h"
#include "mojo/public/cpp/application/application.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
#include "mojo/public/cpp/environment/environment.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/macros.h"
@@ -27,14 +26,14 @@ class DBusEchoApp : public Application {
ConnectTo("dbus:org.chromium.EchoService/org/chromium/MojoImpl",
&echo_service_);
- AllocationScope scope;
- echo_service_->Echo("who", base::Bind(&DBusEchoApp::OnEcho,
- base::Unretained(this)));
+ echo_service_->Echo(
+ String::From("who"),
+ base::Bind(&DBusEchoApp::OnEcho, base::Unretained(this)));
}
private:
- void OnEcho(const String& echoed) {
- LOG(INFO) << "echo'd " << echoed.To<std::string>();
+ void OnEcho(String echoed) {
+ LOG(INFO) << "echo'd " << echoed;
}
EchoServicePtr echo_service_;