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

Unified Diff: ui/events/fraction_of_time_without_user_input_recorder.h

Issue 2751403002: Record the fraction of the time without user input - Aura only (Closed)
Patch Set: Address sadrul@'s feedback. Created 3 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 | « ui/events/BUILD.gn ('k') | ui/events/fraction_of_time_without_user_input_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/fraction_of_time_without_user_input_recorder.h
diff --git a/ui/events/fraction_of_time_without_user_input_recorder.h b/ui/events/fraction_of_time_without_user_input_recorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..6a59453715cd0c0cb15ff55401ddf7d9a38301e9
--- /dev/null
+++ b/ui/events/fraction_of_time_without_user_input_recorder.h
@@ -0,0 +1,45 @@
+// Copyright 2017 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 UI_EVENTS_IDLE_FRACTION_RECORDER_H_
+#define UI_EVENTS_IDLE_FRACTION_RECORDER_H_
+
+#include "base/time/time.h"
+#include "ui/events/events_base_export.h"
+
+namespace ui {
+
+// Receives as input a set of timestamps indicating when events were
+// received. Reports via UMA the fraction of the time per |window_size_| that
+// the user was interacting.
+class EVENTS_BASE_EXPORT FractionOfTimeWithoutUserInputRecorder {
+ public:
+ FractionOfTimeWithoutUserInputRecorder();
+ void RecordEventAtTime(base::TimeTicks start_time);
+
+ protected:
+ // We report the fraction of the time we were idle once per |window_size_|.
+ base::TimeDelta window_size_;
+
+ // Two events within |idle_timeout_| of one another are considered to be in
+ // the same period of user activity.
+ base::TimeDelta idle_timeout_;
+
+ virtual void RecordActiveInterval(base::TimeTicks start_time,
+ base::TimeTicks end_time);
+ virtual void RecordToUma(float idle_fraction) const;
sadrul 2017/03/24 17:29:33 This no longer needs to be virtual.
tdresser 2017/03/27 18:59:26 Done.
+
+ private:
+ // Within the current period of length |window_size_|, how long has the user
+ // been active?
+ base::TimeDelta current_window_active_time_;
+ // If the user is currently active, when did they start being active?
+ base::TimeTicks active_duration_start_time_;
+ base::TimeTicks window_start_time_;
+ base::TimeTicks previous_event_end_time_;
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_IDLE_FRACTION_RECORDER_H_
« no previous file with comments | « ui/events/BUILD.gn ('k') | ui/events/fraction_of_time_without_user_input_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698