-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdaemon.cc
74 lines (58 loc) · 2.38 KB
/
daemon.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2018 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 "dlcservice/daemon.h"
#include <string>
#include <utility>
#include <chromeos/constants/imageloader.h>
#include <chromeos/dbus/dlcservice/dbus-constants.h>
#include <sysexits.h>
#include "dlcservice/boot/boot_device.h"
#include "dlcservice/boot/boot_slot.h"
#include "dlcservice/dlc_service.h"
#include "dlcservice/system_state.h"
namespace dlcservice {
namespace {
constexpr char kDlcPreloadedImageRootpath[] =
"/mnt/stateful_partition/var_overlay/cache/dlc-images";
} // namespace
// kDlcServiceServiceName is defined in
// chromeos/dbus/dlcservice/dbus-constants.h
Daemon::Daemon() : DBusServiceDaemon(kDlcServiceServiceName) {}
int Daemon::OnInit() {
int return_code = brillo::DBusServiceDaemon::OnInit();
if (return_code != EX_OK)
return return_code;
dlc_service_->LoadDlcModuleImages();
return EX_OK;
}
void Daemon::RegisterDBusObjectsAsync(
brillo::dbus_utils::AsyncEventSequencer* sequencer) {
dbus_object_ = std::make_unique<brillo::dbus_utils::DBusObject>(
nullptr, bus_,
org::chromium::DlcServiceInterfaceAdaptor::GetObjectPath());
bus_for_proxies_ = dbus_connection_for_proxies_.Connect();
CHECK(bus_for_proxies_);
// |SystemState| must be:
// - Initialized after |bus_for_proxies_|.
// - Initialized before |DlcService|.
SystemState::Initialize(
std::make_unique<org::chromium::ImageLoaderInterfaceProxy>(
bus_for_proxies_),
std::make_unique<org::chromium::UpdateEngineInterfaceProxy>(
bus_for_proxies_),
std::make_unique<BootSlot>(std::make_unique<BootDevice>()),
base::FilePath(imageloader::kDlcManifestRootpath),
base::FilePath(kDlcPreloadedImageRootpath),
base::FilePath(imageloader::kDlcImageRootpath),
base::FilePath(imageloader::kDlcMetadataRootpath));
CHECK(SystemState::Get());
dlc_service_ = std::make_unique<DlcService>();
auto dbus_service = std::make_unique<DBusService>(dlc_service_.get());
dbus_adaptor_ = std::make_unique<DBusAdaptor>(std::move(dbus_service));
dlc_service_->AddObserver(dbus_adaptor_.get());
dbus_adaptor_->RegisterWithDBusObject(dbus_object_.get());
dbus_object_->RegisterAsync(
sequencer->GetHandler("RegisterAsync() failed.", true));
}
} // namespace dlcservice