blob: 8867df6fe6379c5619d70afab2ea77a9095be975 (
plain)
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
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_MAC_SERVICE_MANAGEMENT_H_
#define CHROME_COMMON_MAC_SERVICE_MANAGEMENT_H_
#include <string>
#include <vector>
#include "base/optional.h"
namespace mac {
namespace services {
struct JobInfo {
JobInfo();
JobInfo(const JobInfo& other);
~JobInfo();
std::string program;
base::Optional<int> pid;
};
struct JobCheckinInfo {
JobCheckinInfo();
JobCheckinInfo(const JobCheckinInfo& info);
~JobCheckinInfo();
std::string program;
};
struct JobOptions {
JobOptions();
JobOptions(const JobOptions& other);
~JobOptions();
std::string label;
// See launchd.plist(5) for details about these two fields. In short:
// - executable_path, if non-empty, is the absolute path to the executable
// for this job;
// - arguments[0] is the absolute *or relative* path to the executable if
// executable_path is empty; in either case, all of arguments is passed
// directly as argv to the job, meaning arguments[0] becomes argv[0]
// There are important caveats about the argument vector documented in the
// launchd.plist(5) man page.
std::string executable_path;
std::vector<std::string> arguments;
// See launchd.plist(5) "MachServices" for details about this field. The
// mach_service_ field corresponds to a key in the MachServices dictionary,
// whose value will be YES.
std::string mach_service_name;
// Whether to run this job immediately once it is loaded.
bool run_at_load;
// Whether to restart the job whenever it exits successfully. This also
// implicitly limits the job to interactive sessions only (i.e., the job will
// not run in system sessions).
bool auto_launch;
};
bool GetJobInfo(const std::string& label, JobInfo* info);
bool SubmitJob(const JobOptions& options);
bool RemoveJob(const std::string& label);
} // namespace services
} // namespace mac
#endif // CHROME_COMMON_MAC_SERVICE_MANAGEMENT_H_
|