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..142e58152816439aeda79ae922a219b38a1d990d |
| --- /dev/null |
| +++ b/ash/wm/stylus_metrics_recorder.cc |
| @@ -0,0 +1,85 @@ |
| +// 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 { |
| + |
| +// Form factor of the down event. |
|
jdufault
2016/08/23 23:09:53
Continue comment on the same line.
xiaoyinh(OOO Sep 11-29)
2016/08/23 23:45:41
Done.
|
| +// This enum is used to back an UMA histogram and should be treated as |
| +// append-only. |
| +enum DownEventFormFactor { |
| + DOWN_EVENT_FORMFACTOR_CLAMSHELL = 0, |
| + DOWN_EVENT_FORMFACTOR_TOUCHVIEW, |
| + DOWN_EVENT_FORMFACTOR_COUNT |
| +}; |
| + |
| +// Input type of the down event. |
|
jdufault
2016/08/23 23:09:53
Continue comment on the same line.
xiaoyinh(OOO Sep 11-29)
2016/08/23 23:45:41
Done.
|
| +// This enum is used to back an UMA histogram and should be treated as |
| +// append-only. |
| +enum DownEventSource { |
| + DOWN_EVENT_SOURCE_UNKNOWN = 0, |
| + DOWN_EVENT_SOURCE_MOUSE, |
| + DOWN_EVENT_SOURCE_STYLUS, |
| + DOWN_EVENT_SOURCE_TOUCH, |
| + DOWN_EVENT_SOURCE_COUNT |
| +}; |
| + |
| +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) { |
| + DownEventFormFactor form_factor; |
| + if (WmShell::Get() |
| + ->maximize_mode_controller() |
| + ->IsMaximizeModeWindowManagerEnabled()) { |
| + form_factor = DOWN_EVENT_FORMFACTOR_TOUCHVIEW; |
| + } else { |
| + form_factor = DOWN_EVENT_FORMFACTOR_CLAMSHELL; |
| + } |
| + UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", form_factor, |
| + DOWN_EVENT_FORMFACTOR_COUNT); |
| + |
| + DownEventSource input_type; |
| + switch (type) { |
| + case ui::EventPointerType::POINTER_TYPE_UNKNOWN: |
| + input_type = DOWN_EVENT_SOURCE_UNKNOWN; |
| + break; |
| + case ui::EventPointerType::POINTER_TYPE_MOUSE: |
| + input_type = DOWN_EVENT_SOURCE_MOUSE; |
| + break; |
| + case ui::EventPointerType::POINTER_TYPE_PEN: |
| + input_type = DOWN_EVENT_SOURCE_STYLUS; |
| + break; |
| + case ui::EventPointerType::POINTER_TYPE_TOUCH: |
| + input_type = DOWN_EVENT_SOURCE_TOUCH; |
| + break; |
| + } |
| + |
| + UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", input_type, |
| + DOWN_EVENT_SOURCE_COUNT); |
| +} |
| + |
| +} // namespace ash |