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

Side by Side Diff: ash/metrics/task_switch_metrics_recorder.h

Issue 1148723006: Added Ash.TimeBetweenTaskSwitches to record time deltas between all recorded task switches. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged with master. Created 5 years, 6 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 | « no previous file | ash/metrics/task_switch_metrics_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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_ 5 #ifndef ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_
6 #define ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_ 6 #define ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "base/containers/scoped_ptr_hash_map.h" 11 #include "base/containers/scoped_ptr_hash_map.h"
12 12
13 namespace aura { 13 namespace aura {
14 class Window; 14 class Window;
15 } // namespace aura 15 } // namespace aura
16 16
17 namespace ash { 17 namespace ash {
18 18
19 class TaskSwitchTimeTracker; 19 class TaskSwitchTimeTracker;
20 20
21 // The TaskSwitchMetricsRecorder class records UMA metrics related to task 21 // The TaskSwitchMetricsRecorder class records UMA metrics related to task
22 // switching. The main purpose of the TaskSwitchMetricsRecorder is to track time 22 // switching. The main purpose of the TaskSwitchMetricsRecorder is to track time
23 // deltas between task switches and record histograms of the deltas. 23 // deltas between task switches and record histograms of the deltas.
24 class ASH_EXPORT TaskSwitchMetricsRecorder { 24 class ASH_EXPORT TaskSwitchMetricsRecorder {
25 public: 25 public:
26 // Enumeration of the different user interfaces that could be the source of 26 // Enumeration of the different user interfaces that could be the source of
27 // a task switch. Note this is not necessarily comprehensive of all sources. 27 // a task switch. Note this is not necessarily comprehensive of all sources.
28 // TODO(bruthig): Convert enum format from kValue to VALUE. 28 // TODO(bruthig): Convert enum format from kValue to VALUE.
29 enum TaskSwitchSource { 29 enum TaskSwitchSource {
30 // Task switches caused by any two sources in this enum. NOTE: This value
31 // should NOT be used outside of this class.
32 kAny,
30 // Task switches from selecting items in the app list. 33 // Task switches from selecting items in the app list.
31 kAppList, 34 kAppList,
32 // Task switches caused by the user activating a task window by clicking or 35 // Task switches caused by the user activating a task window by clicking or
33 // tapping on it. 36 // tapping on it.
34 kDesktop, 37 kDesktop,
35 // Task switches caused by selecting a window from overview mode which is 38 // Task switches caused by selecting a window from overview mode which is
36 // different from the previously-active window. 39 // different from the previously-active window.
37 kOverviewMode, 40 kOverviewMode,
38 // All task switches caused by shelf buttons, not including sub-menus. 41 // All task switches caused by shelf buttons, not including sub-menus.
39 kShelf, 42 kShelf,
40 // All task switches caused by the tab strip. 43 // All task switches caused by the tab strip.
41 kTabStrip, 44 kTabStrip,
42 // Task switches caused by the WindowCycleController (ie Alt+Tab). 45 // Task switches caused by the WindowCycleController (ie Alt+Tab).
43 kWindowCycleController 46 kWindowCycleController
44 }; 47 };
45 48
46 TaskSwitchMetricsRecorder(); 49 TaskSwitchMetricsRecorder();
47 virtual ~TaskSwitchMetricsRecorder(); 50 virtual ~TaskSwitchMetricsRecorder();
48 51
49 // Notifies |this| that a "navigate to" task switch has occurred. A 52 // Notifies |this| that a "navigate to" task switch has occurred from the
50 // "navigate to" operation is defined by a task switch where the specific task 53 // specified |task_switch_source|. The metrics associated with
51 // that becomes active is user-predictable (ie Alt+Tab accelerator, launching 54 // TaskSwitchSource::kAny source will be updated as well.
52 // a new window via the shelf, etc). Contrast to a "navigate away" operation 55 //
53 // which is defined as a user interaction that navigates away from a specified 56 // NOTE: A |task_switch_source| value of TaskSwitchSource::kAny should not be
54 // task and the next task that becomes active is likely not user-predictable 57 // used and behavior is undefined if it is.
55 // (ie. closing or minimizing a window, closing a tab, etc). 58 //
59 // A "navigate to" operation is defined by a task switch where the specific
60 // task that becomes active is user-predictable (e.g., Alt+Tab accelerator,
61 // launching a new window via the shelf, etc). Contrast to a "navigate away"
62 // operation which is defined as a user interaction that navigates away from a
63 // specified task and the next task that becomes active is likely not
64 // user-predictable (e.g., closing or minimizing a window, closing a tab,
65 // etc).
56 // 66 //
57 // Will add an entry to |histogram_map_| when called for the first time for 67 // Will add an entry to |histogram_map_| when called for the first time for
58 // each |task_switch_source| value. 68 // each |task_switch_source| value.
59 void OnTaskSwitch(TaskSwitchSource task_switch_source); 69 void OnTaskSwitch(TaskSwitchSource task_switch_source);
60 70
61 private: 71 private:
72 // Internal implementation of OnTaskSwitch(TaskSwitchSource) that will accept
73 // the TaskSwitchSource::kAny value.
74 void OnTaskSwitchInternal(TaskSwitchSource task_switch_source);
75
62 // Returns the TaskSwitchTimeTracker associated with the specified 76 // Returns the TaskSwitchTimeTracker associated with the specified
63 // |task_switch_source|. May return nullptr if mapping does not exist yet. 77 // |task_switch_source|. May return nullptr if mapping does not exist yet.
64 TaskSwitchTimeTracker* FindTaskSwitchTimeTracker( 78 TaskSwitchTimeTracker* FindTaskSwitchTimeTracker(
65 TaskSwitchSource task_switch_source); 79 TaskSwitchSource task_switch_source);
66 80
67 // Adds a TaskSwitchTimeTracker to |histogram_map_| for the specified 81 // Adds a TaskSwitchTimeTracker to |histogram_map_| for the specified
68 // |task_switch_source|. Behavior is undefined if a TaskSwitchTimeTracker 82 // |task_switch_source|. Behavior is undefined if a TaskSwitchTimeTracker
69 // |histogram_map_| already has an entry for |task_switch_source|. 83 // |histogram_map_| already has an entry for |task_switch_source|.
70 void AddTaskSwitchTimeTracker(TaskSwitchSource task_switch_source); 84 void AddTaskSwitchTimeTracker(TaskSwitchSource task_switch_source);
71 85
72 // Tracks TaskSwitchSource to TaskSwitchTimeTracker mappings. The 86 // Tracks TaskSwitchSource to TaskSwitchTimeTracker mappings. The
73 // |histogram_map_| is populated on demand the first time a 87 // |histogram_map_| is populated on demand the first time a
74 // TaskSwitchTimeTracker is needed for a given source. 88 // TaskSwitchTimeTracker is needed for a given source.
75 base::ScopedPtrHashMap<int, scoped_ptr<TaskSwitchTimeTracker>> histogram_map_; 89 base::ScopedPtrHashMap<int, scoped_ptr<TaskSwitchTimeTracker>> histogram_map_;
76 90
77 DISALLOW_COPY_AND_ASSIGN(TaskSwitchMetricsRecorder); 91 DISALLOW_COPY_AND_ASSIGN(TaskSwitchMetricsRecorder);
78 }; 92 };
79 93
80 } // namespace ash 94 } // namespace ash
81 95
82 #endif // ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_ 96 #endif // ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/metrics/task_switch_metrics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698