Andreea Costinas | 942284d | 2020-01-28 16:28:40 +0100 | [diff] [blame] | 1 | // Copyright 2020 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 "system-proxy/system_proxy_daemon.h" |
| 6 | |
| 7 | #include <utility> |
| 8 | |
| 9 | #include <brillo/dbus/dbus_object.h> |
| 10 | #include <dbus/system_proxy/dbus-constants.h> |
| 11 | |
| 12 | #include "system-proxy/system_proxy_adaptor.h" |
| 13 | |
| 14 | namespace system_proxy { |
| 15 | |
| 16 | namespace { |
| 17 | const char kObjectServicePath[] = "/org/chromium/SystemProxy/ObjectManager"; |
| 18 | } // namespace |
| 19 | |
| 20 | SystemProxyDaemon::SystemProxyDaemon() |
| 21 | : DBusServiceDaemon(kSystemProxyServiceName, kObjectServicePath) {} |
| 22 | SystemProxyDaemon::~SystemProxyDaemon() = default; |
| 23 | |
| 24 | void SystemProxyDaemon::RegisterDBusObjectsAsync( |
| 25 | brillo::dbus_utils::AsyncEventSequencer* sequencer) { |
| 26 | auto dbus_object = std::make_unique<brillo::dbus_utils::DBusObject>( |
| 27 | object_manager_.get(), object_manager_->GetBus(), |
| 28 | org::chromium::SystemProxyAdaptor::GetObjectPath()); |
| 29 | DCHECK(!adaptor_); |
| 30 | adaptor_ = std::make_unique<SystemProxyAdaptor>(std::move(dbus_object)); |
| 31 | adaptor_->RegisterAsync( |
| 32 | sequencer->GetHandler("RegisterAsync() failed", true)); |
| 33 | } |
| 34 | } // namespace system_proxy |