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

Side by Side Diff: mojo/services/dbus_echo/dbus_echo_service.cc

Issue 275363002: Internalize ServiceConnector<> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add OnConnectionEstablished() Created 6 years, 7 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 "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/environment/environment.h" 15 #include "mojo/public/cpp/environment/environment.h"
16 #include "mojo/services/dbus_echo/echo.mojom.h" 16 #include "mojo/services/dbus_echo/echo.mojom.h"
17 17
18 namespace { 18 namespace {
19 class EchoServiceImpl 19 class EchoServiceImpl : public mojo::InterfaceImpl<mojo::EchoService> {
20 : public mojo::ServiceConnection<mojo::EchoService, EchoServiceImpl> {
21 public: 20 public:
22 EchoServiceImpl() {} 21 EchoServiceImpl() {}
23 virtual ~EchoServiceImpl() {} 22 virtual ~EchoServiceImpl() {}
24 23
24 virtual void OnConnectionError() OVERRIDE {}
25
25 protected: 26 protected:
26 virtual void Echo( 27 virtual void Echo(
27 const mojo::String& in_to_echo, 28 const mojo::String& in_to_echo,
28 const mojo::Callback<void(mojo::String)>& callback) OVERRIDE { 29 const mojo::Callback<void(mojo::String)>& callback) OVERRIDE {
29 DVLOG(1) << "Asked to echo " << in_to_echo.To<std::string>(); 30 DVLOG(1) << "Asked to echo " << in_to_echo.To<std::string>();
30 callback.Run(in_to_echo); 31 callback.Run(in_to_echo);
31 } 32 }
33
darin (slow to review) 2014/05/15 18:06:20 nit: spurious new line
32 }; 34 };
33 35
34 const char kServiceName[] = "org.chromium.EchoService"; 36 const char kServiceName[] = "org.chromium.EchoService";
35 } // anonymous namespace 37 } // anonymous namespace
36 38
37 int main(int argc, char** argv) { 39 int main(int argc, char** argv) {
38 base::AtExitManager exit_manager; 40 base::AtExitManager exit_manager;
39 CommandLine::Init(argc, argv); 41 CommandLine::Init(argc, argv);
40 42
41 logging::LoggingSettings settings; 43 logging::LoggingSettings settings;
42 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 44 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
43 logging::InitLogging(settings); 45 logging::InitLogging(settings);
44 logging::SetLogItems(false, // Process ID 46 logging::SetLogItems(false, // Process ID
45 false, // Thread ID 47 false, // Thread ID
46 false, // Timestamp 48 false, // Timestamp
47 false); // Tick count 49 false); // Tick count
48 50
49 mojo::Environment env; 51 mojo::Environment env;
50 mojo::embedder::Init(); 52 mojo::embedder::Init();
51 53
52 base::MessageLoopForIO message_loop; 54 base::MessageLoopForIO message_loop;
53 base::RunLoop run_loop; 55 base::RunLoop run_loop;
54 56
55 mojo::DBusExternalService<EchoServiceImpl> echo_service(kServiceName); 57 mojo::DBusExternalService<EchoServiceImpl> echo_service(kServiceName);
56 echo_service.Start(); 58 echo_service.Start();
57 59
58 run_loop.Run(); 60 run_loop.Run();
59 return 0; 61 return 0;
60 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698