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

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: 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..d00ac72cd8284b896760ae358d2759b0ba9917c4 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,24 @@ void RecordGesturePrediction(GesturePredictionResult result) {
} // namespace
-UserModel::UserModel()
- : pending_input_event_count_(0),
+namespace features {
+
+// Enables the recording of gesture as UMA user actions.
+// That feature is disabled by default and controlled with Finch so as not to
Alexei Svitkine (slow) 2016/03/18 16:30:36 Nit: Finch is an internal keyword. You can say "co
beaudoin 2016/03/18 16:35:24 (Sad, such a great name! :)) Done.
+// generate too many UMA user actions.
+const base::Feature kRecordGestureAction {"RecordGestureActions",
+ 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 +58,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 +115,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;
}
« 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