summaryrefslogtreecommitdiffstats
path: root/chromium/mojo/examples/dbus_echo/dbus_echo_app.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/mojo/examples/dbus_echo/dbus_echo_app.cc')
-rw-r--r--chromium/mojo/examples/dbus_echo/dbus_echo_app.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/chromium/mojo/examples/dbus_echo/dbus_echo_app.cc b/chromium/mojo/examples/dbus_echo/dbus_echo_app.cc
new file mode 100644
index 00000000000..5a9b80f0c15
--- /dev/null
+++ b/chromium/mojo/examples/dbus_echo/dbus_echo_app.cc
@@ -0,0 +1,51 @@
+// Copyright 2014 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 <stdio.h>
+#include <string>
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "mojo/public/cpp/application/application.h"
+#include "mojo/public/cpp/environment/environment.h"
+#include "mojo/public/cpp/system/core.h"
+#include "mojo/public/cpp/system/macros.h"
+#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
+#include "mojo/services/dbus_echo/echo.mojom.h"
+
+namespace mojo {
+namespace examples {
+
+class DBusEchoApp : public Application {
+ public:
+ DBusEchoApp() {}
+ virtual ~DBusEchoApp() {}
+
+ virtual void Initialize() MOJO_OVERRIDE {
+ ConnectTo("dbus:org.chromium.EchoService/org/chromium/MojoImpl",
+ &echo_service_);
+
+ echo_service_->Echo(
+ String::From("who"),
+ base::Bind(&DBusEchoApp::OnEcho, base::Unretained(this)));
+ }
+
+ private:
+ void OnEcho(String echoed) {
+ LOG(INFO) << "echo'd " << echoed;
+ }
+
+ EchoServicePtr echo_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(DBusEchoApp);
+};
+
+} // namespace examples
+
+// static
+Application* Application::Create() {
+ return new examples::DBusEchoApp();
+}
+
+} // namespace mojo