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> |
Alex Vakulenko | 8d0c31b | 2015-10-13 09:14:24 -0700 | [diff] [blame] | 21 | #include <brillo/daemons/dbus_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 | #include "apmanager/manager.h" |
| 25 | |
| 26 | namespace apmanager { |
| 27 | |
Alex Vakulenko | 8d0c31b | 2015-10-13 09:14:24 -0700 | [diff] [blame] | 28 | class Daemon : public brillo::DBusServiceDaemon { |
Peter Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 29 | 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 Qiu | 376e404 | 2014-11-13 09:40:28 -0800 | [diff] [blame] | 40 | void RegisterDBusObjectsAsync( |
Alex Vakulenko | 8d0c31b | 2015-10-13 09:14:24 -0700 | [diff] [blame] | 41 | brillo::dbus_utils::AsyncEventSequencer* sequencer) override; |
Peter Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 42 | |
| 43 | private: |
| 44 | friend class DaemonTest; |
| 45 | |
Peter Qiu | be12882 | 2015-10-13 13:55:03 -0700 | [diff] [blame] | 46 | std::unique_ptr<ControlInterface> control_interface_; |
Peter Qiu | 5dd242d | 2014-10-14 12:23:21 -0700 | [diff] [blame] | 47 | 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_ |