Remove existing Skia suppressions
[chromium-blink-merge.git] / ash / metrics / task_switch_metrics_recorder.h
blobc1ee339fc7e9cc497389228bc087e3463fc3ed46
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.
5 #ifndef ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_
6 #define ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_
8 #include <string>
10 #include "ash/ash_export.h"
11 #include "base/containers/scoped_ptr_hash_map.h"
13 namespace aura {
14 class Window;
15 } // namespace aura
17 namespace ash {
19 class TaskSwitchTimeTracker;
21 // The TaskSwitchMetricsRecorder class records UMA metrics related to task
22 // switching. The main purpose of the TaskSwitchMetricsRecorder is to track time
23 // deltas between task switches and record histograms of the deltas.
24 class ASH_EXPORT TaskSwitchMetricsRecorder {
25 public:
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.
28 // TODO(bruthig): Convert enum format from kValue to VALUE.
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,
33 // Task switches from selecting items in the app list.
34 kAppList,
35 // Task switches caused by the user activating a task window by clicking or
36 // tapping on it.
37 kDesktop,
38 // Task switches caused by selecting a window from overview mode which is
39 // different from the previously-active window.
40 kOverviewMode,
41 // All task switches caused by shelf buttons, not including sub-menus.
42 kShelf,
43 // All task switches caused by the tab strip.
44 kTabStrip,
45 // Task switches caused by the WindowCycleController (ie Alt+Tab).
46 kWindowCycleController
49 TaskSwitchMetricsRecorder();
50 virtual ~TaskSwitchMetricsRecorder();
52 // Notifies |this| that a "navigate to" task switch has occurred from the
53 // specified |task_switch_source|. The metrics associated with
54 // TaskSwitchSource::kAny source will be updated as well.
56 // NOTE: A |task_switch_source| value of TaskSwitchSource::kAny should not be
57 // used and behavior is undefined if it is.
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).
67 // Will add an entry to |histogram_map_| when called for the first time for
68 // each |task_switch_source| value.
69 void OnTaskSwitch(TaskSwitchSource task_switch_source);
71 private:
72 // Internal implementation of OnTaskSwitch(TaskSwitchSource) that will accept
73 // the TaskSwitchSource::kAny value.
74 void OnTaskSwitchInternal(TaskSwitchSource task_switch_source);
76 // Returns the TaskSwitchTimeTracker associated with the specified
77 // |task_switch_source|. May return nullptr if mapping does not exist yet.
78 TaskSwitchTimeTracker* FindTaskSwitchTimeTracker(
79 TaskSwitchSource task_switch_source);
81 // Adds a TaskSwitchTimeTracker to |histogram_map_| for the specified
82 // |task_switch_source|. Behavior is undefined if a TaskSwitchTimeTracker
83 // |histogram_map_| already has an entry for |task_switch_source|.
84 void AddTaskSwitchTimeTracker(TaskSwitchSource task_switch_source);
86 // Tracks TaskSwitchSource to TaskSwitchTimeTracker mappings. The
87 // |histogram_map_| is populated on demand the first time a
88 // TaskSwitchTimeTracker is needed for a given source.
89 base::ScopedPtrHashMap<int, scoped_ptr<TaskSwitchTimeTracker>> histogram_map_;
91 DISALLOW_COPY_AND_ASSIGN(TaskSwitchMetricsRecorder);
94 } // namespace ash
96 #endif // ASH_METRICS_TASK_SWITCH_METRIC_RECORDER_H_