blob: 66fff09b23b8ee3c589c3aad1bb23a09b66890a3 [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;
19// Class to collect and report metric data when manually triggered. Does not
20// automatically collect data. Necessary reporting settings must be set or
21// `setting_enabled_default_value` must be set to True in order to trigger
22// collection.
23class ManualCollector : public CollectorBase {
24 public:
25 ManualCollector(Sampler* sampler,
26 MetricReportQueue* metric_report_queue,
27 ReportingSettings* reporting_settings,
28 const std::string& setting_path,
29 bool setting_enabled_default_value);
30
31 ManualCollector(const ManualCollector& other) = delete;
32 ManualCollector& operator=(const ManualCollector& other) = delete;
33 ~ManualCollector() override;
34
35 protected:
36 // CollectorBase:
37 bool CanCollect() const override;
38 // CollectorBase:
39 void OnMetricDataCollected(bool is_event_driven,
40 absl::optional<MetricData> metric_data) override;
41
42 private:
43 const raw_ptr<MetricReportQueue> metric_report_queue_;
44 const std::unique_ptr<MetricReportingController> reporting_controller_;
45};
46} // namespace reporting
47
48#endif // COMPONENTS_REPORTING_METRICS_ONE_SHOT_COLLECTOR_H_