blob: 37e9b8dab0efeb479c8b5d9c53f87458cce73c8e [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>
Peter Qiu0d70fa72015-11-12 10:31:40 -080021#include <brillo/daemons/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
25namespace apmanager {
26
Peter Qiu0d70fa72015-11-12 10:31:40 -080027class Daemon : public brillo::Daemon {
Peter Qiu5dd242d2014-10-14 12:23:21 -070028 public:
29 // User and group to run the apmanager process.
30 static const char kAPManagerGroupName[];
31 static const char kAPManagerUserName[];
32
33 explicit Daemon(const base::Closure& startup_callback);
34 ~Daemon() = default;
35
36 protected:
37 int OnInit() override;
38 void OnShutdown(int* return_code) override;
Peter Qiu5dd242d2014-10-14 12:23:21 -070039
40 private:
41 friend class DaemonTest;
42
Peter Qiube128822015-10-13 13:55:03 -070043 std::unique_ptr<ControlInterface> control_interface_;
Peter Qiu5dd242d2014-10-14 12:23:21 -070044 base::Closure startup_callback_;
45
46 DISALLOW_COPY_AND_ASSIGN(Daemon);
47};
48
49} // namespace apmanager
50
51#endif // APMANAGER_DAEMON_H_