diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
commit | 881da28418d380042aa95a97f0cbd42560a64f7c (patch) | |
tree | a794dff3274695e99c651902dde93d934ea7a5af /Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp | |
parent | 7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff) | |
parent | 0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff) | |
download | qtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz |
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp | 72 |
1 files changed, 43 insertions, 29 deletions
diff --git a/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp b/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp index dd8f14ac7..6b24cf473 100644 --- a/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp +++ b/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "StorageAreaMap.h" -#include "SecurityOriginData.h" #include "StorageAreaImpl.h" #include "StorageAreaMapMessages.h" #include "StorageManagerMessages.h" @@ -35,9 +34,11 @@ #include "WebPageGroupProxy.h" #include "WebProcess.h" #include <WebCore/DOMWindow.h> -#include <WebCore/Frame.h> +#include <WebCore/Document.h> +#include <WebCore/MainFrame.h> #include <WebCore/Page.h> #include <WebCore/PageGroup.h> +#include <WebCore/SecurityOriginData.h> #include <WebCore/Storage.h> #include <WebCore/StorageEventDispatcher.h> #include <WebCore/StorageMap.h> @@ -52,32 +53,45 @@ static uint64_t generateStorageMapID() return ++storageMapID; } -PassRefPtr<StorageAreaMap> StorageAreaMap::create(StorageNamespaceImpl* storageNamespace, PassRefPtr<WebCore::SecurityOrigin> securityOrigin) +Ref<StorageAreaMap> StorageAreaMap::create(StorageNamespaceImpl* storageNamespace, Ref<WebCore::SecurityOrigin>&& securityOrigin) { - return adoptRef(new StorageAreaMap(storageNamespace, securityOrigin)); + return adoptRef(*new StorageAreaMap(storageNamespace, WTFMove(securityOrigin))); } -StorageAreaMap::StorageAreaMap(StorageNamespaceImpl* storageNamespace, PassRefPtr<WebCore::SecurityOrigin> securityOrigin) - : m_storageMapID(generateStorageMapID()) +StorageAreaMap::StorageAreaMap(StorageNamespaceImpl* storageNamespace, Ref<WebCore::SecurityOrigin>&& securityOrigin) + : m_storageNamespace(*storageNamespace) + , m_storageMapID(generateStorageMapID()) , m_storageType(storageNamespace->storageType()) , m_storageNamespaceID(storageNamespace->storageNamespaceID()) , m_quotaInBytes(storageNamespace->quotaInBytes()) - , m_securityOrigin(securityOrigin) + , m_securityOrigin(WTFMove(securityOrigin)) , m_currentSeed(0) , m_hasPendingClear(false) , m_hasPendingGetValues(false) { - if (m_storageType == LocalStorage) - WebProcess::shared().parentProcessConnection()->send(Messages::StorageManager::CreateLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin.get())), 0); - else - WebProcess::shared().parentProcessConnection()->send(Messages::StorageManager::CreateSessionStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin.get())), 0); - WebProcess::shared().addMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID, this); + switch (m_storageType) { + case WebCore::LocalStorage: + if (SecurityOrigin* topLevelOrigin = storageNamespace->topLevelOrigin()) + WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateTransientLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(*topLevelOrigin), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0); + else + WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0); + + break; + + case WebCore::SessionStorage: + WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateSessionStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0); + break; + } + + WebProcess::singleton().addMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID, *this); } StorageAreaMap::~StorageAreaMap() { - WebProcess::shared().parentProcessConnection()->send(Messages::StorageManager::DestroyStorageMap(m_storageMapID), 0); - WebProcess::shared().removeMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID); + WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::DestroyStorageMap(m_storageMapID), 0); + WebProcess::singleton().removeMessageReceiver(Messages::StorageAreaMap::messageReceiverName(), m_storageMapID); + + m_storageNamespace->didDestroyStorageAreaMap(*this); } unsigned StorageAreaMap::length() @@ -118,7 +132,7 @@ void StorageAreaMap::setItem(Frame* sourceFrame, StorageAreaImpl* sourceArea, co m_pendingValueChanges.add(key); - WebProcess::shared().parentProcessConnection()->send(Messages::StorageManager::SetItem(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, key, value, sourceFrame->document()->url()), 0); + WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::SetItem(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, key, value, sourceFrame->document()->url()), 0); } void StorageAreaMap::removeItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key) @@ -134,7 +148,7 @@ void StorageAreaMap::removeItem(WebCore::Frame* sourceFrame, StorageAreaImpl* so m_pendingValueChanges.add(key); - WebProcess::shared().parentProcessConnection()->send(Messages::StorageManager::RemoveItem(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, key, sourceFrame->document()->url()), 0); + WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::RemoveItem(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, key, sourceFrame->document()->url()), 0); } void StorageAreaMap::clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea) @@ -143,7 +157,7 @@ void StorageAreaMap::clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceA m_hasPendingClear = true; m_storageMap = StorageMap::create(m_quotaInBytes); - WebProcess::shared().parentProcessConnection()->send(Messages::StorageManager::Clear(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, sourceFrame->document()->url()), 0); + WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::Clear(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, sourceFrame->document()->url()), 0); } bool StorageAreaMap::contains(const String& key) @@ -172,7 +186,7 @@ void StorageAreaMap::loadValuesIfNeeded() // FIXME: This should use a special sendSync flag to indicate that we don't want to process incoming messages while waiting for a reply. // (This flag does not yet exist). Since loadValuesIfNeeded() ends up being called from within JavaScript code, processing incoming synchronous messages // could lead to weird reentrency bugs otherwise. - WebProcess::shared().parentProcessConnection()->sendSync(Messages::StorageManager::GetValues(m_storageMapID, m_currentSeed), Messages::StorageManager::GetValues::Reply(values), 0); + WebProcess::singleton().parentProcessConnection()->sendSync(Messages::StorageManager::GetValues(m_storageMapID, m_currentSeed), Messages::StorageManager::GetValues::Reply(values), 0); m_storageMap = StorageMap::create(m_quotaInBytes); m_storageMap->importItems(values); @@ -251,7 +265,7 @@ void StorageAreaMap::applyChange(const String& key, const String& newValue) RefPtr<StorageMap> newStorageMap = StorageMap::create(m_quotaInBytes); // Any changes that were made locally after the clear must still be kept around in the new map. - for (HashCountedSet<String>::iterator::Keys it = m_pendingValueChanges.begin().keys(), end = m_pendingValueChanges.end().keys(); it != end; ++it) { + for (auto it = m_pendingValueChanges.begin().keys(), end = m_pendingValueChanges.end().keys(); it != end; ++it) { const String& key = *it; String value = m_storageMap->getItem(key); @@ -305,16 +319,16 @@ void StorageAreaMap::dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, c // Namespace IDs for session storage namespaces are equivalent to web page IDs // so we can get the right page here. - WebPage* webPage = WebProcess::shared().webPage(m_storageNamespaceID); + WebPage* webPage = WebProcess::singleton().webPage(m_storageNamespaceID); if (!webPage) return; - Vector<RefPtr<Frame> > frames; + Vector<RefPtr<Frame>> frames; Page* page = webPage->corePage(); - for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) { + for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) { Document* document = frame->document(); - if (!document->securityOrigin()->equal(m_securityOrigin.get())) + if (!document->securityOrigin()->equal(m_securityOrigin.ptr())) continue; Storage* storage = document->domWindow()->optionalSessionStorage(); @@ -330,21 +344,21 @@ void StorageAreaMap::dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, c frames.append(frame); } - StorageEventDispatcher::dispatchLocalStorageEventsToFrames(page->group(), frames, key, oldValue, newValue, urlString, m_securityOrigin.get()); + StorageEventDispatcher::dispatchLocalStorageEventsToFrames(page->group(), frames, key, oldValue, newValue, urlString, m_securityOrigin.ptr()); } void StorageAreaMap::dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) { ASSERT(storageType() == LocalStorage); - Vector<RefPtr<Frame> > frames; + Vector<RefPtr<Frame>> frames; - PageGroup& pageGroup = *WebProcess::shared().webPageGroup(m_storageNamespaceID)->corePageGroup(); + PageGroup& pageGroup = *WebProcess::singleton().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()) { + for (Frame* frame = &(*it)->mainFrame(); frame; frame = frame->tree().traverseNext()) { Document* document = frame->document(); - if (!document->securityOrigin()->equal(m_securityOrigin.get())) + if (!document->securityOrigin()->equal(m_securityOrigin.ptr())) continue; Storage* storage = document->domWindow()->optionalLocalStorage(); @@ -361,7 +375,7 @@ void StorageAreaMap::dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, con } } - StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin.get()); + StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin.ptr()); } } // namespace WebKit |