Commit 693c002f authored by xiaoyinh's avatar xiaoyinh Committed by Commit bot

Adding the following stylus metrics:

1. Number of “down” events generated by stylus/touch/mouse
2. Number of “down” events received by clamshell vs touchview

BUG=630070

Review-Url: https://codereview.chromium.org/2270173002
Cr-Commit-Position: refs/heads/master@{#414304}
parent 168ecd71
...@@ -140,6 +140,8 @@ component("ash") { ...@@ -140,6 +140,8 @@ component("ash") {
"touch/touchscreen_util.h", "touch/touchscreen_util.h",
"virtual_keyboard_controller.cc", "virtual_keyboard_controller.cc",
"virtual_keyboard_controller.h", "virtual_keyboard_controller.h",
"wm/stylus_metrics_recorder.cc",
"wm/stylus_metrics_recorder.h",
] ]
} }
......
...@@ -776,6 +776,8 @@ ...@@ -776,6 +776,8 @@
'wm/session_state_animator_impl.h', 'wm/session_state_animator_impl.h',
'wm/stacking_controller.cc', 'wm/stacking_controller.cc',
'wm/stacking_controller.h', 'wm/stacking_controller.h',
'wm/stylus_metrics_recorder.cc',
'wm/stylus_metrics_recorder.h',
'wm/system_background_controller.cc', 'wm/system_background_controller.cc',
'wm/system_background_controller.h', 'wm/system_background_controller.h',
'wm/system_gesture_event_filter.cc', 'wm/system_gesture_event_filter.cc',
...@@ -1193,7 +1195,9 @@ ...@@ -1193,7 +1195,9 @@
'touch/touchscreen_util.cc', 'touch/touchscreen_util.cc',
'touch/touchscreen_util.h', 'touch/touchscreen_util.h',
'virtual_keyboard_controller.cc', 'virtual_keyboard_controller.cc',
'virtual_keyboard_controller.h' 'virtual_keyboard_controller.h',
'wm/stylus_metrics_recorder.cc',
'wm/stylus_metrics_recorder.h'
], ],
}], }],
], ],
......
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
#include "ash/system/chromeos/power/video_activity_notifier.h" #include "ash/system/chromeos/power/video_activity_notifier.h"
#include "ash/touch/touch_transformer_controller.h" #include "ash/touch/touch_transformer_controller.h"
#include "ash/virtual_keyboard_controller.h" #include "ash/virtual_keyboard_controller.h"
#include "ash/wm/stylus_metrics_recorder.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "chromeos/audio/audio_a11y_controller.h" #include "chromeos/audio/audio_a11y_controller.h"
...@@ -552,6 +553,9 @@ Shell::~Shell() { ...@@ -552,6 +553,9 @@ Shell::~Shell() {
RemovePostTargetHandler(toplevel_window_event_handler_.get()); RemovePostTargetHandler(toplevel_window_event_handler_.get());
RemovePreTargetHandler(system_gesture_filter_.get()); RemovePreTargetHandler(system_gesture_filter_.get());
RemovePreTargetHandler(mouse_cursor_filter_.get()); RemovePreTargetHandler(mouse_cursor_filter_.get());
#if defined(OS_CHROMEOS)
RemovePreTargetHandler(stylus_metrics_recorder_.get());
#endif
RemovePreTargetHandler(modality_filter_.get()); RemovePreTargetHandler(modality_filter_.get());
// TooltipController is deleted with the Shell so removing its references. // TooltipController is deleted with the Shell so removing its references.
...@@ -640,9 +644,7 @@ Shell::~Shell() { ...@@ -640,9 +644,7 @@ Shell::~Shell() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
touch_transformer_controller_.reset(); touch_transformer_controller_.reset();
#endif // defined(OS_CHROMEOS) stylus_metrics_recorder_.reset();
#if defined(OS_CHROMEOS)
audio_a11y_controller_.reset(); audio_a11y_controller_.reset();
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -864,6 +866,14 @@ void Shell::Init(const ShellInitParams& init_params) { ...@@ -864,6 +866,14 @@ void Shell::Init(const ShellInitParams& init_params) {
mouse_cursor_filter_.reset(new MouseCursorEventFilter()); mouse_cursor_filter_.reset(new MouseCursorEventFilter());
PrependPreTargetHandler(mouse_cursor_filter_.get()); PrependPreTargetHandler(mouse_cursor_filter_.get());
#if defined(OS_CHROMEOS)
// |stylus_metrics_recorder| records stylus metrics for certain events.
// It does not handle/consume any events, so prepend it as a pre-target hander
// before events are consumed elsewhere.
stylus_metrics_recorder_.reset(new StylusMetricsRecorder());
PrependPreTargetHandler(stylus_metrics_recorder_.get());
#endif
// Create Controllers that may need root window. // Create Controllers that may need root window.
// TODO(oshima): Move as many controllers before creating // TODO(oshima): Move as many controllers before creating
// RootWindowController as possible. // RootWindowController as possible.
......
...@@ -120,6 +120,7 @@ struct ShellInitParams; ...@@ -120,6 +120,7 @@ struct ShellInitParams;
class SlowAnimationEventFilter; class SlowAnimationEventFilter;
class StatusAreaWidget; class StatusAreaWidget;
class StickyKeysController; class StickyKeysController;
class StylusMetricsRecorder;
class SystemGestureEventFilter; class SystemGestureEventFilter;
class SystemModalContainerEventFilter; class SystemModalContainerEventFilter;
class SystemTray; class SystemTray;
...@@ -576,6 +577,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, ...@@ -576,6 +577,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
std::unique_ptr<ui::EventHandler> magnifier_key_scroll_handler_; std::unique_ptr<ui::EventHandler> magnifier_key_scroll_handler_;
std::unique_ptr<ui::EventHandler> speech_feedback_handler_; std::unique_ptr<ui::EventHandler> speech_feedback_handler_;
std::unique_ptr<StylusMetricsRecorder> stylus_metrics_recorder_;
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
// |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a // |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
......
// 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. 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. 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 = DOWN_EVENT_FORMFACTOR_CLAMSHELL;
if (WmShell::Get()
->maximize_mode_controller()
->IsMaximizeModeWindowManagerEnabled()) {
form_factor = DOWN_EVENT_FORMFACTOR_TOUCHVIEW;
}
UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", form_factor,
DOWN_EVENT_FORMFACTOR_COUNT);
DownEventSource input_type = DOWN_EVENT_SOURCE_UNKNOWN;
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
// 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.
#ifndef ASH_WM_STYLUS_METRICS_RECORDER_H_
#define ASH_WM_STYLUS_METRICS_RECORDER_H_
#include <memory>
#include "base/macros.h"
#include "ui/events/event_handler.h"
namespace ash {
// An event recorder that record stylus related metrics.
class StylusMetricsRecorder : public ui::EventHandler {
public:
StylusMetricsRecorder();
~StylusMetricsRecorder() override;
private:
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override;
void OnTouchEvent(ui::TouchEvent* event) override;
void RecordUMA(ui::EventPointerType type);
DISALLOW_COPY_AND_ASSIGN(StylusMetricsRecorder);
};
} // namespace ash
#endif // ASH_WM_STYLUS_METRICS_RECORDER_H_
...@@ -12759,6 +12759,20 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -12759,6 +12759,20 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Event.DownEventCount.PerFormFactor" enum="DownEventFormFactor">
<owner>xiaoyinh@chromium.org</owner>
<summary>
Counts the number of down events generated by clamshell/touchview.
</summary>
</histogram>
<histogram name="Event.DownEventCount.PerInput" enum="DownEventSource">
<owner>xiaoyinh@chromium.org</owner>
<summary>
Counts the number of down events generated by Mouse/Touch/Stylus.
</summary>
</histogram>
<histogram name="Event.DragDrop.Cancel" enum="DragDropEventSource"> <histogram name="Event.DragDrop.Cancel" enum="DragDropEventSource">
<owner>mfomitchev@chromium.org</owner> <owner>mfomitchev@chromium.org</owner>
<summary> <summary>
...@@ -74081,6 +74095,18 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -74081,6 +74095,18 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="2" label="GET_NON_CACHABLE"/> <int value="2" label="GET_NON_CACHABLE"/>
</enum> </enum>
<enum name="DownEventFormFactor" type="int">
<int value="0" label="Clamshell"/>
<int value="1" label="Touchview"/>
</enum>
<enum name="DownEventSource" type="int">
<int value="0" label="Unknown"/>
<int value="1" label="Mouse"/>
<int value="2" label="Stylus"/>
<int value="3" label="Touch"/>
</enum>
<enum name="DownloadContentDisposition" type="int"> <enum name="DownloadContentDisposition" type="int">
<int value="0" label="Content-Disposition header present"/> <int value="0" label="Content-Disposition header present"/>
<int value="1" label="Valid"/> <int value="1" label="Valid"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment