blob: 648aa27e419106ea76416505a158637c3c9d2500 [file] [log] [blame]
Daniel Erat5bcc9b12010-12-16 16:53:331// Copyright (c) 2010 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 LOGIN_MANAGER_UPSTART_SIGNAL_EMITTER_H_
6#define LOGIN_MANAGER_UPSTART_SIGNAL_EMITTER_H_
7
Ben Chanf57c19c2016-12-08 01:14:498#include <memory>
Daniel Erat5bcc9b12010-12-16 16:53:339#include <string>
Chris Masone2e65e012014-01-03 21:15:5410#include <vector>
Daniel Erat5bcc9b12010-12-16 16:53:3311
Ben Chan857458a2014-09-03 23:44:4212#include <base/macros.h>
Chris Masoneb2e94192014-02-19 22:14:1513
Sabin Floares6208a332016-04-12 13:21:2014#include "login_manager/init_daemon_controller.h"
15
Chris Masoneb2e94192014-02-19 22:14:1516namespace dbus {
17class ObjectProxy;
Chris Masoneb2e94192014-02-19 22:14:1518}
Daniel Erat5bcc9b12010-12-16 16:53:3319
20namespace login_manager {
Hidehiko Abe5a5f8632017-06-14 08:06:5221
Daniel Erat5bcc9b12010-12-16 16:53:3322// Simple mockable class for emitting Upstart signals.
Sabin Floares6208a332016-04-12 13:21:2023class UpstartSignalEmitter : public InitDaemonController {
Daniel Erat5bcc9b12010-12-16 16:53:3324 public:
Chris Masoneb2e94192014-02-19 22:14:1525 static const char kServiceName[];
26 static const char kPath[];
Chris Masoneb2e94192014-02-19 22:14:1527
28 explicit UpstartSignalEmitter(dbus::ObjectProxy* proxy);
Qijiang Fan6bc59e12020-11-10 17:51:0629 UpstartSignalEmitter(const UpstartSignalEmitter&) = delete;
30 UpstartSignalEmitter& operator=(const UpstartSignalEmitter&) = delete;
31
Hidehiko Abe5a5f8632017-06-14 08:06:5232 ~UpstartSignalEmitter() override;
Daniel Erat5bcc9b12010-12-16 16:53:3333
Daniel Erat2e22a9b2016-12-06 17:54:4634 // InitDaemonController:
Daniel Erat2e22a9b2016-12-06 17:54:4635
Chris Masone2e65e012014-01-03 21:15:5436 // Emits an upstart signal. |args_keyvals| will be provided as
37 // environment variables to any upstart jobs kicked off as a result
38 // of the signal. Each element of |args_keyvals| is a string of the format
39 // "key=value".
Daniel Erat5bcc9b12010-12-16 16:53:3340 //
Daniel Eratcc827122016-12-06 18:29:4041 // Returns null if emitting the signal fails or if |mode| is ASYNC.
Hidehiko Abe5a5f8632017-06-14 08:06:5242 std::unique_ptr<dbus::Response> TriggerImpulse(
43 const std::string& name,
Daniel Eratcc827122016-12-06 18:29:4044 const std::vector<std::string>& args_keyvals,
Hidehiko Abe5a5f8632017-06-14 08:06:5245 TriggerMode mode) override;
Chris Masoneb2e94192014-02-19 22:14:1546
Hidehiko Abe5a5f8632017-06-14 08:06:5247 private:
Chris Masoneb2e94192014-02-19 22:14:1548 dbus::ObjectProxy* upstart_dbus_proxy_; // Weak, owned by caller.
Daniel Erat5bcc9b12010-12-16 16:53:3349};
50
51} // namespace login_manager
52
53#endif // LOGIN_MANAGER_UPSTART_SIGNAL_EMITTER_H_