-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdlc.h
99 lines (75 loc) · 3.22 KB
/
dlc.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This class is an abstraction for a Chrome OS Downloadable Content (DLC).
//
// A DLC module is a dynamically installed Chrome OS package that is verified
// via verity on device. DLC provides a way to install packages on demand
// instead of bundling all (used/unused) packages into root file system.
//
// This class verfies and mounts a DLC module image. A DLC module can be
// installed via API provided by dlc_service.
#ifndef IMAGELOADER_DLC_H_
#define IMAGELOADER_DLC_H_
#include <memory>
#include <string>
#include <base/files/file_path.h>
#include <base/gtest_prod_util.h>
#include <dlcservice/metadata/metadata_interface.h>
#include "imageloader/helper_process_proxy.h"
namespace imageloader {
using dlcservice::metadata::MetadataInterface;
// Enum on the two images (A/B) for one DLC module.
// We keep two copies (A/B) for each DLC module in order to sync with platform
// AutoUpdate (A/B update).
enum class AOrB { kDlcA, kDlcB, kUnknown };
class Dlc {
public:
explicit Dlc(const std::string& id,
const std::string& package,
const base::FilePath& mount_base,
std::shared_ptr<MetadataInterface> metadata);
Dlc(const Dlc&) = delete;
Dlc& operator=(const Dlc&) = delete;
// Mount the image.
bool Mount(HelperProcessProxy* proxy, const std::string& a_or_b);
// Mount the image at path.
bool Mount(HelperProcessProxy* proxy, const base::FilePath& path);
// Returns the directory where the DLC will be mounted. look at |mount_base_|.
base::FilePath GetMountPoint();
// Static version of the above function.
static base::FilePath GetMountPoint(const base::FilePath& mount_base,
const std::string& id,
const std::string& package);
private:
FRIEND_TEST_ALL_PREFIXES(DlcTest, MountDlc);
// Mount the image from |image_path| to |mount_point| using imageloader.json
// at |manifest_path| and table at |table_path|
bool Mount(HelperProcessProxy* proxy,
const base::FilePath& image_path,
const base::FilePath& manifest_path,
const base::FilePath& table_path,
const base::FilePath& mount_point);
bool MountInternal(HelperProcessProxy* proxy,
const base::FilePath& image_path,
const base::FilePath& mount_point,
const Manifest& manifest,
const std::string& table);
// Get the path to the DLC manifest (imageloader.json)
base::FilePath GetManifestPath();
// Get the path to the table file.
base::FilePath GetTablePath();
// Get the path to the DLC image itself.
base::FilePath GetImagePath(const AOrB a_or_b);
// ID of the DLC module image.
std::string id_;
// Package ID of the DLC module image.
std::string package_;
// The base directory where we need to mount the image. The DLC image will be
// mounted at |mount_base|/|id_|/|package_|/a_or_b.
base::FilePath mount_base_;
// The DLC metadata.
std::shared_ptr<MetadataInterface> metadata_;
};
} // namespace imageloader
#endif // IMAGELOADER_DLC_H_