Chromium Code Reviews| Index: ash/wm/stylus_metrics_recorder.cc |
| diff --git a/ash/wm/stylus_metrics_recorder.cc b/ash/wm/stylus_metrics_recorder.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0bffe3e84e0402d84656cef57c7a8e3c151f9753 |
| --- /dev/null |
| +++ b/ash/wm/stylus_metrics_recorder.cc |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2016 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 "ash/wm/stylus_metrics_recorder.h" |
| + |
| +#include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| +#include "ash/common/wm_shell.h" |
| +#include "ash/shell.h" |
| +#include "base/metrics/histogram.h" |
| +#include "ui/events/event.h" |
| +#include "ui/events/event_constants.h" |
| +#include "ui/events/event_utils.h" |
| + |
| +namespace ash { |
| + |
| +enum DownEventFormFactor { |
| + DOWN_EVENT_FORMFACTOR_CLAMSHELL = 0, |
| + DOWN_EVENT_FORMFACTOR_TOUCHVIEW, |
| + DOWN_EVENT_FORMFACTOR_COUNT |
| +}; |
| + |
| +enum DownEventSource { |
| + DOWN_EVENT_SOURCE_MOUSE = 0, |
| + DOWN_EVENT_SOURCE_TOUCH, |
| + DOWN_EVENT_SOURCE_STYLUS, |
| + DOWN_EVENT_SOURCE_COUNT |
| +}; |
|
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.
|
| + |
| +StylusMetricsRecorder::StylusMetricsRecorder() {} |
| + |
| +StylusMetricsRecorder::~StylusMetricsRecorder() {} |
| + |
| +void StylusMetricsRecorder::OnMouseEvent(ui::MouseEvent* event) { |
| + if (event->type() != ui::ET_MOUSE_PRESSED) |
| + return; |
| + RecordUMA(event->pointer_details().pointer_type); |
| +} |
| + |
| +void StylusMetricsRecorder::OnTouchEvent(ui::TouchEvent* event) { |
| + if (event->type() != ui::ET_TOUCH_PRESSED) |
| + return; |
| + RecordUMA(event->pointer_details().pointer_type); |
| +} |
| + |
| +void StylusMetricsRecorder::RecordUMA(ui::EventPointerType type) { |
| + if (WmShell::Get() |
| + ->maximize_mode_controller() |
| + ->IsMaximizeModeWindowManagerEnabled()) { |
| + UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", |
| + DOWN_EVENT_FORMFACTOR_TOUCHVIEW, |
| + DOWN_EVENT_FORMFACTOR_COUNT); |
| + } else { |
| + UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", |
| + DOWN_EVENT_FORMFACTOR_CLAMSHELL, |
| + DOWN_EVENT_FORMFACTOR_COUNT); |
| + } |
|
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.
|
| + |
| + switch (type) { |
| + case ui::EventPointerType::POINTER_TYPE_MOUSE: |
| + UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", |
| + DOWN_EVENT_SOURCE_MOUSE, |
| + DOWN_EVENT_SOURCE_COUNT); |
| + break; |
| + case ui::EventPointerType::POINTER_TYPE_PEN: |
| + UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", |
| + DOWN_EVENT_SOURCE_STYLUS, |
| + DOWN_EVENT_SOURCE_COUNT); |
| + break; |
| + case ui::EventPointerType::POINTER_TYPE_TOUCH: |
| + UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", |
| + DOWN_EVENT_SOURCE_TOUCH, |
| + DOWN_EVENT_SOURCE_COUNT); |
| + break; |
| + 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.
|
| + break; |
| + } |
| +} |
| + |
| +} // namespace ash |