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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/notification_list.h
diff --git a/ui/message_center/notification_list.h b/ui/message_center/notification_list.h
index f52217b0787b9dde14c367812112e7533f2851b6..0154190ecb5d5d05aa650bb72614c65ffd34cfdc 100644
--- a/ui/message_center/notification_list.h
+++ b/ui/message_center/notification_list.h
@@ -45,16 +45,28 @@ struct MESSAGE_CENTER_EXPORT CompareTimestampSerial {
bool operator()(Notification* n1, Notification* n2);
};
+// An adapter to allow use of the comparers above with std::unique_ptr.
+template <typename PlainCompare>
+struct UniquePtrCompare {
+ template <typename T>
+ bool operator()(const std::unique_ptr<T>& n1, const std::unique_ptr<T>& n2) {
+ return PlainCompare()(n1.get(), n2.get());
+ }
+};
+
// A helper class to manage the list of notifications.
class MESSAGE_CENTER_EXPORT NotificationList {
public:
// Auto-sorted set. Matches the order in which Notifications are shown in
// Notification Center.
- typedef std::set<Notification*, ComparePriorityTimestampSerial> Notifications;
+ using Notifications = std::set<Notification*, ComparePriorityTimestampSerial>;
+ using OwnedNotifications =
+ std::set<std::unique_ptr<Notification>,
+ UniquePtrCompare<ComparePriorityTimestampSerial>>;
// Auto-sorted set used to return the Notifications to be shown as popup
// toasts.
- typedef std::set<Notification*, CompareTimestampSerial> PopupNotifications;
+ using PopupNotifications = std::set<Notification*, CompareTimestampSerial>;
explicit NotificationList(MessageCenter* message_center);
virtual ~NotificationList();
@@ -142,14 +154,14 @@ class MESSAGE_CENTER_EXPORT NotificationList {
TestPushingShownNotification);
// Iterates through the list and returns the first notification matching |id|.
- Notifications::iterator GetNotification(const std::string& id);
+ OwnedNotifications::iterator GetNotification(const std::string& id);
- void EraseNotification(Notifications::iterator iter);
+ void EraseNotification(OwnedNotifications::iterator iter);
void PushNotification(std::unique_ptr<Notification> notification);
MessageCenter* message_center_; // owner
- Notifications notifications_;
+ OwnedNotifications notifications_;
bool quiet_mode_;
DISALLOW_COPY_AND_ASSIGN(NotificationList);
« 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