blob: e974a262514158e3e775e684ba184d10e9771b5f [file] [log] [blame]
Tianjie Xu282aa1f2017-09-05 13:42:45 -07001//
2// Copyright (C) 2017 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//
16
17#ifndef UPDATE_ENGINE_METRICS_REPORTER_OMAHA_H_
18#define UPDATE_ENGINE_METRICS_REPORTER_OMAHA_H_
19
20#include <base/time/time.h>
21#include <metrics/metrics_library.h>
22
23#include "update_engine/certificate_checker.h"
24#include "update_engine/common/constants.h"
25#include "update_engine/common/error_code.h"
26#include "update_engine/metrics_constants.h"
27#include "update_engine/metrics_reporter_interface.h"
28#include "update_engine/system_state.h"
29
30namespace chromeos_update_engine {
31
32class SystemState;
33
34class MetricsReporterOmaha : public MetricsReporterInterface {
35 public:
36 MetricsReporterOmaha() = default;
37
38 ~MetricsReporterOmaha() override = default;
39
40 void Initialize() override;
41
42 void ReportRollbackMetrics(metrics::RollbackResult result) override;
43
44 void ReportDailyMetrics(base::TimeDelta os_age) override;
45
46 void ReportUpdateCheckMetrics(
47 SystemState* system_state,
48 metrics::CheckResult result,
49 metrics::CheckReaction reaction,
50 metrics::DownloadErrorCode download_error_code) override;
51
52 void ReportUpdateAttemptMetrics(
53 SystemState* system_state,
54 int attempt_number,
55 PayloadType payload_type,
56 base::TimeDelta duration,
57 base::TimeDelta duration_uptime,
58 int64_t payload_size,
59 int64_t payload_bytes_downloaded,
60 int64_t payload_download_speed_bps,
61 DownloadSource download_source,
62 metrics::AttemptResult attempt_result,
63 ErrorCode internal_error_code,
64 metrics::DownloadErrorCode payload_download_error_code,
65 metrics::ConnectionType connection_type) override;
66
67 void ReportAbnormallyTerminatedUpdateAttemptMetrics() override;
68
69 void ReportSuccessfulUpdateMetrics(
70 int attempt_count,
71 int updates_abandoned_count,
72 PayloadType payload_type,
73 int64_t payload_size,
74 int64_t num_bytes_downloaded[kNumDownloadSources],
75 int download_overhead_percentage,
76 base::TimeDelta total_duration,
77 int reboot_count,
78 int url_switch_count) override;
79
80 void ReportCertificateCheckMetrics(ServerToCheck server_to_check,
81 CertificateCheckResult result) override;
82
83 void ReportFailedUpdateCount(int target_attempt) override;
84
85 void ReportTimeToReboot(int time_to_reboot_minutes) override;
86
87 void ReportInstallDateProvisioningSource(int source, int max) override;
88
89 private:
90 MetricsLibrary metrics_lib_;
91
92 DISALLOW_COPY_AND_ASSIGN(MetricsReporterOmaha);
93}; // class metrics
94
95} // namespace chromeos_update_engine
96
97#endif // UPDATE_ENGINE_METRICS_REPORTER_OMAHA_H_