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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
cc / metrics / average_lag_tracking_manager.h [blame]
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_METRICS_AVERAGE_LAG_TRACKING_MANAGER_H_
#define CC_METRICS_AVERAGE_LAG_TRACKING_MANAGER_H_
#include <utility>
#include <vector>
#include "base/containers/circular_deque.h"
#include "cc/cc_export.h"
#include "cc/metrics/average_lag_tracker.h"
#include "cc/metrics/event_metrics.h"
namespace viz {
struct FrameTimingDetails;
} // namespace viz
namespace cc {
// A helper to decouple the `EventMetrics` and the `AverageLagTracker`.
class CC_EXPORT AverageLagTrackingManager {
public:
AverageLagTrackingManager();
~AverageLagTrackingManager();
// Disallow copy and assign.
AverageLagTrackingManager(const AverageLagTrackingManager&) = delete;
AverageLagTrackingManager& operator=(AverageLagTrackingManager const&) =
delete;
// Adds all the eligible events in the collection |infos| to the |frame_token|
// wait list.
void CollectScrollEventsFromFrame(uint32_t frame_token,
const EventMetricsSet& events_metrics);
// Sends all pending events in the |frame_token| list to the
// AverageLagTracker, given its |frame_details|.
void DidPresentCompositorFrame(uint32_t frame_token,
const viz::FrameTimingDetails& frame_details);
// Clears the list of events |frame_token_to_info_| if the current frames wont
// receive a presentation feedback (e.g. LayerTreeFrameSink loses context)
void Clear();
private:
// Tracker for the AverageLagPresentation metrics that uses the presentation
// feedback time as an approximation for the time the users sees the frame on
// the screen.
AverageLagTracker lag_tracker_;
// List of events (vector) per frame (uint32_t |frame_token|) to submit to the
// lag trackers when DidPresentCompositorFrame is called for a |frame_token|.
base::circular_deque<
std::pair<uint32_t, std::vector<AverageLagTracker::EventInfo>>>
frame_token_to_info_;
};
} // namespace cc
#endif // CC_METRICS_AVERAGE_LAG_TRACKING_MANAGER_H_