blob: 535b3e77ea380ca56a0af6494a8a865bdbd49763 [file] [log] [blame]
Gilad Arnoldae47a9a2014-03-26 12:16:47 -07001// Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Gilad Arnold48415f12014-06-27 07:10:58 -07005#ifndef UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_
6#define UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_
Gilad Arnoldae47a9a2014-03-26 12:16:47 -07007
8#include <string>
9
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070010#include <base/time/time.h>
11
Alex Deymo63784a52014-05-28 10:46:14 -070012#include "update_engine/update_manager/provider.h"
13#include "update_engine/update_manager/variable.h"
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070014
Alex Deymo63784a52014-05-28 10:46:14 -070015namespace chromeos_update_manager {
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070016
17enum class Stage {
18 kIdle,
19 kCheckingForUpdate,
20 kUpdateAvailable,
21 kDownloading,
22 kVerifying,
23 kFinalizing,
24 kUpdatedNeedReboot,
25 kReportingErrorEvent,
26 kAttemptingRollback,
27};
28
Gilad Arnoldec7f9162014-07-15 13:24:46 -070029enum class UpdateRequestStatus {
30 kNone,
31 kInteractive,
32 kPeriodic,
33};
34
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070035// Provider for Chrome OS update related information.
36class UpdaterProvider : public Provider {
37 public:
David Zeuthen21716e22014-04-23 15:42:05 -070038 virtual ~UpdaterProvider() {}
39
Alex Deymoc7ab6162014-04-25 18:32:50 -070040 // A variable returning the timestamp when the update engine was started in
41 // wallclock time.
42 virtual Variable<base::Time>* var_updater_started_time() = 0;
43
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070044 // A variable returning the last update check time.
45 virtual Variable<base::Time>* var_last_checked_time() = 0;
46
47 // A variable reporting the time when an update was last completed in the
48 // current boot cycle. Returns an error if an update completed time could not
49 // be read (e.g. no update was completed in the current boot cycle) or is
50 // invalid.
51 //
52 // IMPORTANT: The time reported is not the wallclock time reading at the time
53 // of the update, rather it is the point in time when the update completed
54 // relative to the current wallclock time reading. Therefore, the gap between
55 // the reported value and the current wallclock time is guaranteed to be
56 // monotonically increasing.
57 virtual Variable<base::Time>* var_update_completed_time() = 0;
58
59 // A variable returning the update progress (0.0 to 1.0).
60 virtual Variable<double>* var_progress() = 0;
61
62 // A variable returning the current update status.
63 virtual Variable<Stage>* var_stage() = 0;
64
65 // A variable returning the update target version.
66 virtual Variable<std::string>* var_new_version() = 0;
67
Alex Deymof967ebe2014-05-05 14:46:17 -070068 // A variable returning the update payload size. The payload size is
69 // guaranteed to be non-negative.
70 virtual Variable<int64_t>* var_payload_size() = 0;
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070071
72 // A variable returning the current channel.
73 virtual Variable<std::string>* var_curr_channel() = 0;
74
75 // A variable returning the update target channel.
76 virtual Variable<std::string>* var_new_channel() = 0;
77
Gilad Arnold0adbc942014-05-12 10:35:43 -070078 // A variable indicating whether user settings allow P2P updates.
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070079 virtual Variable<bool>* var_p2p_enabled() = 0;
80
Gilad Arnold0adbc942014-05-12 10:35:43 -070081 // A variable indicating whether user settings allow updates over a cellular
82 // network.
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070083 virtual Variable<bool>* var_cellular_enabled() = 0;
David Zeuthen21716e22014-04-23 15:42:05 -070084
Gilad Arnolda6dab942014-04-25 11:46:03 -070085 // A variable returning the number of consecutive failed update checks.
86 virtual Variable<unsigned int>* var_consecutive_failed_update_checks() = 0;
87
Gilad Arnolda0258a52014-07-10 16:21:19 -070088 // A server-dictated update check interval in seconds, if one was given.
89 virtual Variable<unsigned int>* var_server_dictated_poll_interval() = 0;
90
Gilad Arnoldec7f9162014-07-15 13:24:46 -070091 // A variable denoting whether a forced update was request but no update check
92 // performed yet; also tells whether this request is for an interactive or
93 // scheduled update.
94 virtual Variable<UpdateRequestStatus>* var_forced_update_requested() = 0;
Gilad Arnold44dc3bf2014-07-18 23:39:38 -070095
David Zeuthen21716e22014-04-23 15:42:05 -070096 protected:
97 UpdaterProvider() {}
98
99 private:
100 DISALLOW_COPY_AND_ASSIGN(UpdaterProvider);
Gilad Arnoldae47a9a2014-03-26 12:16:47 -0700101};
102
Alex Deymo63784a52014-05-28 10:46:14 -0700103} // namespace chromeos_update_manager
Gilad Arnoldae47a9a2014-03-26 12:16:47 -0700104
Gilad Arnold48415f12014-06-27 07:10:58 -0700105#endif // UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_