blob: ab9d4b2ed6173adbff5fd89588c9a0209021b194 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
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 Deymob7ca0962014-10-01 17:58:07 -070016
Amin Hassaniec7bc112020-10-29 16:47:58 -070017#ifndef UPDATE_ENGINE_CROS_DAEMON_CHROMEOS_H_
18#define UPDATE_ENGINE_CROS_DAEMON_CHROMEOS_H_
Alex Deymob7ca0962014-10-01 17:58:07 -070019
20#include <memory>
Alex Deymob7ca0962014-10-01 17:58:07 -070021
Amin Hassaniec7bc112020-10-29 16:47:58 -070022#include "update_engine/common/daemon_base.h"
23#include "update_engine/common/daemon_state_interface.h"
Alex Deymo39910dc2015-11-09 17:04:30 -080024#include "update_engine/common/subprocess.h"
Amin Hassaniec7bc112020-10-29 16:47:58 -070025#include "update_engine/cros/dbus_service.h"
Alex Deymob7ca0962014-10-01 17:58:07 -070026
27namespace chromeos_update_engine {
28
Amin Hassani565331e2019-06-24 14:11:29 -070029class DaemonChromeOS : public DaemonBase {
Alex Deymob7ca0962014-10-01 17:58:07 -070030 public:
Amin Hassani565331e2019-06-24 14:11:29 -070031 DaemonChromeOS() = default;
Alex Deymob7ca0962014-10-01 17:58:07 -070032
33 protected:
34 int OnInit() override;
35
36 private:
37 // Run from the main loop when the |dbus_adaptor_| object is registered. At
38 // this point we can request ownership of the DBus service name and continue
39 // initialization.
40 void OnDBusRegistered(bool succeeded);
41
Sen Jiang299128e2016-06-03 17:48:18 -070042 // Main D-Bus service adaptor.
Alex Deymoa91cc482016-01-20 16:51:56 -080043 std::unique_ptr<UpdateEngineAdaptor> dbus_adaptor_;
44
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070045 // The Subprocess singleton class requires a brillo::MessageLoop in the
Alex Deymob7ca0962014-10-01 17:58:07 -070046 // current thread, so we need to initialize it from this class instead of
47 // the main() function.
48 Subprocess subprocess_;
49
Amin Hassani565331e2019-06-24 14:11:29 -070050 DISALLOW_COPY_AND_ASSIGN(DaemonChromeOS);
Alex Deymob7ca0962014-10-01 17:58:07 -070051};
52
53} // namespace chromeos_update_engine
54
Amin Hassaniec7bc112020-10-29 16:47:58 -070055#endif // UPDATE_ENGINE_CROS_DAEMON_CHROMEOS_H_