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

Side by Side Diff: mojo/examples/dbus_echo/dbus_echo_app.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/examples/compositor_app/compositor_host.cc ('k') | mojo/examples/launcher/launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/public/cpp/application/application.h" 10 #include "mojo/public/cpp/application/application.h"
11 #include "mojo/public/cpp/bindings/allocation_scope.h"
12 #include "mojo/public/cpp/environment/environment.h" 11 #include "mojo/public/cpp/environment/environment.h"
13 #include "mojo/public/cpp/system/core.h" 12 #include "mojo/public/cpp/system/core.h"
14 #include "mojo/public/cpp/system/macros.h" 13 #include "mojo/public/cpp/system/macros.h"
15 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 14 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
16 #include "mojo/services/dbus_echo/echo.mojom.h" 15 #include "mojo/services/dbus_echo/echo.mojom.h"
17 16
18 namespace mojo { 17 namespace mojo {
19 namespace examples { 18 namespace examples {
20 19
21 class DBusEchoApp : public Application { 20 class DBusEchoApp : public Application {
22 public: 21 public:
23 DBusEchoApp() {} 22 DBusEchoApp() {}
24 virtual ~DBusEchoApp() {} 23 virtual ~DBusEchoApp() {}
25 24
26 virtual void Initialize() MOJO_OVERRIDE { 25 virtual void Initialize() MOJO_OVERRIDE {
27 ConnectTo("dbus:org.chromium.EchoService/org/chromium/MojoImpl", 26 ConnectTo("dbus:org.chromium.EchoService/org/chromium/MojoImpl",
28 &echo_service_); 27 &echo_service_);
29 28
30 AllocationScope scope; 29 echo_service_->Echo(
31 echo_service_->Echo("who", base::Bind(&DBusEchoApp::OnEcho, 30 String::From("who"),
32 base::Unretained(this))); 31 base::Bind(&DBusEchoApp::OnEcho, base::Unretained(this)));
33 } 32 }
34 33
35 private: 34 private:
36 void OnEcho(const String& echoed) { 35 void OnEcho(String echoed) {
37 LOG(INFO) << "echo'd " << echoed.To<std::string>(); 36 LOG(INFO) << "echo'd " << echoed;
38 } 37 }
39 38
40 EchoServicePtr echo_service_; 39 EchoServicePtr echo_service_;
41 40
42 DISALLOW_COPY_AND_ASSIGN(DBusEchoApp); 41 DISALLOW_COPY_AND_ASSIGN(DBusEchoApp);
43 }; 42 };
44 43
45 } // namespace examples 44 } // namespace examples
46 45
47 // static 46 // static
48 Application* Application::Create() { 47 Application* Application::Create() {
49 return new examples::DBusEchoApp(); 48 return new examples::DBusEchoApp();
50 } 49 }
51 50
52 } // namespace mojo 51 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/compositor_app/compositor_host.cc ('k') | mojo/examples/launcher/launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698