Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 1 | // 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 Arnold | 48415f1 | 2014-06-27 07:10:58 -0700 | [diff] [blame^] | 5 | #ifndef UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ |
| 6 | #define UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 10 | #include <base/time/time.h> |
| 11 | |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 12 | #include "update_engine/update_manager/provider.h" |
| 13 | #include "update_engine/update_manager/variable.h" |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 14 | |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 15 | namespace chromeos_update_manager { |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 16 | |
| 17 | enum class Stage { |
| 18 | kIdle, |
| 19 | kCheckingForUpdate, |
| 20 | kUpdateAvailable, |
| 21 | kDownloading, |
| 22 | kVerifying, |
| 23 | kFinalizing, |
| 24 | kUpdatedNeedReboot, |
| 25 | kReportingErrorEvent, |
| 26 | kAttemptingRollback, |
| 27 | }; |
| 28 | |
| 29 | // Provider for Chrome OS update related information. |
| 30 | class UpdaterProvider : public Provider { |
| 31 | public: |
David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 32 | virtual ~UpdaterProvider() {} |
| 33 | |
Alex Deymo | c7ab616 | 2014-04-25 18:32:50 -0700 | [diff] [blame] | 34 | // A variable returning the timestamp when the update engine was started in |
| 35 | // wallclock time. |
| 36 | virtual Variable<base::Time>* var_updater_started_time() = 0; |
| 37 | |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 38 | // A variable returning the last update check time. |
| 39 | virtual Variable<base::Time>* var_last_checked_time() = 0; |
| 40 | |
| 41 | // A variable reporting the time when an update was last completed in the |
| 42 | // current boot cycle. Returns an error if an update completed time could not |
| 43 | // be read (e.g. no update was completed in the current boot cycle) or is |
| 44 | // invalid. |
| 45 | // |
| 46 | // IMPORTANT: The time reported is not the wallclock time reading at the time |
| 47 | // of the update, rather it is the point in time when the update completed |
| 48 | // relative to the current wallclock time reading. Therefore, the gap between |
| 49 | // the reported value and the current wallclock time is guaranteed to be |
| 50 | // monotonically increasing. |
| 51 | virtual Variable<base::Time>* var_update_completed_time() = 0; |
| 52 | |
| 53 | // A variable returning the update progress (0.0 to 1.0). |
| 54 | virtual Variable<double>* var_progress() = 0; |
| 55 | |
| 56 | // A variable returning the current update status. |
| 57 | virtual Variable<Stage>* var_stage() = 0; |
| 58 | |
| 59 | // A variable returning the update target version. |
| 60 | virtual Variable<std::string>* var_new_version() = 0; |
| 61 | |
Alex Deymo | f967ebe | 2014-05-05 14:46:17 -0700 | [diff] [blame] | 62 | // A variable returning the update payload size. The payload size is |
| 63 | // guaranteed to be non-negative. |
| 64 | virtual Variable<int64_t>* var_payload_size() = 0; |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 65 | |
| 66 | // A variable returning the current channel. |
| 67 | virtual Variable<std::string>* var_curr_channel() = 0; |
| 68 | |
| 69 | // A variable returning the update target channel. |
| 70 | virtual Variable<std::string>* var_new_channel() = 0; |
| 71 | |
Gilad Arnold | 0adbc94 | 2014-05-12 10:35:43 -0700 | [diff] [blame] | 72 | // A variable indicating whether user settings allow P2P updates. |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 73 | virtual Variable<bool>* var_p2p_enabled() = 0; |
| 74 | |
Gilad Arnold | 0adbc94 | 2014-05-12 10:35:43 -0700 | [diff] [blame] | 75 | // A variable indicating whether user settings allow updates over a cellular |
| 76 | // network. |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 77 | virtual Variable<bool>* var_cellular_enabled() = 0; |
David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 78 | |
Gilad Arnold | a6dab94 | 2014-04-25 11:46:03 -0700 | [diff] [blame] | 79 | // A variable returning the number of consecutive failed update checks. |
| 80 | virtual Variable<unsigned int>* var_consecutive_failed_update_checks() = 0; |
| 81 | |
David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 82 | protected: |
| 83 | UpdaterProvider() {} |
| 84 | |
| 85 | private: |
| 86 | DISALLOW_COPY_AND_ASSIGN(UpdaterProvider); |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 89 | } // namespace chromeos_update_manager |
Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 90 | |
Gilad Arnold | 48415f1 | 2014-06-27 07:10:58 -0700 | [diff] [blame^] | 91 | #endif // UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ |