blob: 38869fd2ae17e3ad36f4fd1ba4c7705d2509fb9b [file] [log] [blame]
Peter Qiu326b6cf2015-09-02 11:11:42 -07001//
2// Copyright (C) 2014 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Peter Qiu5dd242d2014-10-14 12:23:21 -070016
17#ifndef APMANAGER_DAEMON_H_
18#define APMANAGER_DAEMON_H_
19
Alex Vakulenkob56e3cd2015-04-24 18:09:32 -070020#include <base/callback_forward.h>
Alex Vakulenko8d0c31b2015-10-13 09:14:24 -070021#include <brillo/daemons/dbus_daemon.h>
Peter Qiu5dd242d2014-10-14 12:23:21 -070022
Peter Qiube128822015-10-13 13:55:03 -070023#include "apmanager/control_interface.h"
Peter Qiu5dd242d2014-10-14 12:23:21 -070024#include "apmanager/manager.h"
25
26namespace apmanager {
27
Alex Vakulenko8d0c31b2015-10-13 09:14:24 -070028class Daemon : public brillo::DBusServiceDaemon {
Peter Qiu5dd242d2014-10-14 12:23:21 -070029 public:
30 // User and group to run the apmanager process.
31 static const char kAPManagerGroupName[];
32 static const char kAPManagerUserName[];
33
34 explicit Daemon(const base::Closure& startup_callback);
35 ~Daemon() = default;
36
37 protected:
38 int OnInit() override;
39 void OnShutdown(int* return_code) override;
Peter Qiu376e4042014-11-13 09:40:28 -080040 void RegisterDBusObjectsAsync(
Alex Vakulenko8d0c31b2015-10-13 09:14:24 -070041 brillo::dbus_utils::AsyncEventSequencer* sequencer) override;
Peter Qiu5dd242d2014-10-14 12:23:21 -070042
43 private:
44 friend class DaemonTest;
45
Peter Qiube128822015-10-13 13:55:03 -070046 std::unique_ptr<ControlInterface> control_interface_;
Peter Qiu5dd242d2014-10-14 12:23:21 -070047 std::unique_ptr<Manager> manager_;
48 base::Closure startup_callback_;
49
50 DISALLOW_COPY_AND_ASSIGN(Daemon);
51};
52
53} // namespace apmanager
54
55#endif // APMANAGER_DAEMON_H_