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.
5 #ifndef CC_METRICS_LATENCY_UKM_REPORTER_H_
6 #define CC_METRICS_LATENCY_UKM_REPORTER_H_
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"
19 // A helper class that takes latency data from a CompositorFrameReporter and
20 // talks to UkmManager to report it.
21 class CC_EXPORT LatencyUkmReporter {
24 ~LatencyUkmReporter();
26 LatencyUkmReporter(const LatencyUkmReporter&) = delete;
27 LatencyUkmReporter& operator=(const LatencyUkmReporter&) = delete;
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);
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);
46 void set_ukm_manager(UkmManager* manager) { ukm_manager_ = manager; }
49 class SamplingController;
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;
58 std::unique_ptr<SamplingController> compositor_latency_sampling_controller_;
59 std::unique_ptr<SamplingController> event_latency_sampling_controller_;
64 #endif // CC_METRICS_LATENCY_UKM_REPORTER_H_