summaryrefslogtreecommitdiff
path: root/Source/WebCore/storage/StorageEventDispatcher.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/storage/StorageEventDispatcher.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/storage/StorageEventDispatcher.cpp')
-rw-r--r--Source/WebCore/storage/StorageEventDispatcher.cpp46
1 files changed, 22 insertions, 24 deletions
diff --git a/Source/WebCore/storage/StorageEventDispatcher.cpp b/Source/WebCore/storage/StorageEventDispatcher.cpp
index b4de9b857..ab89263d5 100644
--- a/Source/WebCore/storage/StorageEventDispatcher.cpp
+++ b/Source/WebCore/storage/StorageEventDispatcher.cpp
@@ -34,11 +34,13 @@
#include "Page.h"
#include "PageGroup.h"
#include "SecurityOrigin.h"
+#include "SecurityOriginData.h"
#include "StorageEvent.h"
+#include "StorageType.h"
namespace WebCore {
-void StorageEventDispatcher::dispatchSessionStorageEvents(const String& key, const String& oldValue, const String& newValue, SecurityOrigin* securityOrigin, Frame* sourceFrame)
+void StorageEventDispatcher::dispatchSessionStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOriginData& securityOrigin, Frame* sourceFrame)
{
Page* page = sourceFrame->page();
if (!page)
@@ -48,14 +50,14 @@ void StorageEventDispatcher::dispatchSessionStorageEvents(const String& key, con
// Send events only to our page.
for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (sourceFrame != frame && frame->document()->securityOrigin()->equal(securityOrigin))
+ if (sourceFrame != frame && frame->document()->securityOrigin().equal(securityOrigin.securityOrigin().ptr()))
frames.append(frame);
}
dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, sourceFrame->document()->url(), securityOrigin);
}
-void StorageEventDispatcher::dispatchLocalStorageEvents(const String& key, const String& oldValue, const String& newValue, SecurityOrigin* securityOrigin, Frame* sourceFrame)
+void StorageEventDispatcher::dispatchLocalStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOriginData& securityOrigin, Frame* sourceFrame)
{
Page* page = sourceFrame->page();
if (!page)
@@ -64,10 +66,9 @@ void StorageEventDispatcher::dispatchLocalStorageEvents(const String& key, const
Vector<RefPtr<Frame>> frames;
// Send events to every page.
- const HashSet<Page*>& pages = page->group().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()) {
- if (sourceFrame != frame && frame->document()->securityOrigin()->equal(securityOrigin))
+ for (auto& pageInGroup : page->group().pages()) {
+ for (Frame* frame = &pageInGroup->mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ if (sourceFrame != frame && frame->document()->securityOrigin().equal(securityOrigin.securityOrigin().ptr()))
frames.append(frame);
}
}
@@ -75,29 +76,26 @@ void StorageEventDispatcher::dispatchLocalStorageEvents(const String& key, const
dispatchLocalStorageEventsToFrames(page->group(), frames, key, oldValue, newValue, sourceFrame->document()->url(), securityOrigin);
}
-void StorageEventDispatcher::dispatchSessionStorageEventsToFrames(Page& page, const Vector<RefPtr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, SecurityOrigin* securityOrigin)
+void StorageEventDispatcher::dispatchSessionStorageEventsToFrames(Page& page, const Vector<RefPtr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOriginData& securityOrigin)
{
- InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, SessionStorage, securityOrigin, &page);
+ InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, StorageType::Session, securityOrigin.securityOrigin().ptr());
- for (unsigned i = 0; i < frames.size(); ++i) {
- ExceptionCode ec = 0;
- Storage* storage = frames[i]->document()->domWindow()->sessionStorage(ec);
- if (!ec)
- frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
+ for (auto& frame : frames) {
+ auto result = frame->document()->domWindow()->sessionStorage();
+ if (!result.hasException())
+ frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, result.releaseReturnValue()));
}
}
-void StorageEventDispatcher::dispatchLocalStorageEventsToFrames(PageGroup& pageGroup, const Vector<RefPtr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, SecurityOrigin* securityOrigin)
+void StorageEventDispatcher::dispatchLocalStorageEventsToFrames(PageGroup& pageGroup, const Vector<RefPtr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOriginData& securityOrigin)
{
- const HashSet<Page*>& pages = pageGroup.pages();
- for (HashSet<Page*>::const_iterator it = pages.begin(), end = pages.end(); it != end; ++it)
- InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStorage, securityOrigin, *it);
-
- for (unsigned i = 0; i < frames.size(); ++i) {
- ExceptionCode ec = 0;
- Storage* storage = frames[i]->document()->domWindow()->localStorage(ec);
- if (!ec)
- frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
+ for (auto& page : pageGroup.pages())
+ InspectorInstrumentation::didDispatchDOMStorageEvent(*page, key, oldValue, newValue, StorageType::Local, securityOrigin.securityOrigin().ptr());
+
+ for (auto& frame : frames) {
+ auto result = frame->document()->domWindow()->localStorage();
+ if (!result.hasException())
+ frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, result.releaseReturnValue()));
}
}