blob: 216d3b96e657b065fbf41afd7cffe54b05b3476b [file] [log] [blame]
Enrico Granata60b1cbc2019-05-20 11:06:46 -07001// Copyright 2019 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#ifndef MEMS_SETUP_DELEGATE_H_
6#define MEMS_SETUP_DELEGATE_H_
7
8#include <unistd.h>
9
10#include <string>
11
12#include <base/files/file_path.h>
13#include <base/macros.h>
14#include <base/optional.h>
15
16namespace mems_setup {
17
18class Delegate {
19 public:
20 virtual ~Delegate() = default;
21
22 virtual base::Optional<std::string> ReadVpdValue(const std::string& key) = 0;
23 virtual bool ProbeKernelModule(const std::string& module) = 0;
24
25 virtual bool Exists(const base::FilePath&) = 0;
26
Enrico Granata10e19de2019-05-21 14:17:36 -070027 virtual base::Optional<gid_t> FindGroupId(const char* group) = 0;
28
29 virtual int GetPermissions(const base::FilePath& path) = 0;
30 virtual bool SetPermissions(const base::FilePath& path, int mode) = 0;
31
32 virtual bool SetOwnership(const base::FilePath& path,
33 uid_t user,
34 gid_t group) = 0;
35
Enrico Granata60b1cbc2019-05-20 11:06:46 -070036 protected:
37 Delegate() = default;
Qijiang Fan6bc59e12020-11-11 02:51:06 +090038 Delegate(const Delegate&) = delete;
39 Delegate& operator=(const Delegate&) = delete;
Enrico Granata60b1cbc2019-05-20 11:06:46 -070040};
41
42} // namespace mems_setup
43
44#endif // MEMS_SETUP_DELEGATE_H_