blob: f7f03b91810f6b01e0b0da4d329021b217e6ba8b (
plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/metrics/event_metrics.h"
#include <tuple>
#include "base/stl_util.h"
namespace cc {
EventMetrics::EventMetrics(ui::EventType type,
base::TimeTicks time_stamp,
base::Optional<ScrollInputType> scroll_input_type)
: type_(type),
time_stamp_(time_stamp),
scroll_input_type_(scroll_input_type) {}
EventMetrics::EventMetrics(const EventMetrics&) = default;
EventMetrics& EventMetrics::operator=(const EventMetrics&) = default;
bool EventMetrics::IsWhitelisted() const {
switch (type_) {
case ui::ET_MOUSE_PRESSED:
case ui::ET_MOUSE_RELEASED:
case ui::ET_MOUSEWHEEL:
case ui::ET_KEY_PRESSED:
case ui::ET_KEY_RELEASED:
case ui::ET_TOUCH_PRESSED:
case ui::ET_TOUCH_RELEASED:
case ui::ET_TOUCH_MOVED:
case ui::ET_GESTURE_SCROLL_BEGIN:
case ui::ET_GESTURE_SCROLL_UPDATE:
case ui::ET_GESTURE_SCROLL_END:
return true;
default:
return false;
}
}
const char* EventMetrics::GetTypeName() const {
DCHECK(IsWhitelisted()) << "Event type is not whitelisted for event metrics: "
<< type_;
switch (type_) {
case ui::ET_MOUSE_PRESSED:
return "MousePressed";
case ui::ET_MOUSE_RELEASED:
return "MouseReleased";
case ui::ET_MOUSEWHEEL:
return "MouseWheel";
case ui::ET_KEY_PRESSED:
return "KeyPressed";
case ui::ET_KEY_RELEASED:
return "KeyReleased";
case ui::ET_TOUCH_PRESSED:
return "TouchPressed";
case ui::ET_TOUCH_RELEASED:
return "TouchReleased";
case ui::ET_TOUCH_MOVED:
return "TouchMoved";
case ui::ET_GESTURE_SCROLL_BEGIN:
return "GestureScrollBegin";
case ui::ET_GESTURE_SCROLL_UPDATE:
return "GestureScrollUpdate";
case ui::ET_GESTURE_SCROLL_END:
return "GestureScrollEnd";
default:
NOTREACHED();
return nullptr;
}
}
const char* EventMetrics::GetScrollTypeName() const {
DCHECK(IsWhitelisted()) << "Event type is not whitelisted for event metrics: "
<< type_;
DCHECK(scroll_input_type_) << "Event is not a scroll event";
switch (*scroll_input_type_) {
case ScrollInputType::kTouchscreen:
return "Touchscreen";
case ScrollInputType::kWheel:
return "Wheel";
case ScrollInputType::kAutoscroll:
return "Autoscroll";
case ScrollInputType::kScrollbar:
return "Scrollbar";
}
}
bool EventMetrics::operator==(const EventMetrics& other) const {
return std::tie(type_, time_stamp_, scroll_input_type_) ==
std::tie(other.type_, other.time_stamp_, other.scroll_input_type_);
}
// EventMetricsSet
EventMetricsSet::EventMetricsSet() = default;
EventMetricsSet::~EventMetricsSet() = default;
EventMetricsSet::EventMetricsSet(
std::vector<EventMetrics> main_thread_event_metrics,
std::vector<EventMetrics> impl_thread_event_metrics)
: main_event_metrics(std::move(main_thread_event_metrics)),
impl_event_metrics(std::move(impl_thread_event_metrics)) {}
EventMetricsSet::EventMetricsSet(EventMetricsSet&& other) = default;
EventMetricsSet& EventMetricsSet::operator=(EventMetricsSet&& other) = default;
} // namespace cc
|