OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_STATS_COLLECTOR_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_STATS_COLLECTOR_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_STATS_COLLECTOR_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_STATS_COLLECTOR_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 NOTIFICATION_ACTION_CLOSE_BY_USER, | 32 NOTIFICATION_ACTION_CLOSE_BY_USER, |
33 NOTIFICATION_ACTION_CLOSE_BY_SYSTEM, | 33 NOTIFICATION_ACTION_CLOSE_BY_SYSTEM, |
34 // NOTE: Add new action types only immediately above this line. Also, | 34 // NOTE: Add new action types only immediately above this line. Also, |
35 // make sure the enum list in tools/histogram/histograms.xml is | 35 // make sure the enum list in tools/histogram/histograms.xml is |
36 // updated with any change in here. | 36 // updated with any change in here. |
37 NOTIFICATION_ACTION_COUNT | 37 NOTIFICATION_ACTION_COUNT |
38 }; | 38 }; |
39 | 39 |
40 explicit MessageCenterStatsCollector( | 40 explicit MessageCenterStatsCollector( |
41 message_center::MessageCenter* message_center); | 41 message_center::MessageCenter* message_center); |
42 virtual ~MessageCenterStatsCollector(); | 42 ~MessageCenterStatsCollector() override; |
43 | 43 |
44 private: | 44 private: |
45 // Represents the aggregate stats for each notification. | 45 // Represents the aggregate stats for each notification. |
46 class NotificationStats { | 46 class NotificationStats { |
47 public: | 47 public: |
48 // Default constructor for map. | 48 // Default constructor for map. |
49 NotificationStats(); | 49 NotificationStats(); |
50 | 50 |
51 explicit NotificationStats(const std::string& id); | 51 explicit NotificationStats(const std::string& id); |
52 virtual ~NotificationStats(); | 52 virtual ~NotificationStats(); |
53 | 53 |
54 // Called when we get an action from the message center. | 54 // Called when we get an action from the message center. |
55 void CollectAction(NotificationActionType type); | 55 void CollectAction(NotificationActionType type); |
56 | 56 |
57 // Sends aggregate data to UMA. | 57 // Sends aggregate data to UMA. |
58 void RecordAggregateStats(); | 58 void RecordAggregateStats(); |
59 | 59 |
60 private: | 60 private: |
61 std::string id_; | 61 std::string id_; |
62 bool actions_[NOTIFICATION_ACTION_COUNT]; | 62 bool actions_[NOTIFICATION_ACTION_COUNT]; |
63 }; | 63 }; |
64 | 64 |
65 // MessageCenterObserver | 65 // MessageCenterObserver |
66 virtual void OnNotificationAdded(const std::string& notification_id) override; | 66 void OnNotificationAdded(const std::string& notification_id) override; |
67 virtual void OnNotificationRemoved(const std::string& notification_id, | 67 void OnNotificationRemoved(const std::string& notification_id, |
68 bool by_user) override; | 68 bool by_user) override; |
69 virtual void OnNotificationUpdated( | 69 void OnNotificationUpdated(const std::string& notification_id) override; |
70 const std::string& notification_id) override; | 70 void OnNotificationClicked(const std::string& notification_id) override; |
71 virtual void OnNotificationClicked( | 71 void OnNotificationButtonClicked(const std::string& notification_id, |
72 const std::string& notification_id) override; | 72 int button_index) override; |
73 virtual void OnNotificationButtonClicked(const std::string& notification_id, | 73 void OnNotificationDisplayed( |
74 int button_index) override; | |
75 virtual void OnNotificationDisplayed( | |
76 const std::string& notification_id, | 74 const std::string& notification_id, |
77 const message_center::DisplaySource source) override; | 75 const message_center::DisplaySource source) override; |
78 virtual void OnCenterVisibilityChanged( | 76 void OnCenterVisibilityChanged( |
79 message_center::Visibility visibility) override; | 77 message_center::Visibility visibility) override; |
80 virtual void OnQuietModeChanged(bool in_quiet_mode) override; | 78 void OnQuietModeChanged(bool in_quiet_mode) override; |
81 | 79 |
82 // Weak, global. | 80 // Weak, global. |
83 message_center::MessageCenter* message_center_; | 81 message_center::MessageCenter* message_center_; |
84 | 82 |
85 typedef std::map<std::string,NotificationStats> StatsCollection; | 83 typedef std::map<std::string,NotificationStats> StatsCollection; |
86 StatsCollection stats_; | 84 StatsCollection stats_; |
87 | 85 |
88 DISALLOW_COPY_AND_ASSIGN(MessageCenterStatsCollector); | 86 DISALLOW_COPY_AND_ASSIGN(MessageCenterStatsCollector); |
89 }; | 87 }; |
90 | 88 |
91 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_STATS_COLLECTOR_H_ | 89 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_STATS_COLLECTOR_H_ |
OLD | NEW |