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

Side by Side Diff: ui/message_center/notification_list.h

Issue 2314833002: Remove some uses of stl_util's STLDeleteContainerPointers. (Closed)
Patch Set: cleanup Created 4 years, 3 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
« no previous file with comments | « remoting/protocol/jingle_session.cc ('k') | ui/message_center/notification_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ 5 #ifndef UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_
6 #define UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ 6 #define UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 27 matching lines...) Expand all
38 38
39 // Comparers used to auto-sort the lists of Notifications. 39 // Comparers used to auto-sort the lists of Notifications.
40 struct MESSAGE_CENTER_EXPORT ComparePriorityTimestampSerial { 40 struct MESSAGE_CENTER_EXPORT ComparePriorityTimestampSerial {
41 bool operator()(Notification* n1, Notification* n2); 41 bool operator()(Notification* n1, Notification* n2);
42 }; 42 };
43 43
44 struct MESSAGE_CENTER_EXPORT CompareTimestampSerial { 44 struct MESSAGE_CENTER_EXPORT CompareTimestampSerial {
45 bool operator()(Notification* n1, Notification* n2); 45 bool operator()(Notification* n1, Notification* n2);
46 }; 46 };
47 47
48 // An adapter to allow use of the comparers above with std::unique_ptr.
49 template <typename PlainCompare>
50 struct UniquePtrCompare {
51 template <typename T>
52 bool operator()(const std::unique_ptr<T>& n1, const std::unique_ptr<T>& n2) {
53 return PlainCompare()(n1.get(), n2.get());
54 }
55 };
56
48 // A helper class to manage the list of notifications. 57 // A helper class to manage the list of notifications.
49 class MESSAGE_CENTER_EXPORT NotificationList { 58 class MESSAGE_CENTER_EXPORT NotificationList {
50 public: 59 public:
51 // Auto-sorted set. Matches the order in which Notifications are shown in 60 // Auto-sorted set. Matches the order in which Notifications are shown in
52 // Notification Center. 61 // Notification Center.
53 typedef std::set<Notification*, ComparePriorityTimestampSerial> Notifications; 62 using Notifications = std::set<Notification*, ComparePriorityTimestampSerial>;
63 using OwnedNotifications =
64 std::set<std::unique_ptr<Notification>,
65 UniquePtrCompare<ComparePriorityTimestampSerial>>;
54 66
55 // Auto-sorted set used to return the Notifications to be shown as popup 67 // Auto-sorted set used to return the Notifications to be shown as popup
56 // toasts. 68 // toasts.
57 typedef std::set<Notification*, CompareTimestampSerial> PopupNotifications; 69 using PopupNotifications = std::set<Notification*, CompareTimestampSerial>;
58 70
59 explicit NotificationList(MessageCenter* message_center); 71 explicit NotificationList(MessageCenter* message_center);
60 virtual ~NotificationList(); 72 virtual ~NotificationList();
61 73
62 // Makes a message "read". Collects the set of ids whose state have changed 74 // Makes a message "read". Collects the set of ids whose state have changed
63 // and set to |udpated_ids|. NULL if updated ids don't matter. 75 // and set to |udpated_ids|. NULL if updated ids don't matter.
64 void SetNotificationsShown(const NotificationBlockers& blockers, 76 void SetNotificationsShown(const NotificationBlockers& blockers,
65 std::set<std::string>* updated_ids); 77 std::set<std::string>* updated_ids);
66 78
67 void AddNotification(std::unique_ptr<Notification> notification); 79 void AddNotification(std::unique_ptr<Notification> notification);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const NotificationBlockers& blockers) const; 147 const NotificationBlockers& blockers) const;
136 size_t NotificationCount(const NotificationBlockers& blockers) const; 148 size_t NotificationCount(const NotificationBlockers& blockers) const;
137 size_t UnreadCount(const NotificationBlockers& blockers) const; 149 size_t UnreadCount(const NotificationBlockers& blockers) const;
138 150
139 private: 151 private:
140 friend class NotificationListTest; 152 friend class NotificationListTest;
141 FRIEND_TEST_ALL_PREFIXES(NotificationListTest, 153 FRIEND_TEST_ALL_PREFIXES(NotificationListTest,
142 TestPushingShownNotification); 154 TestPushingShownNotification);
143 155
144 // Iterates through the list and returns the first notification matching |id|. 156 // Iterates through the list and returns the first notification matching |id|.
145 Notifications::iterator GetNotification(const std::string& id); 157 OwnedNotifications::iterator GetNotification(const std::string& id);
146 158
147 void EraseNotification(Notifications::iterator iter); 159 void EraseNotification(OwnedNotifications::iterator iter);
148 160
149 void PushNotification(std::unique_ptr<Notification> notification); 161 void PushNotification(std::unique_ptr<Notification> notification);
150 162
151 MessageCenter* message_center_; // owner 163 MessageCenter* message_center_; // owner
152 Notifications notifications_; 164 OwnedNotifications notifications_;
153 bool quiet_mode_; 165 bool quiet_mode_;
154 166
155 DISALLOW_COPY_AND_ASSIGN(NotificationList); 167 DISALLOW_COPY_AND_ASSIGN(NotificationList);
156 }; 168 };
157 169
158 } // namespace message_center 170 } // namespace message_center
159 171
160 #endif // UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ 172 #endif // UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session.cc ('k') | ui/message_center/notification_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698