[M73 Dev][EFL] Disable VizDisplayCompositor for EFL port
[platform/framework/web/chromium-efl.git] / components / scheduling_metrics / total_duration_metric_reporter.h
1 // Copyright 2018 The Chromium Authors. All rights reserved.
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_SCHEDULING_METRICS_TOTAL_DURATION_METRIC_REPORTER_H_
6 #define COMPONENTS_SCHEDULING_METRICS_TOTAL_DURATION_METRIC_REPORTER_H_
7
8 #include "base/component_export.h"
9 #include "base/metrics/histogram.h"
10 #include "base/optional.h"
11 #include "base/time/time.h"
12
13 namespace scheduling_metrics {
14
15 // Helper class to measure the total duration of the event accounting for
16 // possibility of the renderer process going away at any point.
17 //
18 // This is implemented by "undoing" old total value and "applying" new one
19 // each time RecordAdditionalDuration() is called.
20 // "Undoing" is implemented by having a second "negative" histogram, so to
21 // obtain the result, |positive_histogram - negative_histogram| difference
22 // should be analysed.
23 class COMPONENT_EXPORT(SCHEDULING_METRICS) TotalDurationMetricReporter {
24  public:
25   TotalDurationMetricReporter(const char* positive_histogram_name,
26                               const char* negative_histogram_name);
27
28   void RecordAdditionalDuration(base::TimeDelta duration);
29
30   void Reset();
31
32  private:
33   base::Optional<base::TimeDelta> reported_value_;
34
35   base::HistogramBase* positive_histogram_;
36   base::HistogramBase* negative_histogram_;
37 };
38
39 }  // namespace scheduling_metrics
40
41 #endif  // COMPONENTS_SCHEDULING_METRICS_TOTAL_DURATION_METRIC_REPORTER_H_