Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (196481 => 196482)
--- trunk/Source/WebCore/CMakeLists.txt 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-02-12 18:30:43 UTC (rev 196482)
@@ -1180,6 +1180,7 @@
bindings/js/JSIDBCursorCustom.cpp
bindings/js/JSIDBCursorWithValueCustom.cpp
bindings/js/JSIDBDatabaseCustom.cpp
+ bindings/js/JSIDBIndexCustom.cpp
bindings/js/JSIDBObjectStoreCustom.cpp
bindings/js/JSImageConstructor.cpp
bindings/js/JSImageDataCustom.cpp
Modified: trunk/Source/WebCore/ChangeLog (196481 => 196482)
--- trunk/Source/WebCore/ChangeLog 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/ChangeLog 2016-02-12 18:30:43 UTC (rev 196482)
@@ -1,3 +1,73 @@
+2016-02-12 Brady Eidson <[email protected]>
+
+ Modern IDB: Ref cycle between IDBObjectStore and IDBIndex.
+ https://bugs.webkit.org/show_bug.cgi?id=154110
+
+ Reviewed by Darin Adler.
+
+ No new tests (Currently untestable).
+
+ The lifetime of IDBObjectStore and IDBIndex are closely intertwined, but we have to break the ref cycle.
+
+ This patch does a few semi-gnarly things:
+ 1 - Makes both IDBIndex and IDBObjectStore have a custom marking function so they can add each other as
+ opaque roots.
+ 2 - Adds a lock to protect IDBObjectStore's collection of referenced indexes to support #1, as GC marking
+ can happen on any thread.
+ 3 - Makes IDBIndex not be traditionally RefCounted; Instead, IDBIndex::ref()/deref() simply ref()/deref()
+ the owning IDBObjectStore.
+ 4 - ...Except when somebody deletes an IDBIndex from its IDBObjectStore. Once that happens, the object
+ store no longer has a reference back to the index, but the index still needs a reference back to the
+ object store. To support this, the IDBIndex becomes "traditionally RefCounted" while holding a ref to
+ its IDBObjectStore.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ * Modules/indexeddb/IDBIndex.h:
+ (WebCore::IDBIndex::isModern):
+ * Modules/indexeddb/IDBIndex.idl:
+
+ * Modules/indexeddb/IDBObjectStore.h:
+ (WebCore::IDBObjectStore::isModern):
+ * Modules/indexeddb/IDBObjectStore.idl:
+
+ * Modules/indexeddb/client/IDBIndexImpl.cpp:
+ (WebCore::IDBClient::IDBIndex::objectStore):
+ (WebCore::IDBClient::IDBIndex::openCursor):
+ (WebCore::IDBClient::IDBIndex::doCount):
+ (WebCore::IDBClient::IDBIndex::openKeyCursor):
+ (WebCore::IDBClient::IDBIndex::doGet):
+ (WebCore::IDBClient::IDBIndex::doGetKey):
+ (WebCore::IDBClient::IDBIndex::markAsDeleted):
+ (WebCore::IDBClient::IDBIndex::ref):
+ (WebCore::IDBClient::IDBIndex::deref):
+ (WebCore::IDBClient::IDBIndex::create): Deleted.
+ * Modules/indexeddb/client/IDBIndexImpl.h:
+ (WebCore::IDBClient::IDBIndex::modernObjectStore):
+
+ * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+ (WebCore::IDBClient::IDBObjectStore::createIndex):
+ (WebCore::IDBClient::IDBObjectStore::index):
+ (WebCore::IDBClient::IDBObjectStore::deleteIndex):
+ (WebCore::IDBClient::IDBObjectStore::visitReferencedIndexes):
+ * Modules/indexeddb/client/IDBObjectStoreImpl.h:
+
+ * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+ (WebCore::IDBClient::IDBTransaction::createIndex):
+ * Modules/indexeddb/client/IDBTransactionImpl.h:
+
+ * Modules/indexeddb/legacy/LegacyIndex.cpp:
+ (WebCore::LegacyIndex::ref):
+ (WebCore::LegacyIndex::deref):
+ * Modules/indexeddb/legacy/LegacyIndex.h:
+
+ * bindings/js/JSIDBIndexCustom.cpp: Added.
+ (WebCore::JSIDBIndex::visitAdditionalChildren):
+
+ * bindings/js/JSIDBObjectStoreCustom.cpp:
+ (WebCore::JSIDBObjectStore::visitAdditionalChildren):
+
2016-02-12 Csaba Osztrogonác <[email protected]>
[EFL][GTK] Fix ENABLE(SVG_OTF_CONVERTER) build
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h 2016-02-12 18:30:43 UTC (rev 196482)
@@ -43,7 +43,7 @@
class IDBObjectStore;
-class IDBIndex : public RefCounted<IDBIndex> {
+class IDBIndex {
public:
virtual ~IDBIndex() { }
@@ -77,6 +77,14 @@
virtual RefPtr<IDBRequest> getKey(ScriptExecutionContext*, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
virtual RefPtr<IDBRequest> getKey(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
+ virtual bool isModern() const { return false; }
+
+ // We use our own ref/deref function because Legacy IDB and Modern IDB have very different
+ // lifetime management of their indexes.
+ // This will go away once Legacy IDB is dropped.
+ virtual void ref() = 0;
+ virtual void deref() = 0;
+
protected:
IDBIndex();
};
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBIndex.idl (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/IDBIndex.idl 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBIndex.idl 2016-02-12 18:30:43 UTC (rev 196482)
@@ -27,6 +27,8 @@
Conditional=INDEXED_DATABASE,
EnabledAtRuntime=IndexedDB,
SkipVTableValidation,
+ JSCustomMarkFunction,
+ GenerateIsReachable=Impl,
] interface IDBIndex {
readonly attribute DOMString name;
readonly attribute IDBObjectStore objectStore;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h 2016-02-12 18:30:43 UTC (rev 196482)
@@ -92,6 +92,8 @@
virtual RefPtr<IDBRequest> count(ScriptExecutionContext*, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
virtual RefPtr<IDBRequest> count(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
+ virtual bool isModern() const { return false; }
+
protected:
IDBObjectStore();
};
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl 2016-02-12 18:30:43 UTC (rev 196482)
@@ -27,6 +27,8 @@
Conditional=INDEXED_DATABASE,
EnabledAtRuntime=IndexedDB,
SkipVTableValidation,
+ JSCustomMarkFunction,
+ GenerateIsReachable=Impl,
] interface IDBObjectStore {
[TreatReturnedNullStringAs=Null] readonly attribute DOMString name;
[ImplementedAs=keyPathAny] readonly attribute IDBAny keyPath;
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp 2016-02-12 18:30:43 UTC (rev 196482)
@@ -41,11 +41,6 @@
namespace WebCore {
namespace IDBClient {
-Ref<IDBIndex> IDBIndex::create(const IDBIndexInfo& info, IDBObjectStore& objectStore)
-{
- return adoptRef(*new IDBIndex(info, objectStore));
-}
-
IDBIndex::IDBIndex(const IDBIndexInfo& info, IDBObjectStore& objectStore)
: m_info(info)
, m_objectStore(objectStore)
@@ -63,7 +58,7 @@
RefPtr<WebCore::IDBObjectStore> IDBIndex::objectStore()
{
- return &m_objectStore.get();
+ return &m_objectStore;
}
RefPtr<WebCore::IDBAny> IDBIndex::keyPathAny() const
@@ -90,13 +85,13 @@
{
LOG(IndexedDB, "IDBIndex::openCursor");
- if (m_deleted || m_objectStore->isDeleted()) {
+ if (m_deleted || m_objectStore.isDeleted()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The index or its object store has been deleted.");
return nullptr;
}
- if (!m_objectStore->modernTransaction().isActive()) {
+ if (!m_objectStore.modernTransaction().isActive()) {
ec.code = IDBDatabaseException::TransactionInactiveError;
ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The transaction is inactive or finished.");
return nullptr;
@@ -114,9 +109,8 @@
if (rangeData.upperKey.isNull())
rangeData.upperKey = IDBKeyData::maximum();
- auto info = IDBCursorInfo::indexCursor(m_objectStore->modernTransaction(), m_objectStore->info().identifier(), m_info.identifier(), rangeData, direction, IndexedDB::CursorType::KeyAndValue);
- Ref<IDBRequest> request = m_objectStore->modernTransaction().requestOpenCursor(*context, *this, info);
- return WTFMove(request);
+ auto info = IDBCursorInfo::indexCursor(m_objectStore.modernTransaction(), m_objectStore.info().identifier(), m_info.identifier(), rangeData, direction, IndexedDB::CursorType::KeyAndValue);
+ return m_objectStore.modernTransaction().requestOpenCursor(*context, *this, info);
}
RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec)
@@ -177,7 +171,7 @@
RefPtr<WebCore::IDBRequest> IDBIndex::doCount(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
{
- if (m_deleted || m_objectStore->isDeleted()) {
+ if (m_deleted || m_objectStore.isDeleted()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The index or its object store has been deleted.");
return nullptr;
@@ -188,7 +182,7 @@
return nullptr;
}
- auto& transaction = m_objectStore->modernTransaction();
+ auto& transaction = m_objectStore.modernTransaction();
if (!transaction.isActive()) {
ec.code = IDBDatabaseException::TransactionInactiveError;
ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The transaction is inactive or finished.");
@@ -202,13 +196,13 @@
{
LOG(IndexedDB, "IDBIndex::openKeyCursor");
- if (m_deleted || m_objectStore->isDeleted()) {
+ if (m_deleted || m_objectStore.isDeleted()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The index or its object store has been deleted.");
return nullptr;
}
- if (!m_objectStore->modernTransaction().isActive()) {
+ if (!m_objectStore.modernTransaction().isActive()) {
ec.code = IDBDatabaseException::TransactionInactiveError;
ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The transaction is inactive or finished.");
return nullptr;
@@ -220,9 +214,8 @@
return nullptr;
}
- auto info = IDBCursorInfo::indexCursor(m_objectStore->modernTransaction(), m_objectStore->info().identifier(), m_info.identifier(), range, direction, IndexedDB::CursorType::KeyOnly);
- Ref<IDBRequest> request = m_objectStore->modernTransaction().requestOpenCursor(*context, *this, info);
- return WTFMove(request);
+ auto info = IDBCursorInfo::indexCursor(m_objectStore.modernTransaction(), m_objectStore.info().identifier(), m_info.identifier(), range, direction, IndexedDB::CursorType::KeyOnly);
+ return m_objectStore.modernTransaction().requestOpenCursor(*context, *this, info);
}
RefPtr<WebCore::IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec)
@@ -270,7 +263,7 @@
RefPtr<WebCore::IDBRequest> IDBIndex::doGet(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
{
- if (m_deleted || m_objectStore->isDeleted()) {
+ if (m_deleted || m_objectStore.isDeleted()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The index or its object store has been deleted.");
return nullptr;
@@ -281,7 +274,7 @@
return nullptr;
}
- auto& transaction = m_objectStore->modernTransaction();
+ auto& transaction = m_objectStore.modernTransaction();
if (!transaction.isActive()) {
ec.code = IDBDatabaseException::TransactionInactiveError;
ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The transaction is inactive or finished.");
@@ -325,7 +318,7 @@
RefPtr<WebCore::IDBRequest> IDBIndex::doGetKey(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
{
- if (m_deleted || m_objectStore->isDeleted()) {
+ if (m_deleted || m_objectStore.isDeleted()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The index or its object store has been deleted.");
return nullptr;
@@ -336,7 +329,7 @@
return nullptr;
}
- auto& transaction = m_objectStore->modernTransaction();
+ auto& transaction = m_objectStore.modernTransaction();
if (!transaction.isActive()) {
ec.code = IDBDatabaseException::TransactionInactiveError;
ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The transaction is inactive or finished.");
@@ -346,11 +339,51 @@
return transaction.requestGetKey(context, *this, range);
}
-void IDBIndex::markAsDeleted()
+void IDBIndex::markAsDeleted(std::unique_ptr<IDBIndex>&& indexOwner)
{
+ ASSERT(!m_deleted);
+ ASSERT(!m_selfOwner);
+ ASSERT(indexOwner.get() == this);
+
+ // If nobody was keeping a ref to this IDBIndex while under IDBObjectStore ownership,
+ // it can be deleted now by letting indexOwner go out of scope.
+ if (!m_refCount)
+ return;
+
+ m_selfOwner = WTFMove(indexOwner);
+
+ // Now that the IDBIndex is managing its own lifetime, it must ref() its IDBObjectStore to keep it alive.
+ m_objectStoreRef = &m_objectStore;
+
+ // It must undo all of the refs it had previously given its IDBObjectStore when the lifetimes were intertwined.
+ for (unsigned i = m_refCount; i > 0; --i)
+ m_objectStore.deref();
+
m_deleted = true;
}
+void IDBIndex::ref()
+{
+ ++m_refCount;
+
+ if (!m_deleted)
+ m_objectStore.ref();
+}
+
+void IDBIndex::deref()
+{
+ --m_refCount;
+
+ if (!m_deleted)
+ m_objectStore.deref();
+ else {
+ // This IDBIndex has been detached from its IDBObjectStore so if its RefCount
+ // just went to 0 it should be destroyed.
+ if (!m_refCount)
+ m_selfOwner = nullptr;
+ }
+}
+
} // namespace IDBClient
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h 2016-02-12 18:30:43 UTC (rev 196482)
@@ -42,7 +42,7 @@
class IDBIndex : public WebCore::IDBIndex {
public:
- static Ref<IDBIndex> create(const IDBIndexInfo&, IDBObjectStore&);
+ IDBIndex(const IDBIndexInfo&, IDBObjectStore&);
virtual ~IDBIndex();
@@ -77,22 +77,38 @@
const IDBIndexInfo& info() const { return m_info; }
- IDBObjectStore& modernObjectStore() { return m_objectStore.get(); }
+ IDBObjectStore& modernObjectStore() { return m_objectStore; }
- void markAsDeleted();
+ void markAsDeleted(std::unique_ptr<IDBIndex>&&);
bool isDeleted() const { return m_deleted; }
+ virtual bool isModern() const override { return true; }
+
+ void ref() override;
+ void deref() override;
+
private:
- IDBIndex(const IDBIndexInfo&, IDBObjectStore&);
-
RefPtr<WebCore::IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
RefPtr<WebCore::IDBRequest> doGet(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
RefPtr<WebCore::IDBRequest> doGetKey(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
IDBIndexInfo m_info;
- Ref<IDBObjectStore> m_objectStore;
bool m_deleted { false };
+
+ // Most of the time, an IDBObjectStore owns an IDBIndex through a std::unique_ptr.
+ // In that scenario, attempts to ref() the IDBIndex directly ref the IDBObjectStore, so it is okay to
+ // keep a raw reference to the IDBObjectStore because it will always outlive the IDBIndex.
+ IDBObjectStore& m_objectStore;
+
+ // But when an IDBIndex is deleted from its IDBObjectStore that lifetime is no longer guaranteed.
+ // The IDBObjectStore no longer owns the IDBIndex, so the following needs to change:
+ // 1 - The IDBIndex must directly ref its IDBObjectStore to keep it alive.
+ // 2 - The IDBIndex becomes traditionally RefCounted.
+ // 2 - The IDBIndex holds its own std::unique_ptr, which it will clear out when its RefCount reaches 0.
+ RefPtr<IDBObjectStore> m_objectStoreRef;
+ unsigned m_refCount { 0 };
+ std::unique_ptr<IDBIndex> m_selfOwner;
};
} // namespace IDBClient
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp 2016-02-12 18:30:43 UTC (rev 196482)
@@ -41,6 +41,7 @@
#include "IndexedDB.h"
#include "Logging.h"
#include "SerializedScriptValue.h"
+#include <wtf/Locker.h>
namespace WebCore {
namespace IDBClient {
@@ -486,10 +487,13 @@
m_transaction->database().didCreateIndexInfo(info);
// Create the actual IDBObjectStore from the transaction, which also schedules the operation server side.
- Ref<IDBIndex> index = m_transaction->createIndex(*this, info);
- m_referencedIndexes.set(name, &index.get());
+ auto index = m_transaction->createIndex(*this, info);
+ RefPtr<IDBIndex> refIndex = index.get();
- return WTFMove(index);
+ Locker<Lock> locker(m_referencedIndexLock);
+ m_referencedIndexes.set(name, WTFMove(index));
+
+ return WTFMove(refIndex);
}
RefPtr<WebCore::IDBIndex> IDBObjectStore::index(const String& indexName, ExceptionCodeWithMessage& ec)
@@ -508,9 +512,10 @@
return nullptr;
}
+ Locker<Lock> locker(m_referencedIndexLock);
auto iterator = m_referencedIndexes.find(indexName);
if (iterator != m_referencedIndexes.end())
- return iterator->value;
+ return iterator->value.get();
auto* info = m_info.infoForExistingIndex(indexName);
if (!info) {
@@ -519,10 +524,11 @@
return nullptr;
}
- auto index = IDBIndex::create(*info, *this);
- m_referencedIndexes.set(indexName, &index.get());
+ auto index = std::make_unique<IDBIndex>(*info, *this);
+ RefPtr<IDBIndex> refIndex = index.get();
+ m_referencedIndexes.set(indexName, WTFMove(index));
- return WTFMove(index);
+ return refIndex;
}
void IDBObjectStore::deleteIndex(const String& name, ExceptionCodeWithMessage& ec)
@@ -559,8 +565,11 @@
m_info.deleteIndex(name);
- if (auto index = m_referencedIndexes.take(name))
- index->markAsDeleted();
+ {
+ Locker<Lock> locker(m_referencedIndexLock);
+ if (auto index = m_referencedIndexes.take(name))
+ index->markAsDeleted(WTFMove(index));
+ }
m_transaction->deleteIndex(m_info.identifier(), name);
}
@@ -646,6 +655,13 @@
m_info = m_originalInfo;
}
+void IDBObjectStore::visitReferencedIndexes(JSC::SlotVisitor& visitor) const
+{
+ Locker<Lock> locker(m_referencedIndexLock);
+ for (auto& index : m_referencedIndexes.values())
+ visitor.addOpaqueRoot(index.get());
+}
+
} // namespace IDBClient
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h 2016-02-12 18:30:43 UTC (rev 196482)
@@ -93,6 +93,10 @@
void rollbackInfoForVersionChangeAbort();
+ virtual bool isModern() const override { return true; }
+
+ void visitReferencedIndexes(JSC::SlotVisitor&) const;
+
private:
IDBObjectStore(const IDBObjectStoreInfo&, IDBTransaction&);
@@ -111,7 +115,8 @@
bool m_deleted { false };
- HashMap<String, RefPtr<IDBIndex>> m_referencedIndexes;
+ mutable Lock m_referencedIndexLock;
+ HashMap<String, std::unique_ptr<IDBIndex>> m_referencedIndexes;
};
} // namespace IDBClient
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2016-02-12 18:30:43 UTC (rev 196482)
@@ -494,17 +494,15 @@
ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::CreateObjectStoreSuccess || resultData.type() == IDBResultType::Error);
}
-Ref<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStore, const IDBIndexInfo& info)
+std::unique_ptr<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStore, const IDBIndexInfo& info)
{
LOG(IndexedDB, "IDBTransaction::createIndex");
ASSERT(isVersionChange());
- Ref<IDBIndex> index = IDBIndex::create(info, objectStore);
-
auto operation = createTransactionOperation(*this, &IDBTransaction::didCreateIndexOnServer, &IDBTransaction::createIndexOnServer, info);
scheduleOperation(WTFMove(operation));
- return index;
+ return std::make_unique<IDBIndex>(info, objectStore);
}
void IDBTransaction::createIndexOnServer(TransactionOperation& operation, const IDBIndexInfo& info)
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h 2016-02-12 18:30:43 UTC (rev 196482)
@@ -97,7 +97,7 @@
bool isActive() const;
Ref<IDBObjectStore> createObjectStore(const IDBObjectStoreInfo&);
- Ref<IDBIndex> createIndex(IDBObjectStore&, const IDBIndexInfo&);
+ std::unique_ptr<IDBIndex> createIndex(IDBObjectStore&, const IDBIndexInfo&);
Ref<IDBRequest> requestPutOrAdd(ScriptExecutionContext&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
Ref<IDBRequest> requestGetRecord(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyIndex.cpp (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyIndex.cpp 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyIndex.cpp 2016-02-12 18:30:43 UTC (rev 196482)
@@ -54,6 +54,19 @@
{
}
+void LegacyIndex::ref()
+{
+ ++m_refCount;
+}
+
+void LegacyIndex::deref()
+{
+ if (--m_refCount)
+ return;
+
+ delete this;
+}
+
RefPtr<IDBRequest> LegacyIndex::openCursor(ScriptExecutionContext* context, IDBKeyRange* keyRange, const String& directionString, ExceptionCodeWithMessage& ec)
{
LOG(StorageAPI, "LegacyIndex::openCursor");
Modified: trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyIndex.h (196481 => 196482)
--- trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyIndex.h 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyIndex.h 2016-02-12 18:30:43 UTC (rev 196482)
@@ -89,6 +89,9 @@
IDBDatabaseBackend* backendDB() const;
+ virtual void ref() override;
+ virtual void deref() override;
+
private:
LegacyIndex(const IDBIndexMetadata&, LegacyObjectStore*, LegacyTransaction*);
@@ -96,6 +99,8 @@
RefPtr<LegacyObjectStore> m_objectStore;
RefPtr<LegacyTransaction> m_transaction;
bool m_deleted;
+
+ unsigned m_refCount { 1 };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (196481 => 196482)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-02-12 18:30:43 UTC (rev 196482)
@@ -1981,6 +1981,7 @@
514129901C601ACC0059E714 /* ScopeGuard.h in Headers */ = {isa = PBXBuildFile; fileRef = 5141298F1C601A890059E714 /* ScopeGuard.h */; settings = {ATTRIBUTES = (Private, ); }; };
514129981C6976900059E714 /* IDBRequestCompletionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514129961C6976150059E714 /* IDBRequestCompletionEvent.cpp */; };
514129991C6976900059E714 /* IDBRequestCompletionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 514129971C6976150059E714 /* IDBRequestCompletionEvent.h */; };
+ 5141299B1C6C16740059E714 /* JSIDBIndexCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5141299A1C6C166D0059E714 /* JSIDBIndexCustom.cpp */; };
5145B1091BC48E2E00E86219 /* IDBResourceIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5145B1071BC4890B00E86219 /* IDBResourceIdentifier.cpp */; };
5145B10A1BC48E2E00E86219 /* IDBResourceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 5145B1081BC4890B00E86219 /* IDBResourceIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
5148453E1BB9D07E006A72ED /* IDBError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5148453C1BB9D076006A72ED /* IDBError.cpp */; };
@@ -9489,6 +9490,7 @@
5141298F1C601A890059E714 /* ScopeGuard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopeGuard.h; sourceTree = "<group>"; };
514129961C6976150059E714 /* IDBRequestCompletionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBRequestCompletionEvent.cpp; sourceTree = "<group>"; };
514129971C6976150059E714 /* IDBRequestCompletionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBRequestCompletionEvent.h; sourceTree = "<group>"; };
+ 5141299A1C6C166D0059E714 /* JSIDBIndexCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBIndexCustom.cpp; sourceTree = "<group>"; };
5145B1071BC4890B00E86219 /* IDBResourceIdentifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBResourceIdentifier.cpp; sourceTree = "<group>"; };
5145B1081BC4890B00E86219 /* IDBResourceIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBResourceIdentifier.h; sourceTree = "<group>"; };
5148453C1BB9D076006A72ED /* IDBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBError.cpp; sourceTree = "<group>"; };
@@ -22352,6 +22354,7 @@
512BDB4C1C46B0FF006494DF /* JSIDBCursorCustom.cpp */,
5141298D1C5FD7E90059E714 /* JSIDBCursorWithValueCustom.cpp */,
511EF2CD17F0FDF100E4FA16 /* JSIDBDatabaseCustom.cpp */,
+ 5141299A1C6C166D0059E714 /* JSIDBIndexCustom.cpp */,
511EF2CE17F0FDF100E4FA16 /* JSIDBObjectStoreCustom.cpp */,
A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */,
7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */,
@@ -29426,6 +29429,7 @@
3F2B33EC165AF15600E3987C /* DOMWebKitCSSViewportRule.mm in Sources */,
8A195933147EA16E00D1EA61 /* DOMWebKitNamedFlow.mm in Sources */,
31C0FF4D0E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm in Sources */,
+ 5141299B1C6C16740059E714 /* JSIDBIndexCustom.cpp in Sources */,
85C7F5E80AAFBAFB004014DD /* DOMWheelEvent.mm in Sources */,
1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */,
FD677738195CAF3D0072E0D3 /* DOMWindowCSS.cpp in Sources */,
Added: trunk/Source/WebCore/bindings/js/JSIDBIndexCustom.cpp (0 => 196482)
--- trunk/Source/WebCore/bindings/js/JSIDBIndexCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSIDBIndexCustom.cpp 2016-02-12 18:30:43 UTC (rev 196482)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSIDBIndex.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBIndexImpl.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSIDBIndex::visitAdditionalChildren(SlotVisitor& visitor)
+{
+ if (!wrapped().isModern())
+ return;
+
+ visitor.addOpaqueRoot(&static_cast<IDBClient::IDBIndex&>(wrapped()).modernObjectStore());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp (196481 => 196482)
--- trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp 2016-02-12 17:33:00 UTC (rev 196481)
+++ trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp 2016-02-12 18:30:43 UTC (rev 196482)
@@ -34,7 +34,7 @@
#include "IDBBindingUtilities.h"
#include "IDBDatabaseException.h"
#include "IDBKeyPath.h"
-#include "IDBObjectStore.h"
+#include "IDBObjectStoreImpl.h"
#include "JSDOMBinding.h"
#include "JSIDBIndex.h"
#include "JSIDBRequest.h"
@@ -45,6 +45,14 @@
namespace WebCore {
+void JSIDBObjectStore::visitAdditionalChildren(SlotVisitor& visitor)
+{
+ if (!wrapped().isModern())
+ return;
+
+ static_cast<IDBClient::IDBObjectStore&>(wrapped()).visitReferencedIndexes(visitor);
+}
+
static JSValue putOrAdd(JSC::ExecState& state, bool overwrite)
{
JSValue thisValue = state.thisValue();