OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 #include "ash/wm/stylus_metrics_recorder.h" | |
6 | |
7 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | |
8 #include "ash/common/wm_shell.h" | |
9 #include "ash/shell.h" | |
10 #include "base/metrics/histogram.h" | |
11 #include "ui/events/event.h" | |
12 #include "ui/events/event_constants.h" | |
13 #include "ui/events/event_utils.h" | |
14 | |
15 namespace ash { | |
16 | |
17 enum DownEventFormFactor { | |
18 DOWN_EVENT_FORMFACTOR_CLAMSHELL = 0, | |
19 DOWN_EVENT_FORMFACTOR_TOUCHVIEW, | |
20 DOWN_EVENT_FORMFACTOR_COUNT | |
21 }; | |
22 | |
23 enum DownEventSource { | |
24 DOWN_EVENT_SOURCE_MOUSE = 0, | |
25 DOWN_EVENT_SOURCE_TOUCH, | |
26 DOWN_EVENT_SOURCE_STYLUS, | |
27 DOWN_EVENT_SOURCE_COUNT | |
28 }; | |
Ilya Sherman
2016/08/23 20:50:29
For each of these enums, please add a brief commen
xiaoyinh(OOO Sep 11-29)
2016/08/23 22:43:01
Done.
| |
29 | |
30 StylusMetricsRecorder::StylusMetricsRecorder() {} | |
31 | |
32 StylusMetricsRecorder::~StylusMetricsRecorder() {} | |
33 | |
34 void StylusMetricsRecorder::OnMouseEvent(ui::MouseEvent* event) { | |
35 if (event->type() != ui::ET_MOUSE_PRESSED) | |
36 return; | |
37 RecordUMA(event->pointer_details().pointer_type); | |
38 } | |
39 | |
40 void StylusMetricsRecorder::OnTouchEvent(ui::TouchEvent* event) { | |
41 if (event->type() != ui::ET_TOUCH_PRESSED) | |
42 return; | |
43 RecordUMA(event->pointer_details().pointer_type); | |
44 } | |
45 | |
46 void StylusMetricsRecorder::RecordUMA(ui::EventPointerType type) { | |
47 if (WmShell::Get() | |
48 ->maximize_mode_controller() | |
49 ->IsMaximizeModeWindowManagerEnabled()) { | |
50 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", | |
51 DOWN_EVENT_FORMFACTOR_TOUCHVIEW, | |
52 DOWN_EVENT_FORMFACTOR_COUNT); | |
53 } else { | |
54 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", | |
55 DOWN_EVENT_FORMFACTOR_CLAMSHELL, | |
56 DOWN_EVENT_FORMFACTOR_COUNT); | |
57 } | |
Ilya Sherman
2016/08/23 20:50:29
I'd recommend writing this to reduce repetition, l
oshima
2016/08/23 21:40:57
IIRC, it has to be that way because this macro cre
xiaoyinh(OOO Sep 11-29)
2016/08/23 22:43:01
Done.
| |
58 | |
59 switch (type) { | |
60 case ui::EventPointerType::POINTER_TYPE_MOUSE: | |
61 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", | |
62 DOWN_EVENT_SOURCE_MOUSE, | |
63 DOWN_EVENT_SOURCE_COUNT); | |
64 break; | |
65 case ui::EventPointerType::POINTER_TYPE_PEN: | |
66 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", | |
67 DOWN_EVENT_SOURCE_STYLUS, | |
68 DOWN_EVENT_SOURCE_COUNT); | |
69 break; | |
70 case ui::EventPointerType::POINTER_TYPE_TOUCH: | |
71 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", | |
72 DOWN_EVENT_SOURCE_TOUCH, | |
73 DOWN_EVENT_SOURCE_COUNT); | |
74 break; | |
75 default: | |
Ilya Sherman
2016/08/23 20:50:29
Please handle all possible cases explicitly, so th
xiaoyinh(OOO Sep 11-29)
2016/08/23 22:43:01
Done.
| |
76 break; | |
77 } | |
78 } | |
79 | |
80 } // namespace ash | |
OLD | NEW |