Title: [148716] trunk/Source/WebKit2
Revision
148716
Author
ander...@apple.com
Date
2013-04-18 17:23:02 -0700 (Thu, 18 Apr 2013)

Log Message

Dispatch local storage events
https://bugs.webkit.org/show_bug.cgi?id=114838

Reviewed by Beth Dakin.

* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::StorageArea::dispatchEvents):
Pass 0 as the storage area ID if the event originally comes from another process.

* WebProcess/Storage/StorageAreaMap.cpp:
(WebKit::StorageAreaMap::dispatchLocalStorageEvent):
Gather all the frames for which we want to dispatch events.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (148715 => 148716)


--- trunk/Source/WebKit2/ChangeLog	2013-04-19 00:13:52 UTC (rev 148715)
+++ trunk/Source/WebKit2/ChangeLog	2013-04-19 00:23:02 UTC (rev 148716)
@@ -1,5 +1,20 @@
 2013-04-18  Anders Carlsson  <ander...@apple.com>
 
+        Dispatch local storage events
+        https://bugs.webkit.org/show_bug.cgi?id=114838
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/Storage/StorageManager.cpp:
+        (WebKit::StorageManager::StorageArea::dispatchEvents):
+        Pass 0 as the storage area ID if the event originally comes from another process.
+
+        * WebProcess/Storage/StorageAreaMap.cpp:
+        (WebKit::StorageAreaMap::dispatchLocalStorageEvent):
+        Gather all the frames for which we want to dispatch events.
+
+2013-04-18  Anders Carlsson  <ander...@apple.com>
+
         Use the page group id from the UI process as the local storage namespace ID
         https://bugs.webkit.org/show_bug.cgi?id=114836
 

Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (148715 => 148716)


--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp	2013-04-19 00:13:52 UTC (rev 148715)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp	2013-04-19 00:23:02 UTC (rev 148716)
@@ -170,8 +170,9 @@
 void StorageManager::StorageArea::dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const
 {
     for (HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t> >::const_iterator it = m_eventListeners.begin(), end = m_eventListeners.end(); it != end; ++it) {
-        // FIXME: If this is sent to another process, the source storage area ID will be bogus, since storage are IDs are per process.
-        it->first->send(Messages::StorageAreaMap::DispatchStorageEvent(sourceStorageAreaID, key, oldValue, newValue, urlString), it->second);
+        uint64_t storageAreaID = it->first == sourceConnection ? sourceStorageAreaID : 0;
+
+        it->first->send(Messages::StorageAreaMap::DispatchStorageEvent(storageAreaID, key, oldValue, newValue, urlString), it->second);
     }
 }
 

Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp (148715 => 148716)


--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp	2013-04-19 00:13:52 UTC (rev 148715)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp	2013-04-19 00:23:02 UTC (rev 148716)
@@ -32,10 +32,12 @@
 #include "StorageManagerMessages.h"
 #include "StorageNamespaceImpl.h"
 #include "WebPage.h"
+#include "WebPageGroupProxy.h"
 #include "WebProcess.h"
 #include <WebCore/DOMWindow.h>
 #include <WebCore/Frame.h>
 #include <WebCore/Page.h>
+#include <WebCore/PageGroup.h>
 #include <WebCore/Storage.h>
 #include <WebCore/StorageEventDispatcher.h>
 #include <WebCore/StorageMap.h>
@@ -228,10 +230,31 @@
 {
     ASSERT(storageType() == LocalStorage);
 
-    UNUSED_PARAM(key);
-    UNUSED_PARAM(oldValue);
-    UNUSED_PARAM(newValue);
-    UNUSED_PARAM(urlString);
+    Vector<RefPtr<Frame> > frames;
+
+    PageGroup& pageGroup = *WebProcess::shared().webPageGroup(m_storageNamespaceID)->corePageGroup();
+    const HashSet<Page*>& pages = pageGroup.pages();
+    for (HashSet<Page*>::const_iterator it = pages.begin(), end = pages.end(); it != end; ++it) {
+        for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+            Document* document = frame->document();
+            if (!document->securityOrigin()->equal(m_securityOrigin.get()))
+                continue;
+
+            Storage* storage = document->domWindow()->optionalLocalStorage();
+            if (!storage)
+                continue;
+
+            StorageAreaImpl* storageArea = static_cast<StorageAreaImpl*>(storage->area());
+            if (storageArea->storageAreaID() == sourceStorageAreaID) {
+                // This is the storage area that caused the event to be dispatched.
+                continue;
+            }
+
+            frames.append(frame);
+        }
+    }
+
+    StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin.get());
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to