This source file includes following definitions.
- m_window
- supplementName
- from
- willDestroyGlobalObjectInFrame
- willDetachGlobalObjectFromFrame
- indexedDB
- indexedDB
#include "config.h"
#include "modules/indexeddb/DOMWindowIndexedDatabase.h"
#include "core/dom/Document.h"
#include "core/frame/DOMWindow.h"
#include "core/page/Page.h"
#include "modules/indexeddb/IDBFactory.h"
namespace WebCore {
DOMWindowIndexedDatabase::DOMWindowIndexedDatabase(DOMWindow& window)
: DOMWindowProperty(window.frame())
, m_window(window)
{
}
DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase()
{
}
const char* DOMWindowIndexedDatabase::supplementName()
{
return "DOMWindowIndexedDatabase";
}
DOMWindowIndexedDatabase& DOMWindowIndexedDatabase::from(DOMWindow& window)
{
DOMWindowIndexedDatabase* supplement = static_cast<DOMWindowIndexedDatabase*>(WillBeHeapSupplement<DOMWindow>::from(window, supplementName()));
if (!supplement) {
supplement = new DOMWindowIndexedDatabase(window);
provideTo(window, supplementName(), adoptPtrWillBeNoop(supplement));
}
return *supplement;
}
void DOMWindowIndexedDatabase::willDestroyGlobalObjectInFrame()
{
m_idbFactory = nullptr;
DOMWindowProperty::willDestroyGlobalObjectInFrame();
}
void DOMWindowIndexedDatabase::willDetachGlobalObjectFromFrame()
{
m_idbFactory = nullptr;
DOMWindowProperty::willDetachGlobalObjectFromFrame();
}
IDBFactory* DOMWindowIndexedDatabase::indexedDB(DOMWindow& window)
{
return from(window).indexedDB();
}
IDBFactory* DOMWindowIndexedDatabase::indexedDB()
{
Document* document = m_window.document();
if (!document)
return 0;
Page* page = document->page();
if (!page)
return 0;
if (!m_window.isCurrentlyDisplayedInFrame())
return 0;
if (!m_idbFactory)
m_idbFactory = IDBFactory::create(IDBFactoryBackendInterface::create().get());
return m_idbFactory.get();
}
}