Title: [108566] trunk/Source/WebKit2
- Revision
- 108566
- Author
- [email protected]
- Date
- 2012-02-22 15:45:15 -0800 (Wed, 22 Feb 2012)
Log Message
[WK2] Clearing notifications does not clean up internal state
https://bugs.webkit.org/show_bug.cgi?id=78861
<rdar://problem/10881167>
Reviewed by Anders Carlsson.
* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::WebNotificationManager::clearNotifications): This function was missing removing the notification
entries from the other maps.
(WebKit::WebNotificationManager::didDestroyNotification): When the notification is destroyed, it should
also be removed from the context map.
(WebKit::WebNotificationManager::didCloseNotifications): Refactor to pull out the code that removes
a provided notification from the context map.
(WebKit::WebNotificationManager::removeNotificationFromContextMap): Find the notification in the map, and
remove it. If the map is empty, get rid of the entry.
* WebProcess/Notifications/WebNotificationManager.h:
(WebNotificationManager):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (108565 => 108566)
--- trunk/Source/WebKit2/ChangeLog 2012-02-22 23:44:42 UTC (rev 108565)
+++ trunk/Source/WebKit2/ChangeLog 2012-02-22 23:45:15 UTC (rev 108566)
@@ -1,3 +1,23 @@
+2012-02-16 Jon Lee <[email protected]>
+
+ [WK2] Clearing notifications does not clean up internal state
+ https://bugs.webkit.org/show_bug.cgi?id=78861
+ <rdar://problem/10881167>
+
+ Reviewed by Anders Carlsson.
+
+ * WebProcess/Notifications/WebNotificationManager.cpp:
+ (WebKit::WebNotificationManager::clearNotifications): This function was missing removing the notification
+ entries from the other maps.
+ (WebKit::WebNotificationManager::didDestroyNotification): When the notification is destroyed, it should
+ also be removed from the context map.
+ (WebKit::WebNotificationManager::didCloseNotifications): Refactor to pull out the code that removes
+ a provided notification from the context map.
+ (WebKit::WebNotificationManager::removeNotificationFromContextMap): Find the notification in the map, and
+ remove it. If the map is empty, get rid of the entry.
+ * WebProcess/Notifications/WebNotificationManager.h:
+ (WebNotificationManager):
+
2012-02-22 Jon Lee <[email protected]>
Code cleanup in WebNotificationManager (79285)
Modified: trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp (108565 => 108566)
--- trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp 2012-02-22 23:44:42 UTC (rev 108565)
+++ trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp 2012-02-22 23:45:15 UTC (rev 108566)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -145,7 +145,16 @@
if (it == m_notificationContextMap.end())
return;
- m_process->connection()->send(Messages::WebNotificationManagerProxy::ClearNotifications(it->second), page->pageID());
+ Vector<uint64_t>& notificationIDs = it->second;
+ m_process->connection()->send(Messages::WebNotificationManagerProxy::ClearNotifications(notificationIDs), page->pageID());
+ size_t count = notificationIDs.size();
+ for (size_t i = 0; i < count; ++i) {
+ RefPtr<Notification> notification = m_notificationIDMap.take(notificationIDs[i]);
+ if (!notification)
+ continue;
+ m_notificationMap.remove(notification);
+ }
+
m_notificationContextMap.remove(it);
#endif
}
@@ -157,7 +166,8 @@
if (!notificationID)
return;
- m_notificationIDMap.take(notificationID);
+ m_notificationIDMap.remove(notificationID);
+ removeNotificationFromContextMap(notificationID, notification);
m_process->connection()->send(Messages::WebNotificationManagerProxy::DidDestroyNotification(notificationID), page->pageID());
#endif
}
@@ -199,19 +209,30 @@
if (!isNotificationIDValid(notificationID))
continue;
- RefPtr<Notification> notification = m_notificationIDMap.get(notificationID);
+ RefPtr<Notification> notification = m_notificationIDMap.take(notificationID);
if (!notification)
continue;
- NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext());
- ASSERT(it != m_notificationContextMap.end());
- size_t index = it->second.find(notificationID);
- ASSERT(index != notFound);
- it->second.remove(index);
+ m_notificationMap.remove(notification);
+ removeNotificationFromContextMap(notificationID, notification.get());
notification->dispatchCloseEvent();
}
#endif
}
+#if ENABLE(NOTIFICATIONS)
+void WebNotificationManager::removeNotificationFromContextMap(uint64_t notificationID, Notification* notification)
+{
+ // This is a helper function for managing the hash maps.
+ NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext());
+ ASSERT(it != m_notificationContextMap.end());
+ size_t index = it->second.find(notificationID);
+ ASSERT(index != notFound);
+ it->second.remove(index);
+ if (it->second.isEmpty())
+ m_notificationContextMap.remove(it);
+}
+#endif
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h (108565 => 108566)
--- trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h 2012-02-22 23:44:42 UTC (rev 108565)
+++ trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h 2012-02-22 23:45:15 UTC (rev 108566)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -77,6 +77,10 @@
void didCloseNotifications(const Vector<uint64_t>& notificationIDs);
void didUpdateNotificationDecision(const String& originString, bool allowed);
void didRemoveNotificationDecisions(const Vector<String>& originStrings);
+
+#if ENABLE(NOTIFICATIONS)
+ void removeNotificationFromContextMap(uint64_t notificationID, WebCore::Notification*);
+#endif
WebProcess* m_process;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes