OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_ | |
6 #define ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "ash/ash_export.h" | |
11 #include "base/containers/scoped_ptr_hash_map.h" | |
12 | |
13 namespace ash { | |
14 | |
15 class TaskSwitchTimeTracker; | |
16 | |
17 // The TaskSwitchMetricsRecorder class records UMA metrics related to task | |
18 // switching. The main purpose of the TaskSwitchMetricsRecorder is to track time | |
19 // deltas between task switches and record histograms of the deltas. | |
20 class ASH_EXPORT TaskSwitchMetricsRecorder { | |
21 public: | |
22 // Enumeration of the different user interfaces that could be the source of | |
23 // a task switch. Note this is not necessarily comprehensive of all sources. | |
24 enum TaskSwitchSource { | |
25 // All task switches caused by shelf buttons, not including sub-menus. | |
26 kShelf | |
27 }; | |
28 | |
29 TaskSwitchMetricsRecorder(); | |
30 virtual ~TaskSwitchMetricsRecorder(); | |
31 | |
32 // Notifies |this| that a "navigate to" task switch has occurred. A | |
33 // "navigate to" operation is defined by a task switch where the specific task | |
34 // that becomes active is user-predictable (ie Alt+Tab accelerator, launching | |
35 // a new window via the shelf, etc). Contrast to a "navigate away" operation | |
36 // which is defined as a user interaction that navigates away from a specified | |
37 // task and the next task that becomes active is likely not user-predictable | |
38 // (ie. closing or minimizing a window, closing a tab, etc). | |
39 void OnTaskSwitch(TaskSwitchSource task_switch_source); | |
tdanderson
2015/05/13 19:27:18
nit: mention the fact this lazily initializes the
bruthig
2015/05/13 21:16:21
Done.
| |
40 | |
41 private: | |
42 // Returns the TaskSwitchTimeTracker associated with the specified | |
43 // |task_switch_source|. May return |nullptr| if mapping does not exist yet. | |
tdanderson
2015/05/13 19:27:18
nit: no || around nullptr since it's not an identi
bruthig
2015/05/13 21:16:21
Done.
| |
44 TaskSwitchTimeTracker* FindTaskSwitchTimeTracker( | |
45 TaskSwitchSource task_switch_source); | |
46 | |
47 // Adds a TaskSwitchTimeTracker to |histogram_map_| for the specified | |
48 // |task_switch_source|. Behavior is undefined if a TaskSwitchTimeTracker | |
49 // |histogram_map_| already has an entry for |task_switch_source|. | |
50 void AddTaskSwitchTimeTracker(TaskSwitchSource task_switch_source); | |
51 | |
52 // Tracks TaskSwitchSource to TaskSwitchTimeTracker mappings. The | |
53 // |histogram_map_| is populated on demand the first time a | |
54 // TaskSwitchTimeTracker is needed for a given source. | |
55 base::ScopedPtrHashMap<int, scoped_ptr<TaskSwitchTimeTracker>> histogram_map_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(TaskSwitchMetricsRecorder); | |
58 }; | |
59 | |
60 } // namespace ash | |
61 | |
62 #endif // ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_ | |
OLD | NEW |