| // Copyright 2020 The Chromium OS Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "federated/daemon.h" |
| |
| #include <sysexits.h> |
| |
| #include <memory> |
| #include <utility> |
| |
| #include <base/bind.h> |
| #include <base/files/file_util.h> |
| #include <base/memory/ref_counted.h> |
| #include <chromeos/dbus/service_constants.h> |
| #include <dbus/bus.h> |
| #include <dbus/message.h> |
| #include <mojo/core/embedder/embedder.h> |
| #include <mojo/public/cpp/system/invitation.h> |
| |
| namespace federated { |
| |
| Daemon::Daemon() : weak_ptr_factory_(this) {} |
| |
| Daemon::~Daemon() = default; |
| |
| int Daemon::OnInit() { |
| int exit_code = DBusDaemon::OnInit(); |
| if (exit_code != EX_OK) |
| return exit_code; |
| |
| mojo::core::Init(); |
| ipc_support_ = std::make_unique<mojo::core::ScopedIPCSupport>( |
| base::ThreadTaskRunnerHandle::Get(), |
| mojo::core::ScopedIPCSupport::ShutdownPolicy::FAST); |
| InitDBus(); |
| |
| return 0; |
| } |
| |
| void Daemon::InitDBus() { |
| // TODO(alanlxl): Create kFederatedServicePath, kFederatedServiceInterfaceName |
| // and kFederatedServiceName in platform2/system_api/dbus/service_constants.h |
| } |
| |
| void Daemon::BootstrapMojoConnection( |
| dbus::MethodCall* method_call, |
| dbus::ExportedObject::ResponseSender response_sender) { |
| // TODO(alanlxl): export this as a dbus method. |
| } |
| |
| void Daemon::OnMojoDisconnection() { |
| // Die upon disconnection . Reconnection can occur when the daemon is |
| // restarted. |
| Quit(); |
| } |
| |
| } // namespace federated |