blob: 00988eafa8d0007d7c8f366c89be2a9450db2b00 [file] [log] [blame]
Josh Hilkebe691d752023-01-09 18:50:571// Copyright 2023 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_REPORTING_METRICS_MANUAL_COLLECTOR_H_
6#define COMPONENTS_REPORTING_METRICS_MANUAL_COLLECTOR_H_
7
8#include <memory>
9#include <string>
10
11#include "components/reporting/metrics/collector_base.h"
12#include "components/reporting/proto/synced/metric_data.pb.h"
13
14namespace reporting {
15
16class MetricReportQueue;
17class MetricReportingController;
18class ReportingSettings;
Vignesh Shenvi51b90be2023-12-01 01:15:5219
Josh Hilkebe691d752023-01-09 18:50:5720// Class to collect and report metric data when manually triggered. Does not
21// automatically collect data. Necessary reporting settings must be set or
22// `setting_enabled_default_value` must be set to True in order to trigger
23// collection.
24class ManualCollector : public CollectorBase {
25 public:
Vignesh Shenvi51b90be2023-12-01 01:15:5226 // Metrics name for reporting missing metric data to UMA.
27 static constexpr char kNoMetricDataMetricsName[] =
28 "Browser.ERP.MetricsReporting.ManualCollectorNoMetricData";
29
Josh Hilkebe691d752023-01-09 18:50:5730 ManualCollector(Sampler* sampler,
31 MetricReportQueue* metric_report_queue,
32 ReportingSettings* reporting_settings,
33 const std::string& setting_path,
34 bool setting_enabled_default_value);
35
36 ManualCollector(const ManualCollector& other) = delete;
37 ManualCollector& operator=(const ManualCollector& other) = delete;
38 ~ManualCollector() override;
39
40 protected:
41 // CollectorBase:
42 bool CanCollect() const override;
43 // CollectorBase:
44 void OnMetricDataCollected(bool is_event_driven,
Arthur Sonzognic571efb2024-01-26 20:26:1845 std::optional<MetricData> metric_data) override;
Josh Hilkebe691d752023-01-09 18:50:5746
47 private:
48 const raw_ptr<MetricReportQueue> metric_report_queue_;
49 const std::unique_ptr<MetricReportingController> reporting_controller_;
50};
51} // namespace reporting
52
shaochenguang61f8f1d82023-11-29 23:57:1753#endif // COMPONENTS_REPORTING_METRICS_MANUAL_COLLECTOR_H_