Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2015 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 | // |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef UPDATE_ENGINE_DAEMON_H_ |
| 18 | #define UPDATE_ENGINE_DAEMON_H_ |
| 19 | |
| 20 | #include <memory> |
| 21 | #include <string> |
| 22 | |
Alex Vakulenko | e119e6a | 2016-01-06 17:13:11 -0800 | [diff] [blame^] | 23 | #if USE_WEAVE |
| 24 | #include <brillo/binder_watcher.h> |
| 25 | #endif // USE_WEAVE |
Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 26 | #include <brillo/daemons/dbus_daemon.h> |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 27 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 28 | #include "update_engine/common/subprocess.h" |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 29 | #include "update_engine/dbus_service.h" |
| 30 | #include "update_engine/real_system_state.h" |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 31 | |
| 32 | namespace chromeos_update_engine { |
| 33 | |
Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 34 | class UpdateEngineDaemon : public brillo::DBusDaemon { |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 35 | public: |
| 36 | UpdateEngineDaemon() = default; |
Alex Deymo | 2b4268c | 2015-12-04 13:56:25 -0800 | [diff] [blame] | 37 | ~UpdateEngineDaemon(); |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 38 | |
| 39 | protected: |
| 40 | int OnInit() override; |
| 41 | |
| 42 | private: |
| 43 | // Run from the main loop when the |dbus_adaptor_| object is registered. At |
| 44 | // this point we can request ownership of the DBus service name and continue |
| 45 | // initialization. |
| 46 | void OnDBusRegistered(bool succeeded); |
| 47 | |
Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 48 | // The Subprocess singleton class requires a brillo::MessageLoop in the |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 49 | // current thread, so we need to initialize it from this class instead of |
| 50 | // the main() function. |
| 51 | Subprocess subprocess_; |
| 52 | |
Alex Vakulenko | e119e6a | 2016-01-06 17:13:11 -0800 | [diff] [blame^] | 53 | #if USE_WEAVE |
| 54 | brillo::BinderWatcher binder_watcher_; |
| 55 | #endif // USE_WEAVE |
| 56 | |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 57 | std::unique_ptr<UpdateEngineAdaptor> dbus_adaptor_; |
| 58 | |
Alex Deymo | 2b4268c | 2015-12-04 13:56:25 -0800 | [diff] [blame] | 59 | // The RealSystemState uses the previous classes so it should be defined last. |
| 60 | std::unique_ptr<RealSystemState> real_system_state_; |
| 61 | |
Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 62 | DISALLOW_COPY_AND_ASSIGN(UpdateEngineDaemon); |
| 63 | }; |
| 64 | |
| 65 | } // namespace chromeos_update_engine |
| 66 | |
| 67 | #endif // UPDATE_ENGINE_DAEMON_H_ |