Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / mojo / examples / dbus_echo / dbus_echo_app.cc
blob7a76f71b101176a85c1ddf9f7cd04145fea8b6e5
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <stdio.h>
6 #include <string>
8 #include "base/bind.h"
9 #include "base/logging.h"
10 #include "mojo/examples/echo/echo_service.mojom.h"
11 #include "mojo/public/c/system/main.h"
12 #include "mojo/public/cpp/application/application_delegate.h"
13 #include "mojo/public/cpp/application/application_impl.h"
14 #include "mojo/public/cpp/application/application_runner.h"
15 #include "mojo/public/cpp/environment/environment.h"
16 #include "mojo/public/cpp/system/core.h"
17 #include "mojo/public/cpp/system/macros.h"
19 namespace mojo {
20 namespace examples {
22 class DBusEchoApp : public ApplicationDelegate {
23 public:
24 DBusEchoApp() {}
25 virtual ~DBusEchoApp() {}
27 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE {
28 app->ConnectToService(
29 "dbus:org.chromium.EchoService/org/chromium/MojoImpl", &echo_service_);
31 echo_service_->EchoString(
32 String::From("who"),
33 base::Bind(&DBusEchoApp::OnEcho, base::Unretained(this)));
36 private:
37 void OnEcho(String echoed) {
38 LOG(INFO) << "echo'd " << echoed;
41 EchoServicePtr echo_service_;
43 DISALLOW_COPY_AND_ASSIGN(DBusEchoApp);
46 } // namespace examples
47 } // namespace mojo
49 MojoResult MojoMain(MojoHandle shell_handle) {
50 mojo::ApplicationRunner runner(new mojo::examples::DBusEchoApp);
51 return runner.Run(shell_handle);