Title: [148229] trunk/Source/WebKit2
Revision
148229
Author
[email protected]
Date
2013-04-11 13:14:45 -0700 (Thu, 11 Apr 2013)

Log Message

Clean up related storage areas when a connection is destroyed
https://bugs.webkit.org/show_bug.cgi?id=114459

Reviewed by Beth Dakin.

* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::processWillCloseConnection):
Dispatch invalidateConnectionInternal on the work queue.

(WebKit::StorageManager::createStorageMap):
(WebKit::StorageManager::destroyStorageMap):
Rename m_storageAreas to m_storageAreasByConnection.

(WebKit::StorageManager::invalidateConnectionInternal):
Go over all known storage areas and remove this connection as a listener.

(WebKit::StorageManager::findStorageArea):
Rename m_storageAreas to m_storageAreasByConnection.

* UIProcess/Storage/StorageManager.h:
Rename m_storageAreas to m_storageAreasByConnection.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (148228 => 148229)


--- trunk/Source/WebKit2/ChangeLog	2013-04-11 20:08:32 UTC (rev 148228)
+++ trunk/Source/WebKit2/ChangeLog	2013-04-11 20:14:45 UTC (rev 148229)
@@ -1,5 +1,29 @@
 2013-04-11  Anders Carlsson  <[email protected]>
 
+        Clean up related storage areas when a connection is destroyed
+        https://bugs.webkit.org/show_bug.cgi?id=114459
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/Storage/StorageManager.cpp:
+        (WebKit::StorageManager::processWillCloseConnection):
+        Dispatch invalidateConnectionInternal on the work queue.
+        
+        (WebKit::StorageManager::createStorageMap):
+        (WebKit::StorageManager::destroyStorageMap):
+        Rename m_storageAreas to m_storageAreasByConnection.
+
+        (WebKit::StorageManager::invalidateConnectionInternal):
+        Go over all known storage areas and remove this connection as a listener.
+
+        (WebKit::StorageManager::findStorageArea):
+        Rename m_storageAreas to m_storageAreasByConnection.
+
+        * UIProcess/Storage/StorageManager.h:
+        Rename m_storageAreas to m_storageAreasByConnection.
+
+2013-04-11  Anders Carlsson  <[email protected]>
+
         Make StorageAreaMap dispatch session storage events
         https://bugs.webkit.org/show_bug.cgi?id=114454
 

Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (148228 => 148229)


--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp	2013-04-11 20:08:32 UTC (rev 148228)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp	2013-04-11 20:14:45 UTC (rev 148229)
@@ -206,6 +206,8 @@
 void StorageManager::processWillCloseConnection(WebProcessProxy* webProcessProxy)
 {
     webProcessProxy->connection()->removeWorkQueueMessageReceiver(Messages::StorageManager::messageReceiverName());
+
+    m_queue->dispatch(bind(&StorageManager::invalidateConnectionInternal, this, RefPtr<CoreIPC::Connection>(webProcessProxy->connection())));
 }
 
 void StorageManager::createStorageMap(CoreIPC::Connection* connection, uint64_t storageMapID, uint64_t storageNamespaceID, const SecurityOriginData& securityOriginData)
@@ -215,7 +217,7 @@
     // FIXME: This should be a message check.
     ASSERT((HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::isValidKey(connectionAndStorageMapIDPair)));
 
-    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::AddResult result = m_storageAreas.add(connectionAndStorageMapIDPair, 0);
+    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::AddResult result = m_storageAreasByConnection.add(connectionAndStorageMapIDPair, 0);
 
     // FIXME: This should be a message check.
     ASSERT(result.isNewEntry);
@@ -245,14 +247,13 @@
     // FIXME: This should be a message check.
     ASSERT((HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::isValidKey(connectionAndStorageMapIDPair)));
 
-    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::iterator it = m_storageAreas.find(connectionAndStorageMapIDPair);
+    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::iterator it = m_storageAreasByConnection.find(connectionAndStorageMapIDPair);
 
     // FIXME: This should be a message check.
-    ASSERT(it != m_storageAreas.end());
+    ASSERT(it != m_storageAreasByConnection.end());
 
     it->value->removeListener(connection, storageMapID);
-
-    m_storageAreas.remove(connectionAndStorageMapIDPair);
+    m_storageAreasByConnection.remove(connectionAndStorageMapIDPair);
 }
 
 void StorageManager::getValues(CoreIPC::Connection*, uint64_t, HashMap<String, String>&)
@@ -304,13 +305,29 @@
     sessionStorageNamespace->cloneTo(*newSessionStorageNamespace);
 }
 
+void StorageManager::invalidateConnectionInternal(CoreIPC::Connection* connection)
+{
+    Vector<std::pair<RefPtr<CoreIPC::Connection>, uint64_t> > connectionAndStorageMapIDPairsToRemove;
+    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> > storageAreasByConnection = m_storageAreasByConnection;
+    for (HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::const_iterator it = storageAreasByConnection.begin(), end = storageAreasByConnection.end(); it != end; ++it) {
+        if (it->key.first != connection)
+            continue;
+
+        it->value->removeListener(it->key.first.get(), it->key.second);
+        connectionAndStorageMapIDPairsToRemove.append(it->key);
+    }
+
+    for (size_t i = 0; i < connectionAndStorageMapIDPairsToRemove.size(); ++i)
+        m_storageAreasByConnection.remove(connectionAndStorageMapIDPairsToRemove[i]);
+}
+
 StorageManager::StorageArea* StorageManager::findStorageArea(CoreIPC::Connection* connection, uint64_t storageMapID) const
 {
     std::pair<CoreIPC::Connection*, uint64_t> connectionAndStorageMapIDPair(connection, storageMapID);
     if (!HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::isValidKey(connectionAndStorageMapIDPair))
         return 0;
 
-    return m_storageAreas.get(connectionAndStorageMapIDPair).get();
+    return m_storageAreasByConnection.get(connectionAndStorageMapIDPair).get();
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h (148228 => 148229)


--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h	2013-04-11 20:08:32 UTC (rev 148228)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h	2013-04-11 20:14:45 UTC (rev 148229)
@@ -69,6 +69,8 @@
     void setAllowedSessionStorageNamespaceConnectionInternal(uint64_t storageNamespaceID, CoreIPC::Connection* allowedConnection);
     void cloneSessionStorageNamespaceInternal(uint64_t storageNamespaceID, uint64_t newStorageNamespaceID);
 
+    void invalidateConnectionInternal(CoreIPC::Connection*);
+
     class StorageArea;
     StorageArea* findStorageArea(CoreIPC::Connection*, uint64_t) const;
 
@@ -77,7 +79,7 @@
     class SessionStorageNamespace;
     HashMap<uint64_t, RefPtr<SessionStorageNamespace> > m_sessionStorageNamespaces;
 
-    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> > m_storageAreas;
+    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> > m_storageAreasByConnection;
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to