OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "base/at_exit.h" | |
6 #include "base/callback.h" | |
7 #include "base/command_line.h" | |
8 #include "base/logging.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/message_loop/message_loop.h" | |
11 #include "base/run_loop.h" | |
12 #include "mojo/dbus/dbus_external_service.h" | |
13 #include "mojo/embedder/channel_init.h" | |
14 #include "mojo/embedder/embedder.h" | |
15 #include "mojo/embedder/simple_platform_support.h" | |
16 #include "mojo/public/cpp/environment/environment.h" | |
17 #include "mojo/services/dbus_echo/echo.mojom.h" | |
18 | |
19 namespace { | |
20 class EchoServiceImpl : public mojo::InterfaceImpl<mojo::EchoService> { | |
21 public: | |
22 EchoServiceImpl() {} | |
23 virtual ~EchoServiceImpl() {} | |
24 | |
25 protected: | |
26 virtual void Echo( | |
27 const mojo::String& in_to_echo, | |
28 const mojo::Callback<void(mojo::String)>& callback) OVERRIDE { | |
29 DVLOG(1) << "Asked to echo " << in_to_echo; | |
30 callback.Run(in_to_echo); | |
31 } | |
32 }; | |
33 | |
34 const char kServiceName[] = "org.chromium.EchoService"; | |
35 } // anonymous namespace | |
36 | |
37 int main(int argc, char** argv) { | |
38 base::AtExitManager exit_manager; | |
39 base::CommandLine::Init(argc, argv); | |
40 | |
41 logging::LoggingSettings settings; | |
42 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | |
43 logging::InitLogging(settings); | |
44 logging::SetLogItems(false, // Process ID | |
45 false, // Thread ID | |
46 false, // Timestamp | |
47 false); // Tick count | |
48 | |
49 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( | |
50 new mojo::embedder::SimplePlatformSupport())); | |
51 | |
52 base::MessageLoopForIO message_loop; | |
53 base::RunLoop run_loop; | |
54 | |
55 mojo::DBusExternalService<EchoServiceImpl> echo_service(kServiceName); | |
56 echo_service.Start(); | |
57 | |
58 run_loop.Run(); | |
59 return 0; | |
60 } | |
OLD | NEW |