update_engine: Make SystemState accessible from everywhere
SystemState is supposed to be a global context and is used lamost
everywhere. So instead of passing it to functions and keeping multiple
pointers to it, its better to do what we did in dlcservice and make it a
singleton class with a getter that can be get from everywhere.
BUG=b:171829801
TEST=unittests
Change-Id: I3b2de9394b7769b3911195ca52d61dbe49afd4dd
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2521792
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
diff --git a/cros/metrics_reporter_omaha.h b/cros/metrics_reporter_omaha.h
index 5b3fdb1..b6ffcce 100644
--- a/cros/metrics_reporter_omaha.h
+++ b/cros/metrics_reporter_omaha.h
@@ -29,7 +29,6 @@
#include "update_engine/common/error_code.h"
#include "update_engine/common/metrics_constants.h"
#include "update_engine/common/metrics_reporter_interface.h"
-#include "update_engine/common/system_state.h"
namespace chromeos_update_engine {
@@ -117,13 +116,11 @@
void ReportDailyMetrics(base::TimeDelta os_age) override;
void ReportUpdateCheckMetrics(
- SystemState* system_state,
metrics::CheckResult result,
metrics::CheckReaction reaction,
metrics::DownloadErrorCode download_error_code) override;
- void ReportUpdateAttemptMetrics(SystemState* system_state,
- int attempt_number,
+ void ReportUpdateAttemptMetrics(int attempt_number,
PayloadType payload_type,
base::TimeDelta duration,
base::TimeDelta duration_uptime,
@@ -181,8 +178,7 @@
// If the function returns |true|, the duration (always non-negative)
// is returned in |out_duration|. If the function returns |false|
// something went wrong or there was no previous measurement.
- bool WallclockDurationHelper(SystemState* system_state,
- const std::string& state_variable_key,
+ bool WallclockDurationHelper(const std::string& state_variable_key,
base::TimeDelta* out_duration);
// This function returns the duration on the monotonic clock since the
@@ -194,9 +190,7 @@
// If the function returns |true|, the duration (always non-negative)
// is returned in |out_duration|. If the function returns |false|
// something went wrong or there was no previous measurement.
- bool MonotonicDurationHelper(SystemState* system_state,
- int64_t* storage,
- base::TimeDelta* out_duration);
+ bool MonotonicDurationHelper(int64_t* storage, base::TimeDelta* out_duration);
std::unique_ptr<MetricsLibraryInterface> metrics_lib_;