Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Unified Diff: components/scheduler/renderer/user_model.cc

Issue 1683583002: Report user actions when gesture starts and stops in user_model. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not register action callback in single process. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/scheduler/renderer/user_model.h ('k') | components/scheduler/renderer/user_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/renderer/user_model.cc
diff --git a/components/scheduler/renderer/user_model.cc b/components/scheduler/renderer/user_model.cc
index c71e86c21d8e20f63ab20981964971f4639a08d4..c3deb133c05ff525e28013529c0fa25008529a81 100644
--- a/components/scheduler/renderer/user_model.cc
+++ b/components/scheduler/renderer/user_model.cc
@@ -5,6 +5,8 @@
#include "components/scheduler/renderer/user_model.h"
#include "base/metrics/histogram_macros.h"
+#include "base/metrics/user_metrics.h"
+#include "base/single_thread_task_runner.h"
namespace scheduler {
@@ -26,8 +28,20 @@ void RecordGesturePrediction(GesturePredictionResult result) {
} // namespace
-UserModel::UserModel()
- : pending_input_event_count_(0),
+namespace features {
+
+// Enables the recording of gestures as UMA user actions.
+// That feature is disabled by default and controlled from the server so as not
+// to generate too many UMA user actions.
+const base::Feature kRecordSchedulerGestureActions{
+ "RecordGestureActions", base::FEATURE_DISABLED_BY_DEFAULT};
+
+} // namespace features
+
+UserModel::UserModel(
+ scoped_refptr<base::SingleThreadTaskRunner> default_task_runner)
+ : default_task_runner_(default_task_runner),
+ pending_input_event_count_(0),
is_gesture_active_(false),
is_gesture_expected_(false) {}
UserModel::~UserModel() {}
@@ -42,6 +56,15 @@ void UserModel::DidStartProcessingInputEvent(blink::WebInputEvent::Type type,
if (!is_gesture_active_) {
last_gesture_start_time_ = now;
+ if (base::FeatureList::IsEnabled(
+ features::kRecordSchedulerGestureActions)) {
+ default_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&base::RecordAction,
+ base::UserMetricsAction(
+ "RendererScheduler.UserModel.GestureStart")));
+ }
+
RecordGesturePrediction(is_gesture_expected_
? GESTURE_OCCURED_WAS_PREDICTED
: GESTURE_OCCURED_BUT_NOT_PREDICTED);
@@ -91,6 +114,14 @@ void UserModel::DidStartProcessingInputEvent(blink::WebInputEvent::Type type,
base::TimeDelta duration = now - last_gesture_start_time_;
UMA_HISTOGRAM_TIMES("RendererScheduler.UserModel.GestureDuration",
duration);
+ if (base::FeatureList::IsEnabled(
+ features::kRecordSchedulerGestureActions)) {
+ default_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&base::RecordAction,
+ base::UserMetricsAction(
+ "RendererScheduler.UserModel.GestureEnd")));
+ }
}
is_gesture_active_ = false;
}
« no previous file with comments | « components/scheduler/renderer/user_model.h ('k') | components/scheduler/renderer/user_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698