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

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: Caching feature. 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
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..1a01d6ff4fc69b8ceb76f6fe5eb7b03ad44ce0b3 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,10 +28,22 @@ void RecordGesturePrediction(GesturePredictionResult result) {
} // namespace
-UserModel::UserModel()
- : pending_input_event_count_(0),
+namespace features {
+
+// Enables the recording of gesture as UMA user actions.
Alexei Svitkine (slow) 2016/03/17 21:38:46 Maybe add a comment about the reasoning for this b
beaudoin 2016/03/18 16:08:36 Done.
+const base::Feature kRecordGestureAction = {"RecordGestureActions",
Alexei Svitkine (slow) 2016/03/17 21:38:46 Nit: No need for =.
beaudoin 2016/03/18 16:08:36 Done.
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
+} // namespace features
+
+UserModel::UserModel(
+ const 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) {}
+ is_gesture_expected_(false),
+ record_gesture_action_(
+ base::FeatureList::IsEnabled(features::kRecordGestureAction)) {}
UserModel::~UserModel() {}
void UserModel::DidStartProcessingInputEvent(blink::WebInputEvent::Type type,
@@ -42,6 +56,14 @@ void UserModel::DidStartProcessingInputEvent(blink::WebInputEvent::Type type,
if (!is_gesture_active_) {
last_gesture_start_time_ = now;
+ if (record_gesture_action_) {
+ 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 +113,13 @@ void UserModel::DidStartProcessingInputEvent(blink::WebInputEvent::Type type,
base::TimeDelta duration = now - last_gesture_start_time_;
UMA_HISTOGRAM_TIMES("RendererScheduler.UserModel.GestureDuration",
duration);
+ if (record_gesture_action_) {
+ default_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&base::RecordAction,
+ base::UserMetricsAction(
+ "RendererScheduler.UserModel.GestureEnd")));
+ }
}
is_gesture_active_ = false;
}

Powered by Google App Engine
This is Rietveld 408576698