summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp')
-rw-r--r--Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp b/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
index 75e7a66a6..803844156 100644
--- a/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
+++ b/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
@@ -29,11 +29,10 @@
#if ENABLE(INDEXED_DATABASE)
#include "DOMWindow.h"
+#include "DatabaseProvider.h"
#include "Document.h"
#include "IDBFactory.h"
#include "Page.h"
-#include "PageGroupIndexedDatabase.h"
-#include "SecurityOrigin.h"
namespace WebCore {
@@ -56,22 +55,23 @@ DOMWindowIndexedDatabase* DOMWindowIndexedDatabase::from(DOMWindow* window)
{
DOMWindowIndexedDatabase* supplement = static_cast<DOMWindowIndexedDatabase*>(Supplement<DOMWindow>::from(window, supplementName()));
if (!supplement) {
- supplement = new DOMWindowIndexedDatabase(window);
- provideTo(window, supplementName(), adoptPtr(supplement));
+ auto newSupplement = std::make_unique<DOMWindowIndexedDatabase>(window);
+ supplement = newSupplement.get();
+ provideTo(window, supplementName(), WTFMove(newSupplement));
}
return supplement;
}
-void DOMWindowIndexedDatabase::disconnectFrameForPageCache()
+void DOMWindowIndexedDatabase::disconnectFrameForDocumentSuspension()
{
- m_suspendedIDBFactory = m_idbFactory.release();
- DOMWindowProperty::disconnectFrameForPageCache();
+ m_suspendedIDBFactory = WTFMove(m_idbFactory);
+ DOMWindowProperty::disconnectFrameForDocumentSuspension();
}
-void DOMWindowIndexedDatabase::reconnectFrameFromPageCache(Frame* frame)
+void DOMWindowIndexedDatabase::reconnectFrameFromDocumentSuspension(Frame* frame)
{
- DOMWindowProperty::reconnectFrameFromPageCache(frame);
- m_idbFactory = m_suspendedIDBFactory.release();
+ DOMWindowProperty::reconnectFrameFromDocumentSuspension(frame);
+ m_idbFactory = WTFMove(m_suspendedIDBFactory);
}
void DOMWindowIndexedDatabase::willDestroyGlobalObjectInCachedFrame()
@@ -92,26 +92,32 @@ void DOMWindowIndexedDatabase::willDetachGlobalObjectFromFrame()
DOMWindowProperty::willDetachGlobalObjectFromFrame();
}
-IDBFactory* DOMWindowIndexedDatabase::indexedDB(DOMWindow* window)
+IDBFactory* DOMWindowIndexedDatabase::indexedDB(DOMWindow& window)
{
- return from(window)->indexedDB();
+ return from(&window)->indexedDB();
}
IDBFactory* DOMWindowIndexedDatabase::indexedDB()
{
Document* document = m_window->document();
if (!document)
- return 0;
+ return nullptr;
Page* page = document->page();
if (!page)
- return 0;
+ return nullptr;
if (!m_window->isCurrentlyDisplayedInFrame())
- return 0;
+ return nullptr;
+
+ if (!m_idbFactory) {
+ auto* connectionProxy = document->idbConnectionProxy();
+ if (!connectionProxy)
+ return nullptr;
+
+ m_idbFactory = IDBFactory::create(*connectionProxy);
+ }
- if (!m_idbFactory)
- m_idbFactory = IDBFactory::create(PageGroupIndexedDatabase::from(page->group())->factoryBackend());
return m_idbFactory.get();
}