| 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 |  | 
| Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_CROS_DAEMON_CHROMEOS_H_ | 
|  | 18 | #define UPDATE_ENGINE_CROS_DAEMON_CHROMEOS_H_ | 
| Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 19 |  | 
|  | 20 | #include <memory> | 
| Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 21 |  | 
| Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 22 | #include "update_engine/common/daemon_base.h" | 
|  | 23 | #include "update_engine/common/daemon_state_interface.h" | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 24 | #include "update_engine/common/subprocess.h" | 
| Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 25 | #include "update_engine/cros/dbus_service.h" | 
| Amin Hassani | ddd6822 | 2020-11-30 16:45:59 -0800 | [diff] [blame] | 26 | #include "update_engine/cros/real_system_state.h" | 
| Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 27 |  | 
|  | 28 | namespace chromeos_update_engine { | 
|  | 29 |  | 
| Amin Hassani | 565331e | 2019-06-24 14:11:29 -0700 | [diff] [blame] | 30 | class DaemonChromeOS : public DaemonBase { | 
| Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 31 | public: | 
| Amin Hassani | 565331e | 2019-06-24 14:11:29 -0700 | [diff] [blame] | 32 | DaemonChromeOS() = default; | 
| Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 33 |  | 
|  | 34 | protected: | 
|  | 35 | int OnInit() override; | 
|  | 36 |  | 
|  | 37 | private: | 
|  | 38 | // Run from the main loop when the |dbus_adaptor_| object is registered. At | 
|  | 39 | // this point we can request ownership of the DBus service name and continue | 
|  | 40 | // initialization. | 
|  | 41 | void OnDBusRegistered(bool succeeded); | 
|  | 42 |  | 
| Amin Hassani | ddd6822 | 2020-11-30 16:45:59 -0800 | [diff] [blame] | 43 | // |SystemState| is a global context, but we can't have a static singleton of | 
|  | 44 | // its object because the style guide does not allow that (it has non-trivial | 
|  | 45 | // dtor). We need an instance of |SystemState| in this class instead and have | 
|  | 46 | // a global pointer to it. This is better to be defined as the first variable | 
|  | 47 | // of this class so it is initialized first and destructed last. | 
|  | 48 | RealSystemState system_state_; | 
|  | 49 |  | 
| Sen Jiang | 299128e | 2016-06-03 17:48:18 -0700 | [diff] [blame] | 50 | // Main D-Bus service adaptor. | 
| Alex Deymo | a91cc48 | 2016-01-20 16:51:56 -0800 | [diff] [blame] | 51 | std::unique_ptr<UpdateEngineAdaptor> dbus_adaptor_; | 
|  | 52 |  | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 53 | // The Subprocess singleton class requires a brillo::MessageLoop in the | 
| Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 54 | // current thread, so we need to initialize it from this class instead of | 
|  | 55 | // the main() function. | 
|  | 56 | Subprocess subprocess_; | 
|  | 57 |  | 
| Amin Hassani | 565331e | 2019-06-24 14:11:29 -0700 | [diff] [blame] | 58 | DISALLOW_COPY_AND_ASSIGN(DaemonChromeOS); | 
| Alex Deymo | b7ca096 | 2014-10-01 17:58:07 -0700 | [diff] [blame] | 59 | }; | 
|  | 60 |  | 
|  | 61 | }  // namespace chromeos_update_engine | 
|  | 62 |  | 
| Amin Hassani | ec7bc11 | 2020-10-29 16:47:58 -0700 | [diff] [blame] | 63 | #endif  // UPDATE_ENGINE_CROS_DAEMON_CHROMEOS_H_ |