blob: 5aef8c5abc79e2ef7c0d6384a85440ee2672b8c6 [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
17#ifndef UPDATE_ENGINE_DAEMON_H_
18#define UPDATE_ENGINE_DAEMON_H_
19
20#include <memory>
21#include <string>
22
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070023#include <brillo/daemons/dbus_daemon.h>
Alex Deymob7ca0962014-10-01 17:58:07 -070024
Alex Deymo39910dc2015-11-09 17:04:30 -080025#include "update_engine/common/subprocess.h"
Alex Deymob7ca0962014-10-01 17:58:07 -070026#include "update_engine/dbus_service.h"
27#include "update_engine/real_system_state.h"
Alex Deymob7ca0962014-10-01 17:58:07 -070028
29namespace chromeos_update_engine {
30
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070031class UpdateEngineDaemon : public brillo::DBusDaemon {
Alex Deymob7ca0962014-10-01 17:58:07 -070032 public:
33 UpdateEngineDaemon() = default;
34
35 protected:
36 int OnInit() override;
37
38 private:
39 // Run from the main loop when the |dbus_adaptor_| object is registered. At
40 // this point we can request ownership of the DBus service name and continue
41 // initialization.
42 void OnDBusRegistered(bool succeeded);
43
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070044 // The Subprocess singleton class requires a brillo::MessageLoop in the
Alex Deymob7ca0962014-10-01 17:58:07 -070045 // current thread, so we need to initialize it from this class instead of
46 // the main() function.
47 Subprocess subprocess_;
48
49 std::unique_ptr<RealSystemState> real_system_state_;
Alex Deymob7ca0962014-10-01 17:58:07 -070050 std::unique_ptr<UpdateEngineAdaptor> dbus_adaptor_;
51
52 DISALLOW_COPY_AND_ASSIGN(UpdateEngineDaemon);
53};
54
55} // namespace chromeos_update_engine
56
57#endif // UPDATE_ENGINE_DAEMON_H_