[M108 Migration][VD] Avoid pending frame counter becoming negative
[platform/framework/web/chromium-efl.git] / cc / metrics / latency_ukm_reporter.h
1 // Copyright 2019 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 CC_METRICS_LATENCY_UKM_REPORTER_H_
6 #define CC_METRICS_LATENCY_UKM_REPORTER_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/memory/raw_ptr.h"
12 #include "cc/cc_export.h"
13 #include "cc/metrics/compositor_frame_reporter.h"
14 #include "cc/metrics/event_metrics.h"
15
16 namespace cc {
17 class UkmManager;
18
19 // A helper class that takes latency data from a CompositorFrameReporter and
20 // talks to UkmManager to report it.
21 class CC_EXPORT LatencyUkmReporter {
22  public:
23   LatencyUkmReporter();
24   ~LatencyUkmReporter();
25
26   LatencyUkmReporter(const LatencyUkmReporter&) = delete;
27   LatencyUkmReporter& operator=(const LatencyUkmReporter&) = delete;
28
29   void ReportCompositorLatencyUkm(
30       const CompositorFrameReporter::FrameReportTypes& report_types,
31       const std::vector<CompositorFrameReporter::StageData>& stage_history,
32       const ActiveTrackers& active_trackers,
33       const CompositorFrameReporter::ProcessedBlinkBreakdown&
34           processed_blink_breakdown,
35       const CompositorFrameReporter::ProcessedVizBreakdown&
36           processed_viz_breakdown);
37
38   void ReportEventLatencyUkm(
39       const EventMetrics::List& events_metrics,
40       const std::vector<CompositorFrameReporter::StageData>& stage_history,
41       const CompositorFrameReporter::ProcessedBlinkBreakdown&
42           processed_blink_breakdown,
43       const CompositorFrameReporter::ProcessedVizBreakdown&
44           processed_viz_breakdown);
45
46   void set_ukm_manager(UkmManager* manager) { ukm_manager_ = manager; }
47
48  private:
49   class SamplingController;
50
51   // This is pointing to the LayerTreeHostImpl::ukm_manager_, which is
52   // initialized right after the LayerTreeHostImpl is created. So when this
53   // pointer is initialized, there should be no trackers yet. Moreover, the
54   // LayerTreeHostImpl::ukm_manager_ lives as long as the LayerTreeHostImpl, so
55   // this pointer should never be null as long as LayerTreeHostImpl is alive.
56   raw_ptr<UkmManager> ukm_manager_ = nullptr;
57
58   std::unique_ptr<SamplingController> compositor_latency_sampling_controller_;
59   std::unique_ptr<SamplingController> event_latency_sampling_controller_;
60 };
61
62 }  // namespace cc
63
64 #endif  // CC_METRICS_LATENCY_UKM_REPORTER_H_