| OLD | NEW |
| 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "mojo/common/channel_init.h" | 12 #include "mojo/common/channel_init.h" |
| 13 #include "mojo/dbus/dbus_external_service.h" | 13 #include "mojo/dbus/dbus_external_service.h" |
| 14 #include "mojo/embedder/embedder.h" | 14 #include "mojo/embedder/embedder.h" |
| 15 #include "mojo/public/cpp/bindings/interface.h" | |
| 16 #include "mojo/public/cpp/environment/environment.h" | 15 #include "mojo/public/cpp/environment/environment.h" |
| 17 #include "mojo/services/dbus_echo/echo.mojom.h" | 16 #include "mojo/services/dbus_echo/echo.mojom.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 class EchoServiceImpl : public mojo::ServiceConnection<mojo::EchoService, | 19 class EchoServiceImpl |
| 21 EchoServiceImpl> { | 20 : public mojo::ServiceConnection<mojo::EchoService, EchoServiceImpl> { |
| 22 public: | 21 public: |
| 23 EchoServiceImpl() {} | 22 EchoServiceImpl() {} |
| 24 virtual ~EchoServiceImpl() {} | 23 virtual ~EchoServiceImpl() {} |
| 25 | 24 |
| 26 protected: | 25 protected: |
| 27 virtual void Echo( | 26 virtual void Echo( |
| 28 const mojo::String& in_to_echo, | 27 const mojo::String& in_to_echo, |
| 29 const mojo::Callback<void(mojo::String)>& callback) OVERRIDE { | 28 const mojo::Callback<void(mojo::String)>& callback) OVERRIDE { |
| 30 DVLOG(1) << "Asked to echo " << in_to_echo.To<std::string>(); | 29 DVLOG(1) << "Asked to echo " << in_to_echo.To<std::string>(); |
| 31 callback.Run(in_to_echo); | 30 callback.Run(in_to_echo); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 52 | 51 |
| 53 base::MessageLoopForIO message_loop; | 52 base::MessageLoopForIO message_loop; |
| 54 base::RunLoop run_loop; | 53 base::RunLoop run_loop; |
| 55 | 54 |
| 56 mojo::DBusExternalService<EchoServiceImpl> echo_service(kServiceName); | 55 mojo::DBusExternalService<EchoServiceImpl> echo_service(kServiceName); |
| 57 echo_service.Start(); | 56 echo_service.Start(); |
| 58 | 57 |
| 59 run_loop.Run(); | 58 run_loop.Run(); |
| 60 return 0; | 59 return 0; |
| 61 } | 60 } |
| OLD | NEW |