Peter Qiu | 326b6cf | 2015-09-02 11:11:42 -0700 | [diff] [blame] | 1 | // |
| 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 Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef APMANAGER_DAEMON_H_ |
| 18 | #define APMANAGER_DAEMON_H_ |
| 19 | |
Alex Vakulenko | b56e3cd | 2015-04-24 18:09:32 -0700 | [diff] [blame] | 20 | #include <base/callback_forward.h> |
Peter Qiu | 0d70fa7 | 2015-11-12 10:31:40 -0800 | [diff] [blame] | 21 | #include <brillo/daemons/daemon.h> |
Peter Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 22 | |
Peter Qiu | be12882 | 2015-10-13 13:55:03 -0700 | [diff] [blame] | 23 | #include "apmanager/control_interface.h" |
Peter Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 24 | |
| 25 | namespace apmanager { |
| 26 | |
Peter Qiu | 0d70fa7 | 2015-11-12 10:31:40 -0800 | [diff] [blame] | 27 | class Daemon : public brillo::Daemon { |
Peter Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 28 | 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 Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | friend class DaemonTest; |
| 42 | |
Peter Qiu | be12882 | 2015-10-13 13:55:03 -0700 | [diff] [blame] | 43 | std::unique_ptr<ControlInterface> control_interface_; |
Peter Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 44 | base::Closure startup_callback_; |
| 45 | |
| 46 | DISALLOW_COPY_AND_ASSIGN(Daemon); |
| 47 | }; |
| 48 | |
| 49 | } // namespace apmanager |
| 50 | |
| 51 | #endif // APMANAGER_DAEMON_H_ |