Revert of Revert of Revert of Introduce SessionManager that will contain code to...
[chromium-blink-merge.git] / mojo / services / dbus_echo / dbus_echo_service.cc
blob560daa6b9de9a7d3c5852e05d11a904a3b57b18a
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 "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/common/channel_init.h"
13 #include "mojo/dbus/dbus_external_service.h"
14 #include "mojo/embedder/embedder.h"
15 #include "mojo/public/cpp/environment/environment.h"
16 #include "mojo/services/dbus_echo/echo.mojom.h"
18 namespace {
19 class EchoServiceImpl : public mojo::InterfaceImpl<mojo::EchoService> {
20 public:
21 EchoServiceImpl() {}
22 virtual ~EchoServiceImpl() {}
24 protected:
25 virtual void Echo(
26 const mojo::String& in_to_echo,
27 const mojo::Callback<void(mojo::String)>& callback) OVERRIDE {
28 DVLOG(1) << "Asked to echo " << in_to_echo;
29 callback.Run(in_to_echo);
33 const char kServiceName[] = "org.chromium.EchoService";
34 } // anonymous namespace
36 int main(int argc, char** argv) {
37 base::AtExitManager exit_manager;
38 base::CommandLine::Init(argc, argv);
40 logging::LoggingSettings settings;
41 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
42 logging::InitLogging(settings);
43 logging::SetLogItems(false, // Process ID
44 false, // Thread ID
45 false, // Timestamp
46 false); // Tick count
48 mojo::Environment env;
49 mojo::embedder::Init();
51 base::MessageLoopForIO message_loop;
52 base::RunLoop run_loop;
54 mojo::DBusExternalService<EchoServiceImpl> echo_service(kServiceName);
55 echo_service.Start();
57 run_loop.Run();
58 return 0;