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

Side by Side Diff: ash/common/shelf/shelf_button_pressed_metric_tracker.h

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs 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 unified diff | Download patch
OLDNEW
(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_COMMON_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_
6 #define ASH_COMMON_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_
7
8 #include <memory>
9
10 #include "ash/ash_export.h"
11 #include "ash/common/shelf/shelf_item_delegate.h"
12 #include "base/macros.h"
13 #include "base/time/tick_clock.h"
14 #include "base/time/time.h"
15 #include "ui/events/event.h"
16
17 namespace views {
18 class Button;
19 } // namespace views
20
21 namespace ash {
22
23 namespace test {
24 class ShelfButtonPressedMetricTrackerTestAPI;
25 } // namespace test
26
27 // Tracks UMA metrics based on shelf button press actions. More specifically
28 // data is added to the following user actions and histograms:
29 //
30 // User Actions:
31 // - Launcher_ButtonPressed_Mouse
32 // - Launcher_ButtonPressed_Touch
33 // - Launcher_LaunchTask
34 // - Launcher_MinimizeTask
35 // - Launcher_SwitchTask
36 // Histograms:
37 // - Ash.Shelf.TimeBetweenWindowMinimizedAndActivatedActions
38 //
39 class ASH_EXPORT ShelfButtonPressedMetricTracker {
40 public:
41 static const char
42 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName[];
43
44 ShelfButtonPressedMetricTracker();
45 ~ShelfButtonPressedMetricTracker();
46
47 // Records metrics based on the |event|, |sender|, and |performed_action|.
48 void ButtonPressed(const ui::Event& event,
49 const views::Button* sender,
50 ShelfAction performed_action);
51
52 private:
53 friend class test::ShelfButtonPressedMetricTrackerTestAPI;
54
55 // Records UMA metrics for the input source when a button is pressed.
56 void RecordButtonPressedSource(const ui::Event& event);
57
58 // Records UMA metrics for the action performed when a button is pressed.
59 void RecordButtonPressedAction(ShelfAction performed_action);
60
61 // Records UMA metrics for the elapsed time since the last window minimize
62 // action.
63 void RecordTimeBetweenMinimizedAndActivated();
64
65 // Returns true if a window activation action triggered by |sender| would
66 // be subsequent to the last minimize window action.
67 bool IsSubsequentActivationEvent(const views::Button* sender) const;
68
69 // Caches state data for a window minimized action. The |sender| is the button
70 // that caused the action.
71 void SetMinimizedData(const views::Button* sender);
72
73 // Resets the state data associated with the last window minimize action.
74 void ResetMinimizedData();
75
76 // Time source for performed action times.
77 std::unique_ptr<base::TickClock> tick_clock_;
78
79 // Stores the time of the last window minimize action.
80 base::TimeTicks time_of_last_minimize_;
81
82 // Stores the source button of the last window minimize action.
83 // NOTE: This may become stale and should not be operated on. Not owned.
84 const views::Button* last_minimized_source_button_;
85
86 DISALLOW_COPY_AND_ASSIGN(ShelfButtonPressedMetricTracker);
87 };
88
89 } // namespace ash
90
91 #endif // ASH_COMMON_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_button.cc ('k') | ash/common/shelf/shelf_button_pressed_metric_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698