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

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

Issue 2187953002: mash: Migrate ShelfButton* to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_
6 #define ASH_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 ShelfItemDelegate::PerformedAction 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(
60 ShelfItemDelegate::PerformedAction performed_action);
61
62 // Records UMA metrics for the elapsed time since the last window minimize
63 // action.
64 void RecordTimeBetweenMinimizedAndActivated();
65
66 // Returns true if a window activation action triggered by |sender| would
67 // be subsequent to the last minimize window action.
68 bool IsSubsequentActivationEvent(const views::Button* sender) const;
69
70 // Caches state data for a window minimized action. The |sender| is the button
71 // that caused the action.
72 void SetMinimizedData(const views::Button* sender);
73
74 // Resets the state data associated with the last window minimize action.
75 void ResetMinimizedData();
76
77 // Time source for performed action times.
78 std::unique_ptr<base::TickClock> tick_clock_;
79
80 // Stores the time of the last window minimize action.
81 base::TimeTicks time_of_last_minimize_;
82
83 // Stores the source button of the last window minimize action.
84 // NOTE: This may become stale and should not be operated on. Not owned.
85 const views::Button* last_minimized_source_button_;
86
87 DISALLOW_COPY_AND_ASSIGN(ShelfButtonPressedMetricTracker);
88 };
89
90 } // namespace ash
91
92 #endif // ASH_SHELF_SHELF_BUTTON_PRESSED_METRIC_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698