Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9940a132 authored by Bertrand Simonnet's avatar Bertrand Simonnet Committed by Gerrit Code Review
Browse files

Merge "metricsd: add SendBoolToUMA to metrics interface"

parents f00db9d8 adc1c235
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ class MetricsLibraryInterface {
  virtual bool SendToUMA(const std::string& name, int sample,
                         int min, int max, int nbuckets) = 0;
  virtual bool SendEnumToUMA(const std::string& name, int sample, int max) = 0;
  virtual bool SendBoolToUMA(const std::string& name, bool sample) = 0;
  virtual bool SendSparseToUMA(const std::string& name, int sample) = 0;
  virtual bool SendUserActionToUMA(const std::string& action) = 0;
  virtual ~MetricsLibraryInterface() {}
@@ -96,6 +97,9 @@ class MetricsLibrary : public MetricsLibraryInterface {
  // normal, while 100 is high).
  bool SendEnumToUMA(const std::string& name, int sample, int max) override;

  // Specialization of SendEnumToUMA for boolean values.
  bool SendBoolToUMA(const std::string& name, bool sample) override;

  // Sends sparse histogram sample to Chrome for transport to UMA.  Returns
  // true on success.
  //
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class MetricsLibraryMock : public MetricsLibraryInterface {
                               int min, int max, int nbuckets));
  MOCK_METHOD3(SendEnumToUMA, bool(const std::string& name, int sample,
                                   int max));
  MOCK_METHOD2(SendBoolToUMA, bool(const std::string& name, bool sample));
  MOCK_METHOD2(SendSparseToUMA, bool(const std::string& name, int sample));
  MOCK_METHOD1(SendUserActionToUMA, bool(const std::string& action));

+7 −0
Original line number Diff line number Diff line
@@ -173,6 +173,13 @@ bool MetricsLibrary::SendEnumToUMA(const std::string& name, int sample,
      uma_events_file_.value());
}

bool MetricsLibrary::SendBoolToUMA(const std::string& name, bool sample) {
  return metrics::SerializationUtils::WriteMetricToFile(
      *metrics::MetricSample::LinearHistogramSample(name,
                                                    sample ? 1 : 0, 2).get(),
      uma_events_file_.value());
}

bool MetricsLibrary::SendSparseToUMA(const std::string& name, int sample) {
  return metrics::SerializationUtils::WriteMetricToFile(
      *metrics::MetricSample::SparseHistogramSample(name, sample).get(),