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/common/metrics_reporter_interface.h b/common/metrics_reporter_interface.h
index d7c5347..08636e3 100644
--- a/common/metrics_reporter_interface.h
+++ b/common/metrics_reporter_interface.h
@@ -25,19 +25,12 @@
#include "update_engine/common/constants.h"
#include "update_engine/common/error_code.h"
#include "update_engine/common/metrics_constants.h"
-#include "update_engine/common/system_state.h"
namespace chromeos_update_engine {
enum class ServerToCheck;
enum class CertificateCheckResult;
-namespace metrics {
-
-std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter();
-
-} // namespace metrics
-
class MetricsReporterInterface {
public:
virtual ~MetricsReporterInterface() = default;
@@ -92,7 +85,6 @@
// if it's set, |kMetricCheckRollbackTargetVersion| reports the same, but only
// if rollback is also allowed using enterprise policy.
virtual void ReportUpdateCheckMetrics(
- SystemState* system_state,
metrics::CheckResult result,
metrics::CheckReaction reaction,
metrics::DownloadErrorCode download_error_code) = 0;
@@ -120,8 +112,7 @@
// |kMetricAttemptTimeSinceLastAttemptUptimeMinutes| metrics are
// automatically calculated and reported by maintaining persistent and
// process-local state variables.
- virtual void ReportUpdateAttemptMetrics(SystemState* system_state,
- int attempt_number,
+ virtual void ReportUpdateAttemptMetrics(int attempt_number,
PayloadType payload_type,
base::TimeDelta duration,
base::TimeDelta duration_uptime,
@@ -242,6 +233,12 @@
bool has_time_restriction_policy, int time_to_update_days) = 0;
};
+namespace metrics {
+
+std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter();
+
+} // namespace metrics
+
} // namespace chromeos_update_engine
#endif // UPDATE_ENGINE_COMMON_METRICS_REPORTER_INTERFACE_H_