1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40

ash / webui / diagnostics_ui / diagnostics_metrics.h [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_WEBUI_DIAGNOSTICS_UI_DIAGNOSTICS_METRICS_H_
#define ASH_WEBUI_DIAGNOSTICS_UI_DIAGNOSTICS_METRICS_H_

#include "chromeos/ash/components/feature_usage/feature_usage_metrics.h"

namespace ash {
namespace diagnostics {
namespace metrics {
class DiagnosticsMetrics final
    : public feature_usage::FeatureUsageMetrics::Delegate {
 public:
  DiagnosticsMetrics();
  DiagnosticsMetrics(DiagnosticsMetrics&) = delete;
  DiagnosticsMetrics& operator=(DiagnosticsMetrics&) = delete;
  ~DiagnosticsMetrics() override = default;

  // feature_usage::FeatureUsageMetrics::Delegate:
  bool IsEligible() const override;
  bool IsEnabled() const override;

  // feature_usage::FeatureUsageMetrics helpers:
  void RecordUsage(bool success);
  void StopSuccessfulUsage();

  // Test helpers:
  bool GetSuccessfulUsageStartedForTesting();

 private:
  feature_usage::FeatureUsageMetrics feature_metrics_;
  bool successful_usage_started_;
};
}  // namespace metrics
}  // namespace diagnostics
}  // namespace ash

#endif  // ASH_WEBUI_DIAGNOSTICS_UI_DIAGNOSTICS_METRICS_H_