Diff
Modified: trunk/Source/WebCore/ChangeLog (196518 => 196519)
--- trunk/Source/WebCore/ChangeLog 2016-02-12 23:01:20 UTC (rev 196518)
+++ trunk/Source/WebCore/ChangeLog 2016-02-12 23:16:57 UTC (rev 196519)
@@ -1,5 +1,38 @@
2016-02-12 Brady Eidson <beid...@apple.com>
+ Modern IDB: IDBObjectStore and IDBIndex need to be ActiveDOMObjects.
+ https://bugs.webkit.org/show_bug.cgi?id=154153
+
+ Reviewed by Alex Christensen.
+
+ No new tests (No testable change in behavior).
+
+ This is needed so that IDBObjectStore and IDBIndex JS wrappers are not garbage collected
+ while their IDBTransaction is still in progress.
+
+ * Modules/indexeddb/client/IDBIndexImpl.cpp:
+ (WebCore::IDBClient::IDBIndex::IDBIndex):
+ (WebCore::IDBClient::IDBIndex::activeDOMObjectName):
+ (WebCore::IDBClient::IDBIndex::canSuspendForDocumentSuspension):
+ (WebCore::IDBClient::IDBIndex::hasPendingActivity):
+ * Modules/indexeddb/client/IDBIndexImpl.h:
+
+ * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+ (WebCore::IDBClient::IDBObjectStore::create):
+ (WebCore::IDBClient::IDBObjectStore::IDBObjectStore):
+ (WebCore::IDBClient::IDBObjectStore::activeDOMObjectName):
+ (WebCore::IDBClient::IDBObjectStore::canSuspendForDocumentSuspension):
+ (WebCore::IDBClient::IDBObjectStore::hasPendingActivity):
+ (WebCore::IDBClient::IDBObjectStore::index):
+ * Modules/indexeddb/client/IDBObjectStoreImpl.h:
+
+ * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+ (WebCore::IDBClient::IDBTransaction::objectStore):
+ (WebCore::IDBClient::IDBTransaction::createObjectStore):
+ (WebCore::IDBClient::IDBTransaction::createIndex):
+
+2016-02-12 Brady Eidson <beid...@apple.com>
+
Modern IDB: Simplify the relationship between IDBObjectStore and IDBIndex.
https://bugs.webkit.org/show_bug.cgi?id=154187
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp (196518 => 196519)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp 2016-02-12 23:01:20 UTC (rev 196518)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp 2016-02-12 23:16:57 UTC (rev 196519)
@@ -41,16 +41,33 @@
namespace WebCore {
namespace IDBClient {
-IDBIndex::IDBIndex(const IDBIndexInfo& info, IDBObjectStore& objectStore)
- : m_info(info)
+IDBIndex::IDBIndex(ScriptExecutionContext* context, const IDBIndexInfo& info, IDBObjectStore& objectStore)
+ : ActiveDOMObject(context)
+ , m_info(info)
, m_objectStore(objectStore)
{
+ suspendIfNeeded();
}
IDBIndex::~IDBIndex()
{
}
+const char* IDBIndex::activeDOMObjectName() const
+{
+ return "IDBIndex";
+}
+
+bool IDBIndex::canSuspendForDocumentSuspension() const
+{
+ return false;
+}
+
+bool IDBIndex::hasPendingActivity() const
+{
+ return !m_objectStore.modernTransaction().isFinished();
+}
+
const String& IDBIndex::name() const
{
return m_info.name();
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h (196518 => 196519)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h 2016-02-12 23:01:20 UTC (rev 196518)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h 2016-02-12 23:16:57 UTC (rev 196519)
@@ -30,6 +30,7 @@
#if ENABLE(INDEXED_DATABASE)
+#include "ActiveDOMObject.h"
#include "IDBIndexInfo.h"
namespace WebCore {
@@ -40,9 +41,9 @@
class IDBObjectStore;
-class IDBIndex : public WebCore::IDBIndex {
+class IDBIndex : public WebCore::IDBIndex, public ActiveDOMObject {
public:
- IDBIndex(const IDBIndexInfo&, IDBObjectStore&);
+ IDBIndex(ScriptExecutionContext*, const IDBIndexInfo&, IDBObjectStore&);
virtual ~IDBIndex();
@@ -92,6 +93,11 @@
RefPtr<WebCore::IDBRequest> doGet(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
RefPtr<WebCore::IDBRequest> doGetKey(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
+ // ActiveDOMObject
+ virtual const char* activeDOMObjectName() const override final;
+ virtual bool canSuspendForDocumentSuspension() const override final;
+ virtual bool hasPendingActivity() const override final;
+
IDBIndexInfo m_info;
bool m_deleted { false };
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp (196518 => 196519)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp 2016-02-12 23:01:20 UTC (rev 196518)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp 2016-02-12 23:16:57 UTC (rev 196519)
@@ -46,22 +46,39 @@
namespace WebCore {
namespace IDBClient {
-Ref<IDBObjectStore> IDBObjectStore::create(const IDBObjectStoreInfo& info, IDBTransaction& transaction)
+Ref<IDBObjectStore> IDBObjectStore::create(ScriptExecutionContext* context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
{
- return adoptRef(*new IDBObjectStore(info, transaction));
+ return adoptRef(*new IDBObjectStore(context, info, transaction));
}
-IDBObjectStore::IDBObjectStore(const IDBObjectStoreInfo& info, IDBTransaction& transaction)
- : m_info(info)
+IDBObjectStore::IDBObjectStore(ScriptExecutionContext* context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
+ : ActiveDOMObject(context)
+ , m_info(info)
, m_originalInfo(info)
, m_transaction(transaction)
{
+ suspendIfNeeded();
}
IDBObjectStore::~IDBObjectStore()
{
}
+const char* IDBObjectStore::activeDOMObjectName() const
+{
+ return "IDBObjectStore";
+}
+
+bool IDBObjectStore::canSuspendForDocumentSuspension() const
+{
+ return false;
+}
+
+bool IDBObjectStore::hasPendingActivity() const
+{
+ return !m_transaction->isFinished();
+}
+
const String IDBObjectStore::name() const
{
return m_info.name();
@@ -500,6 +517,9 @@
{
LOG(IndexedDB, "IDBObjectStore::index");
+ if (!scriptExecutionContext())
+ return nullptr;
+
if (m_deleted) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'index' on 'IDBObjectStore': The object store has been deleted.");
@@ -524,7 +544,7 @@
return nullptr;
}
- auto index = std::make_unique<IDBIndex>(*info, *this);
+ auto index = std::make_unique<IDBIndex>(scriptExecutionContext(), *info, *this);
RefPtr<IDBIndex> refIndex = index.get();
m_referencedIndexes.set(indexName, WTFMove(index));
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h (196518 => 196519)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h 2016-02-12 23:01:20 UTC (rev 196518)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h 2016-02-12 23:16:57 UTC (rev 196519)
@@ -28,6 +28,7 @@
#if ENABLE(INDEXED_DATABASE)
+#include "ActiveDOMObject.h"
#include "IDBIndexImpl.h"
#include "IDBObjectStore.h"
#include "IDBObjectStoreInfo.h"
@@ -44,9 +45,9 @@
class IDBRequest;
class IDBTransaction;
-class IDBObjectStore : public WebCore::IDBObjectStore {
+class IDBObjectStore : public WebCore::IDBObjectStore, public ActiveDOMObject {
public:
- static Ref<IDBObjectStore> create(const IDBObjectStoreInfo&, IDBTransaction&);
+ static Ref<IDBObjectStore> create(ScriptExecutionContext*, const IDBObjectStoreInfo&, IDBTransaction&);
virtual ~IDBObjectStore() override final;
@@ -98,7 +99,7 @@
void visitReferencedIndexes(JSC::SlotVisitor&) const;
private:
- IDBObjectStore(const IDBObjectStoreInfo&, IDBTransaction&);
+ IDBObjectStore(ScriptExecutionContext*, const IDBObjectStoreInfo&, IDBTransaction&);
enum class InlineKeyCheck {
Perform,
@@ -109,6 +110,11 @@
RefPtr<WebCore::IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
RefPtr<IDBRequest> doDelete(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec);
+ // ActiveDOMObject
+ virtual const char* activeDOMObjectName() const override final;
+ virtual bool canSuspendForDocumentSuspension() const override final;
+ virtual bool hasPendingActivity() const override final;
+
IDBObjectStoreInfo m_info;
IDBObjectStoreInfo m_originalInfo;
Ref<IDBTransaction> m_transaction;
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (196518 => 196519)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2016-02-12 23:01:20 UTC (rev 196518)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2016-02-12 23:16:57 UTC (rev 196519)
@@ -127,6 +127,9 @@
{
LOG(IndexedDB, "IDBTransaction::objectStore");
+ if (!scriptExecutionContext())
+ return nullptr;
+
if (isFinishedOrFinishing()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'objectStore' on 'IDBTransaction': The transaction finished.");
@@ -159,7 +162,7 @@
return nullptr;
}
- auto objectStore = IDBObjectStore::create(*info, *this);
+ auto objectStore = IDBObjectStore::create(scriptExecutionContext(), *info, *this);
m_referencedObjectStores.set(objectStoreName, &objectStore.get());
return adoptRef(&objectStore.leakRef());
@@ -468,8 +471,9 @@
{
LOG(IndexedDB, "IDBTransaction::createObjectStore");
ASSERT(isVersionChange());
+ ASSERT(scriptExecutionContext());
- Ref<IDBObjectStore> objectStore = IDBObjectStore::create(info, *this);
+ Ref<IDBObjectStore> objectStore = IDBObjectStore::create(scriptExecutionContext(), info, *this);
m_referencedObjectStores.set(info.name(), &objectStore.get());
auto operation = createTransactionOperation(*this, &IDBTransaction::didCreateObjectStoreOnServer, &IDBTransaction::createObjectStoreOnServer, info);
@@ -499,10 +503,13 @@
LOG(IndexedDB, "IDBTransaction::createIndex");
ASSERT(isVersionChange());
+ if (!scriptExecutionContext())
+ return nullptr;
+
auto operation = createTransactionOperation(*this, &IDBTransaction::didCreateIndexOnServer, &IDBTransaction::createIndexOnServer, info);
scheduleOperation(WTFMove(operation));
- return std::make_unique<IDBIndex>(info, objectStore);
+ return std::make_unique<IDBIndex>(scriptExecutionContext(), info, objectStore);
}
void IDBTransaction::createIndexOnServer(TransactionOperation& operation, const IDBIndexInfo& info)