Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 1 | // Copyright 2014 The Chromium OS 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 <string> |
| 6 | |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 7 | #include <base/command_line.h> |
Alex Vakulenko | a8b95bc | 2014-08-27 11:00:57 -0700 | [diff] [blame] | 8 | #include <chromeos/dbus/async_event_sequencer.h> |
| 9 | #include <chromeos/dbus/exported_object_manager.h> |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 10 | #include <chromeos/daemons/dbus_daemon.h> |
| 11 | #include <chromeos/syslog_logging.h> |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 12 | |
Alex Vakulenko | 89d9d5e | 2014-09-12 10:27:23 -0700 | [diff] [blame] | 13 | #include "buffet/libbuffet/dbus_constants.h" |
Christopher Wiley | a4915c4 | 2014-03-27 14:45:37 -0700 | [diff] [blame] | 14 | #include "buffet/manager.h" |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 15 | |
Christopher Wiley | 2d2d92b | 2014-07-29 14:07:10 -0700 | [diff] [blame] | 16 | using chromeos::dbus_utils::AsyncEventSequencer; |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 17 | using chromeos::DBusServiceDaemon; |
| 18 | using buffet::dbus_constants::kServiceName; |
| 19 | using buffet::dbus_constants::kRootServicePath; |
Christopher Wiley | 9001624 | 2014-04-01 17:33:29 -0700 | [diff] [blame] | 20 | |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 21 | namespace buffet { |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 22 | |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 23 | class Daemon : public DBusServiceDaemon { |
| 24 | public: |
| 25 | Daemon() : DBusServiceDaemon(kServiceName, kRootServicePath) {} |
Chris Sosa | ababc5c | 2014-04-09 15:42:01 -0700 | [diff] [blame] | 26 | |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 27 | protected: |
| 28 | void RegisterDBusObjectsAsync(AsyncEventSequencer* sequencer) override { |
| 29 | manager_.reset(new buffet::Manager(object_manager_->AsWeakPtr())); |
| 30 | manager_->RegisterAsync( |
| 31 | sequencer->GetHandler("Manager.RegisterAsync() failed.", true)); |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 32 | } |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 33 | |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 34 | private: |
| 35 | std::unique_ptr<buffet::Manager> manager_; |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 36 | |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 37 | DISALLOW_COPY_AND_ASSIGN(Daemon); |
| 38 | }; |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 39 | |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 40 | } // namespace buffet |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 41 | |
| 42 | int main(int argc, char* argv[]) { |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 43 | CommandLine::Init(argc, argv); |
Alex Vakulenko | 74bd01b | 2014-09-08 17:07:19 -0700 | [diff] [blame] | 44 | chromeos::InitLog(chromeos::kLogToSyslog | chromeos::kLogHeader); |
| 45 | buffet::Daemon daemon; |
| 46 | return daemon.Run(); |
Chris Sosa | 45d9f10 | 2014-03-24 11:18:54 -0700 | [diff] [blame] | 47 | } |