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

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

Issue 304593002: Revert 272983 "Change Shell / ShellClient to ServiceProvider" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
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"
11 #include "mojo/public/cpp/bindings/allocation_scope.h" 10 #include "mojo/public/cpp/bindings/allocation_scope.h"
12 #include "mojo/public/cpp/environment/environment.h" 11 #include "mojo/public/cpp/environment/environment.h"
12 #include "mojo/public/cpp/shell/application.h"
13 #include "mojo/public/cpp/system/core.h" 13 #include "mojo/public/cpp/system/core.h"
14 #include "mojo/public/cpp/system/macros.h" 14 #include "mojo/public/cpp/system/macros.h"
15 #include "mojo/public/cpp/utility/run_loop.h" 15 #include "mojo/public/cpp/utility/run_loop.h"
16 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 16 #include "mojo/public/interfaces/shell/shell.mojom.h"
17 #include "mojo/services/dbus_echo/echo.mojom.h" 17 #include "mojo/services/dbus_echo/echo.mojom.h"
18 18
19 #if defined(WIN32) 19 #if defined(WIN32)
20 #if !defined(CDECL) 20 #if !defined(CDECL)
21 #define CDECL __cdecl 21 #define CDECL __cdecl
22 #endif 22 #endif
23 #define DBUS_ECHO_APP_EXPORT __declspec(dllexport) 23 #define DBUS_ECHO_APP_EXPORT __declspec(dllexport)
24 #else 24 #else
25 #define CDECL 25 #define CDECL
26 #define DBUS_ECHO_APP_EXPORT __attribute__((visibility("default"))) 26 #define DBUS_ECHO_APP_EXPORT __attribute__((visibility("default")))
27 #endif 27 #endif
28 28
29 namespace mojo { 29 namespace mojo {
30 namespace examples { 30 namespace examples {
31 31
32 class DBusEchoApp : public Application { 32 class DBusEchoApp : public Application {
33 public: 33 public:
34 explicit DBusEchoApp(MojoHandle service_provider_handle) 34 explicit DBusEchoApp(MojoHandle shell_handle) : Application(shell_handle) {
35 : Application(service_provider_handle) {
36 ConnectTo("dbus:org.chromium.EchoService/org/chromium/MojoImpl", 35 ConnectTo("dbus:org.chromium.EchoService/org/chromium/MojoImpl",
37 &echo_service_); 36 &echo_service_);
38 37
39 AllocationScope scope; 38 AllocationScope scope;
40 echo_service_->Echo("who", base::Bind(&DBusEchoApp::OnEcho, 39 echo_service_->Echo("who", base::Bind(&DBusEchoApp::OnEcho,
41 base::Unretained(this))); 40 base::Unretained(this)));
42 } 41 }
43 42
44 virtual ~DBusEchoApp() { 43 virtual ~DBusEchoApp() {
45 } 44 }
46 45
47 private: 46 private:
48 void OnEcho(const String& echoed) { 47 void OnEcho(const String& echoed) {
49 LOG(INFO) << "echo'd " << echoed.To<std::string>(); 48 LOG(INFO) << "echo'd " << echoed.To<std::string>();
50 } 49 }
51 50
52 EchoServicePtr echo_service_; 51 EchoServicePtr echo_service_;
53 }; 52 };
54 53
55 } // namespace examples 54 } // namespace examples
56 } // namespace mojo 55 } // namespace mojo
57 56
58 extern "C" DBUS_ECHO_APP_EXPORT MojoResult CDECL MojoMain( 57 extern "C" DBUS_ECHO_APP_EXPORT MojoResult CDECL MojoMain(
59 MojoHandle service_provider_handle) { 58 MojoHandle shell_handle) {
60 mojo::Environment env; 59 mojo::Environment env;
61 mojo::RunLoop loop; 60 mojo::RunLoop loop;
62 61
63 mojo::examples::DBusEchoApp app(service_provider_handle); 62 mojo::examples::DBusEchoApp app(shell_handle);
64 loop.Run(); 63 loop.Run();
65 return MOJO_RESULT_OK; 64 return MOJO_RESULT_OK;
66 } 65 }
OLDNEW
« no previous file with comments | « trunk/src/mojo/examples/compositor_app/compositor_app.cc ('k') | trunk/src/mojo/examples/launcher/launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698