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

Side by Side 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: Add units to histogram Created 3 years, 8 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_EVENTS_IDLE_FRACTION_RECORDER_H_
6 #define UI_EVENTS_IDLE_FRACTION_RECORDER_H_
7
8 #include "base/time/time.h"
9 #include "ui/events/events_base_export.h"
10
11 namespace ui {
12
13 // Receives as input a set of timestamps indicating when events were
14 // received. Reports via UMA the fraction of the time per |window_size_| that
15 // the user was interacting.
16 class EVENTS_BASE_EXPORT FractionOfTimeWithoutUserInputRecorder {
17 public:
18 FractionOfTimeWithoutUserInputRecorder();
19 void RecordEventAtTime(base::TimeTicks start_time);
20
21 protected:
22 virtual void RecordActiveInterval(base::TimeTicks start_time,
23 base::TimeTicks end_time);
24 void RecordToUma(float idle_fraction) const;
25 void set_window_size(base::TimeDelta window_size) {
26 window_size_ = window_size;
27 }
28 void set_idle_timeout(base::TimeDelta idle_timeout) {
29 idle_timeout_ = idle_timeout;
30 }
31
32 private:
33 // Within the current period of length |window_size_|, how long has the user
34 // been active?
35 base::TimeDelta current_window_active_time_;
36 // If the user is currently active, when did they start being active?
37 base::TimeTicks active_duration_start_time_;
38 base::TimeTicks window_start_time_;
39 base::TimeTicks previous_event_end_time_;
40
41 // We report the fraction of the time we were idle once per |window_size_|.
42 base::TimeDelta window_size_;
43
44 // Two events within |idle_timeout_| of one another are considered to be in
45 // the same period of user activity.
46 base::TimeDelta idle_timeout_;
47 };
48
49 } // namespace ui
50
51 #endif // UI_EVENTS_IDLE_FRACTION_RECORDER_H_
OLDNEW
« 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