Diff
Modified: trunk/Source/WebCore/ChangeLog (252786 => 252787)
--- trunk/Source/WebCore/ChangeLog 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/ChangeLog 2019-11-22 19:14:21 UTC (rev 252787)
@@ -1,3 +1,113 @@
+2019-11-22 Sihui Liu <[email protected]>
+
+ IndexedDB: lock-based implementation of suspension
+ https://bugs.webkit.org/show_bug.cgi?id=204379
+
+ Reviewed by Geoffrey Garen.
+
+ Covered by existing API test: IndexedDB.IndexedDBSuspendImminently
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::tryStop):
+ (WebCore::IDBServer::IDBServer::resume):
+ * Modules/indexeddb/server/IDBServer.h:
+ (WebCore::IDBServer::IDBServer::addDatabase):
+ (WebCore::IDBServer::IDBServer::removeDatabase):
+ * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+ (WebCore::IDBServer::MemoryIDBBackingStore::getOrEstablishDatabaseInfo):
+ (WebCore::IDBServer::MemoryIDBBackingStore::beginTransaction):
+ (WebCore::IDBServer::MemoryIDBBackingStore::abortTransaction):
+ (WebCore::IDBServer::MemoryIDBBackingStore::commitTransaction):
+ (WebCore::IDBServer::MemoryIDBBackingStore::createObjectStore):
+ (WebCore::IDBServer::MemoryIDBBackingStore::deleteObjectStore):
+ (WebCore::IDBServer::MemoryIDBBackingStore::renameObjectStore):
+ (WebCore::IDBServer::MemoryIDBBackingStore::clearObjectStore):
+ (WebCore::IDBServer::MemoryIDBBackingStore::createIndex):
+ (WebCore::IDBServer::MemoryIDBBackingStore::deleteIndex):
+ (WebCore::IDBServer::MemoryIDBBackingStore::renameIndex):
+ (WebCore::IDBServer::MemoryIDBBackingStore::keyExistsInObjectStore):
+ (WebCore::IDBServer::MemoryIDBBackingStore::deleteRange):
+ (WebCore::IDBServer::MemoryIDBBackingStore::addRecord):
+ (WebCore::IDBServer::MemoryIDBBackingStore::getRecord):
+ (WebCore::IDBServer::MemoryIDBBackingStore::getAllRecords):
+ (WebCore::IDBServer::MemoryIDBBackingStore::getIndexRecord):
+ (WebCore::IDBServer::MemoryIDBBackingStore::getCount):
+ (WebCore::IDBServer::MemoryIDBBackingStore::generateKeyNumber):
+ (WebCore::IDBServer::MemoryIDBBackingStore::revertGeneratedKeyNumber):
+ (WebCore::IDBServer::MemoryIDBBackingStore::maybeUpdateKeyGeneratorNumber):
+ (WebCore::IDBServer::MemoryIDBBackingStore::openCursor):
+ (WebCore::IDBServer::MemoryIDBBackingStore::iterateCursor):
+ (WebCore::IDBServer::MemoryIDBBackingStore::infoForObjectStore):
+ (WebCore::IDBServer::MemoryIDBBackingStore::deleteBackingStore):
+ (WebCore::IDBServer::MemoryIDBBackingStore::close):
+ (WebCore::IDBServer::MemoryIDBBackingStore::databaseSize const): Deleted.
+ * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getOrEstablishDatabaseInfo):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::abortTransaction):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::renameObjectStore):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::clearObjectStore):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::deleteIndex):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::renameIndex):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::keyExistsInObjectStore):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::deleteRange):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getAllRecords):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getIndexRecord):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getCount):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::revertGeneratedKeyNumber):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::openCursor):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::iterateCursor):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::prefetchCursor):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::infoForObjectStore):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::close):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::hasTransaction const):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::databaseSize const): Deleted.
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::UniqueIDBDatabase):
+ (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase):
+ (WebCore::IDBServer::UniqueIDBDatabase::deleteBackingStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::performUnconditionalDeleteBackingStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose):
+ (WebCore::IDBServer::UniqueIDBDatabase::performStartVersionChangeTransaction):
+ (WebCore::IDBServer::UniqueIDBDatabase::openBackingStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::performCreateObjectStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::performDeleteObjectStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::performRenameObjectStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::performClearObjectStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::performCreateIndex):
+ (WebCore::IDBServer::UniqueIDBDatabase::performDeleteIndex):
+ (WebCore::IDBServer::UniqueIDBDatabase::performRenameIndex):
+ (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
+ (WebCore::IDBServer::UniqueIDBDatabase::performGetRecord):
+ (WebCore::IDBServer::UniqueIDBDatabase::performGetIndexRecord):
+ (WebCore::IDBServer::UniqueIDBDatabase::performGetAllRecords):
+ (WebCore::IDBServer::UniqueIDBDatabase::performGetCount):
+ (WebCore::IDBServer::UniqueIDBDatabase::performDeleteRecord):
+ (WebCore::IDBServer::UniqueIDBDatabase::performOpenCursor):
+ (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor):
+ (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor):
+ (WebCore::IDBServer::UniqueIDBDatabase::performCommitTransaction):
+ (WebCore::IDBServer::UniqueIDBDatabase::performAbortTransaction):
+ (WebCore::IDBServer::UniqueIDBDatabase::performActivateTransactionInBackingStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::abortTransactionOnMainThread):
+ (WebCore::IDBServer::UniqueIDBDatabase::commitTransactionOnMainThread):
+ (WebCore::IDBServer::UniqueIDBDatabase::suspend):
+ (WebCore::IDBServer::UniqueIDBDatabase::resume):
+ (WebCore::IDBServer::UniqueIDBDatabase::finishActiveTransactions): Deleted.
+ * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
2019-11-22 Chris Lord <[email protected]>
Make CSSValuePool constructable
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2019-11-22 19:14:21 UTC (rev 252787)
@@ -60,43 +60,44 @@
public:
virtual ~IDBBackingStore() { RELEASE_ASSERT(!isMainThread()); }
- virtual IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&) = 0;
+ // All functions should take a LockHolder to make sure they have acquired lock when being called.
+ // This is used to make sure database operations would not be performed when process is suspended.
+ virtual IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&, const LockHolder&) = 0;
- virtual IDBError beginTransaction(const IDBTransactionInfo&) = 0;
- virtual IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) = 0;
- virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) = 0;
+ virtual IDBError beginTransaction(const IDBTransactionInfo&, const LockHolder&) = 0;
+ virtual IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) = 0;
+ virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) = 0;
- virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) = 0;
- virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
- virtual IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) = 0;
- virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
- virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) = 0;
- virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) = 0;
- virtual IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) = 0;
- virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
- virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0;
- virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) = 0;
- virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue) = 0;
- virtual IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue) = 0;
- virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) = 0;
- virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0;
- virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) = 0;
- virtual IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber) = 0;
- virtual IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber) = 0;
- virtual IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) = 0;
- virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult) = 0;
- virtual bool prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier) = 0;
+ virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const LockHolder&) = 0;
+ virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) = 0;
+ virtual IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&) = 0;
+ virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) = 0;
+ virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&, const LockHolder&) = 0;
+ virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&) = 0;
+ virtual IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&) = 0;
+ virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists, const LockHolder&) = 0;
+ virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, const LockHolder&) = 0;
+ virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&, const LockHolder&) = 0;
+ virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue, const LockHolder&) = 0;
+ virtual IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue, const LockHolder&) = 0;
+ virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue, const LockHolder&) = 0;
+ virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount, const LockHolder&) = 0;
+ virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber, const LockHolder&) = 0;
+ virtual IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber, const LockHolder&) = 0;
+ virtual IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber, const LockHolder&) = 0;
+ virtual IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult, const LockHolder&) = 0;
+ virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult, const LockHolder&) = 0;
+ virtual bool prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const LockHolder&) = 0;
- virtual IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) = 0;
- virtual void deleteBackingStore() = 0;
+ virtual IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&) = 0;
+ virtual void deleteBackingStore(const LockHolder&) = 0;
- virtual bool supportsSimultaneousTransactions() = 0;
- virtual bool isEphemeral() = 0;
+ virtual bool supportsSimultaneousTransactions(const LockHolder&) = 0;
+ virtual bool isEphemeral(const LockHolder&) = 0;
- virtual void close() = 0;
- virtual uint64_t databaseSize() const = 0;
+ virtual void close(const LockHolder&) = 0;
- virtual bool hasTransaction(const IDBResourceIdentifier&) const = 0;
+ virtual bool hasTransaction(const IDBResourceIdentifier&, const LockHolder&) const = 0;
protected:
IDBBackingStore() { RELEASE_ASSERT(!isMainThread()); }
};
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2019-11-22 19:14:21 UTC (rev 252787)
@@ -853,14 +853,11 @@
if (m_sessionID.isEphemeral())
return;
- suspendAndWait();
- if (shouldForceStop == ShouldForceStop::No && SQLiteDatabaseTracker::hasTransactionInProgress()) {
- CrossThreadTaskHandler::resume();
+ if (shouldForceStop == ShouldForceStop::No && SQLiteDatabaseTracker::hasTransactionInProgress())
return;
- }
- for (auto& database : m_uniqueIDBDatabaseMap.values())
- database->finishActiveTransactions();
+ for (auto& database : m_allUniqueIDBDatabases)
+ database.suspend();
}
void IDBServer::resume()
@@ -868,7 +865,8 @@
if (m_sessionID.isEphemeral())
return;
- CrossThreadTaskHandler::resume();
+ for (auto& database : m_allUniqueIDBDatabases)
+ database.resume();
}
} // namespace IDBServer
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2019-11-22 19:14:21 UTC (rev 252787)
@@ -41,7 +41,7 @@
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
-#include <wtf/WeakPtr.h>
+#include <wtf/WeakHashSet.h>
namespace WebCore {
@@ -123,6 +123,9 @@
WEBCORE_EXPORT void tryStop(ShouldForceStop);
WEBCORE_EXPORT void resume();
+ void addDatabase(UniqueIDBDatabase& database) { m_allUniqueIDBDatabases.add(database); }
+ void removeDatabase(UniqueIDBDatabase& database) { m_allUniqueIDBDatabases.remove(database); }
+
private:
IDBServer(PAL::SessionID, QuotaManagerGetter&&);
IDBServer(PAL::SessionID, const String& databaseDirectoryPath, QuotaManagerGetter&&);
@@ -190,6 +193,7 @@
PAL::SessionID m_sessionID;
HashMap<IDBConnectionIdentifier, RefPtr<IDBConnectionToClient>> m_connectionMap;
HashMap<IDBDatabaseIdentifier, std::unique_ptr<UniqueIDBDatabase>> m_uniqueIDBDatabaseMap;
+ WeakHashSet<UniqueIDBDatabase> m_allUniqueIDBDatabases;
HashMap<uint64_t, UniqueIDBDatabaseConnection*> m_databaseConnections;
HashMap<IDBResourceIdentifier, UniqueIDBDatabaseTransaction*> m_transactions;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2019-11-22 19:14:21 UTC (rev 252787)
@@ -59,6 +59,11 @@
MemoryIDBBackingStore::~MemoryIDBBackingStore() = default;
+IDBError MemoryIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info, const LockHolder&)
+{
+ return getOrEstablishDatabaseInfo(info);
+}
+
IDBError MemoryIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info)
{
if (!m_databaseInfo)
@@ -76,7 +81,7 @@
m_databaseInfo = makeUnique<IDBDatabaseInfo>(info);
}
-IDBError MemoryIDBBackingStore::beginTransaction(const IDBTransactionInfo& info)
+IDBError MemoryIDBBackingStore::beginTransaction(const IDBTransactionInfo& info, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::beginTransaction");
@@ -101,7 +106,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::abortTransaction(const IDBResourceIdentifier& transactionIdentifier)
+IDBError MemoryIDBBackingStore::abortTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::abortTransaction - %s", transactionIdentifier.loggingString().utf8().data());
@@ -114,7 +119,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::commitTransaction(const IDBResourceIdentifier& transactionIdentifier)
+IDBError MemoryIDBBackingStore::commitTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::commitTransaction - %s", transactionIdentifier.loggingString().utf8().data());
@@ -127,7 +132,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info)
+IDBError MemoryIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::createObjectStore - adding OS %s with ID %" PRIu64, info.name().utf8().data(), info.identifier());
@@ -150,7 +155,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
+IDBError MemoryIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::deleteObjectStore");
@@ -173,7 +178,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName)
+IDBError MemoryIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::renameObjectStore");
@@ -202,7 +207,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
+IDBError MemoryIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::clearObjectStore");
ASSERT(objectStoreIdentifier);
@@ -223,7 +228,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info)
+IDBError MemoryIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::createIndex");
@@ -238,7 +243,7 @@
return objectStore->createIndex(*rawTransaction, info);
}
-IDBError MemoryIDBBackingStore::deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier)
+IDBError MemoryIDBBackingStore::deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::deleteIndex");
@@ -253,7 +258,7 @@
return objectStore->deleteIndex(*rawTransaction, indexIdentifier);
}
-IDBError MemoryIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
+IDBError MemoryIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::renameIndex");
@@ -306,7 +311,7 @@
registerObjectStore(WTFMove(objectStore));
}
-IDBError MemoryIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier&, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, bool& keyExists)
+IDBError MemoryIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier&, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, bool& keyExists, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::keyExistsInObjectStore");
@@ -319,7 +324,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range)
+IDBError MemoryIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::deleteRange");
@@ -336,7 +341,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value)
+IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::addRecord");
@@ -353,7 +358,7 @@
return objectStore->addRecord(*transaction, keyData, value);
}
-IDBError MemoryIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, IDBGetRecordDataType type, IDBGetResult& outValue)
+IDBError MemoryIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, IDBGetRecordDataType type, IDBGetResult& outValue, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::getRecord");
@@ -380,7 +385,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData& getAllRecordsData, IDBGetAllResult& result)
+IDBError MemoryIDBBackingStore::getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData& getAllRecordsData, IDBGetAllResult& result, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::getAllRecords");
@@ -405,7 +410,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType recordType, const IDBKeyRangeData& range, IDBGetResult& outValue)
+IDBError MemoryIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType recordType, const IDBKeyRangeData& range, IDBGetResult& outValue, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::getIndexRecord");
@@ -422,7 +427,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData& range, uint64_t& outCount)
+IDBError MemoryIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData& range, uint64_t& outCount, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::getCount");
@@ -440,7 +445,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber)
+IDBError MemoryIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::generateKeyNumber");
ASSERT(objectStoreIdentifier);
@@ -459,7 +464,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber)
+IDBError MemoryIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::revertGeneratedKeyNumber");
ASSERT(objectStoreIdentifier);
@@ -474,7 +479,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber)
+IDBError MemoryIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::maybeUpdateKeyGeneratorNumber");
ASSERT(objectStoreIdentifier);
@@ -503,7 +508,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& outData)
+IDBError MemoryIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& outData, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::openCursor");
@@ -545,7 +550,7 @@
return IDBError { };
}
-IDBError MemoryIDBBackingStore::iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData& data, IDBGetResult& outData)
+IDBError MemoryIDBBackingStore::iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData& data, IDBGetResult& outData, const LockHolder&)
{
LOG(IndexedDB, "MemoryIDBBackingStore::iterateCursor");
@@ -592,27 +597,21 @@
return objectStoreByIdentifier;
}
-IDBObjectStoreInfo* MemoryIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier)
+IDBObjectStoreInfo* MemoryIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&)
{
ASSERT(m_databaseInfo);
return m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier);
}
-void MemoryIDBBackingStore::deleteBackingStore()
+void MemoryIDBBackingStore::deleteBackingStore(const LockHolder&)
{
// The in-memory IDB backing store doesn't need to do any cleanup when it is deleted.
}
-uint64_t MemoryIDBBackingStore::databaseSize() const
+void MemoryIDBBackingStore::close(const LockHolder&)
{
- // FIXME: Implement this.
- return 0;
}
-void MemoryIDBBackingStore::close()
-{
-}
-
} // namespace IDBServer
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2019-11-22 19:14:21 UTC (rev 252787)
@@ -47,50 +47,50 @@
MemoryIDBBackingStore(PAL::SessionID, const IDBDatabaseIdentifier&);
~MemoryIDBBackingStore() final;
- IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&) final;
+ IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&, const LockHolder&) final;
+ IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&);
void setDatabaseInfo(const IDBDatabaseInfo&);
- IDBError beginTransaction(const IDBTransactionInfo&) final;
- IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
- IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
- IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) final;
- IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
- IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) final;
- IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
- IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) final;
- IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;
- IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) final;
- IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
- IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
- IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) final;
- IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue) final;
- IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue) final;
- IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) final;
- IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) final;
- IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) final;
- IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber) final;
- IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber) final;
- IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) final;
- IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult) final;
- bool prefetchCursor(const IDBResourceIdentifier&, const IDBResourceIdentifier&) final { return false; }
+ IDBError beginTransaction(const IDBTransactionInfo&, const LockHolder&) final;
+ IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) final;
+ IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) final;
+ IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const LockHolder&) final;
+ IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) final;
+ IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&) final;
+ IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) final;
+ IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&, const LockHolder&) final;
+ IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&) final;
+ IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&) final;
+ IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists, const LockHolder&) final;
+ IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, const LockHolder&) final;
+ IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&, const LockHolder&) final;
+ IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue, const LockHolder&) final;
+ IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue, const LockHolder&) final;
+ IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue, const LockHolder&) final;
+ IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount, const LockHolder&) final;
+ IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber, const LockHolder&) final;
+ IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber, const LockHolder&) final;
+ IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber, const LockHolder&) final;
+ IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult, const LockHolder&) final;
+ IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult, const LockHolder&) final;
+ bool prefetchCursor(const IDBResourceIdentifier&, const IDBResourceIdentifier&, const LockHolder&) final { return false; }
- IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) final;
- void deleteBackingStore() final;
+ IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&) final;
+ void deleteBackingStore(const LockHolder&) final;
- bool supportsSimultaneousTransactions() final { return true; }
- bool isEphemeral() final { return true; }
+ bool supportsSimultaneousTransactions(const LockHolder&) final { return true; }
+ bool isEphemeral(const LockHolder&) final { return true; }
void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&);
void restoreObjectStoreForVersionChangeAbort(Ref<MemoryObjectStore>&&);
- bool hasTransaction(const IDBResourceIdentifier& identifier) const final { return m_transactions.contains(identifier); }
+ bool hasTransaction(const IDBResourceIdentifier& identifier, const LockHolder&) const final { return m_transactions.contains(identifier); }
private:
RefPtr<MemoryObjectStore> takeObjectStoreByIdentifier(uint64_t identifier);
-
- uint64_t databaseSize() const final;
- void close() final;
+ void close(const LockHolder&) final;
+
IDBDatabaseIdentifier m_identifier;
PAL::SessionID m_sessionID;
std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2019-11-22 19:14:21 UTC (rev 252787)
@@ -781,7 +781,7 @@
return newDatabaseDirectory;
}
-IDBError SQLiteIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info)
+IDBError SQLiteIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::getOrEstablishDatabaseInfo - database %s", m_identifier.databaseName().utf8().data());
@@ -854,14 +854,8 @@
return diskUsage;
}
-uint64_t SQLiteIDBBackingStore::databaseSize() const
+IDBError SQLiteIDBBackingStore::beginTransaction(const IDBTransactionInfo& info, const LockHolder&)
{
- ASSERT(!isMainThread());
- return SQLiteFileSystem::getDatabaseFileSize(fullDatabasePath());
-}
-
-IDBError SQLiteIDBBackingStore::beginTransaction(const IDBTransactionInfo& info)
-{
LOG(IndexedDB, "SQLiteIDBBackingStore::beginTransaction - %s", info.identifier().loggingString().utf8().data());
ASSERT(m_sqliteDB);
@@ -891,7 +885,7 @@
return error;
}
-IDBError SQLiteIDBBackingStore::abortTransaction(const IDBResourceIdentifier& identifier)
+IDBError SQLiteIDBBackingStore::abortTransaction(const IDBResourceIdentifier& identifier, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::abortTransaction - %s", identifier.loggingString().utf8().data());
@@ -910,7 +904,7 @@
return transaction->abort();
}
-IDBError SQLiteIDBBackingStore::commitTransaction(const IDBResourceIdentifier& identifier)
+IDBError SQLiteIDBBackingStore::commitTransaction(const IDBResourceIdentifier& identifier, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::commitTransaction - %s", identifier.loggingString().utf8().data());
@@ -935,7 +929,7 @@
return error;
}
-IDBError SQLiteIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info)
+IDBError SQLiteIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::createObjectStore - adding OS %s with ID %" PRIu64, info.name().utf8().data(), info.identifier());
@@ -986,7 +980,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
+IDBError SQLiteIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::deleteObjectStore - object store %" PRIu64, objectStoreIdentifier);
@@ -1077,7 +1071,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName)
+IDBError SQLiteIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::renameObjectStore - object store %" PRIu64, objectStoreIdentifier);
@@ -1109,7 +1103,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID)
+IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::clearObjectStore - object store %" PRIu64, objectStoreID);
@@ -1150,7 +1144,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info)
+IDBError SQLiteIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::createIndex - ObjectStore %" PRIu64 ", Index %" PRIu64, info.objectStoreIdentifier(), info.identifier());
ASSERT(m_sqliteDB);
@@ -1337,7 +1331,7 @@
}
-IDBError SQLiteIDBBackingStore::deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier)
+IDBError SQLiteIDBBackingStore::deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::deleteIndex - object store %" PRIu64, objectStoreIdentifier);
@@ -1382,7 +1376,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
+IDBError SQLiteIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::renameIndex - object store %" PRIu64 ", index %" PRIu64, objectStoreIdentifier, indexIdentifier);
@@ -1423,7 +1417,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyData& keyData, bool& keyExists)
+IDBError SQLiteIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyData& keyData, bool& keyExists, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::keyExistsInObjectStore - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreID);
@@ -1598,7 +1592,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange)
+IDBError SQLiteIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::deleteRange - range %s, object store %" PRIu64, keyRange.loggingString().utf8().data(), objectStoreID);
@@ -1718,7 +1712,7 @@
return error;
}
-IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value)
+IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::addRecord - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreInfo.identifier());
@@ -1880,7 +1874,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, IDBGetRecordDataType type, IDBGetResult& resultValue)
+IDBError SQLiteIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, IDBGetRecordDataType type, IDBGetResult& resultValue, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::getRecord - key range %s, object store %" PRIu64, keyRange.loggingString().utf8().data(), objectStoreID);
@@ -2015,7 +2009,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData& getAllRecordsData, IDBGetAllResult& result)
+IDBError SQLiteIDBBackingStore::getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData& getAllRecordsData, IDBGetAllResult& result, const LockHolder&)
{
return getAllRecordsData.indexIdentifier ? getAllIndexRecords(transactionIdentifier, getAllRecordsData, result) : getAllObjectStoreRecords(transactionIdentifier, getAllRecordsData, result);
}
@@ -2195,7 +2189,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t indexID, IndexedDB::IndexRecordType type, const IDBKeyRangeData& range, IDBGetResult& getResult)
+IDBError SQLiteIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t indexID, IndexedDB::IndexRecordType type, const IDBKeyRangeData& range, IDBGetResult& getResult, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::getIndexRecord - %s", range.loggingString().utf8().data());
@@ -2297,7 +2291,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData& range, uint64_t& outCount)
+IDBError SQLiteIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData& range, uint64_t& outCount, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::getCount - object store %" PRIu64, objectStoreIdentifier);
ASSERT(m_sqliteDB);
@@ -2414,7 +2408,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t& generatedKey)
+IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t& generatedKey, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::generateKeyNumber");
@@ -2442,7 +2436,7 @@
return uncheckedSetKeyGeneratorValue(objectStoreID, generatedKey);
}
-IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t newKeyNumber)
+IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t newKeyNumber, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::revertGeneratedKeyNumber - object store %" PRIu64 ", reverted number %" PRIu64, objectStoreID, newKeyNumber);
@@ -2462,7 +2456,7 @@
return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyNumber - 1);
}
-IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, double newKeyNumber)
+IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, double newKeyNumber, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber");
@@ -2489,7 +2483,7 @@
return uncheckedSetKeyGeneratorValue(objectStoreID, std::min(newKeyNumber, (double)maxGeneratorValue));
}
-IDBError SQLiteIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& result)
+IDBError SQLiteIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& result, const LockHolder&)
{
ASSERT(m_sqliteDB);
ASSERT(m_sqliteDB->isOpen());
@@ -2512,7 +2506,7 @@
return IDBError { };
}
-IDBError SQLiteIDBBackingStore::iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData& data, IDBGetResult& result)
+IDBError SQLiteIDBBackingStore::iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData& data, IDBGetResult& result, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::iterateCursor");
@@ -2555,7 +2549,7 @@
return IDBError { };
}
-bool SQLiteIDBBackingStore::prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier)
+bool SQLiteIDBBackingStore::prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const LockHolder&)
{
LOG(IndexedDB, "SQLiteIDBBackingStore::prefetchCursor");
@@ -2571,6 +2565,11 @@
return cursor->prefetch();
}
+IDBObjectStoreInfo* SQLiteIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&)
+{
+ return infoForObjectStore(objectStoreIdentifier);
+}
+
IDBObjectStoreInfo* SQLiteIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier)
{
ASSERT(m_databaseInfo);
@@ -2577,7 +2576,7 @@
return m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier);
}
-void SQLiteIDBBackingStore::deleteBackingStore()
+void SQLiteIDBBackingStore::deleteBackingStore(const LockHolder&)
{
String dbFilename = fullDatabasePath();
@@ -2647,7 +2646,7 @@
return m_cachedStatements[static_cast<size_t>(sql)].get();
}
-void SQLiteIDBBackingStore::close()
+void SQLiteIDBBackingStore::close(const LockHolder&)
{
closeSQLiteDB();
}
@@ -2663,7 +2662,7 @@
m_sqliteDB = nullptr;
}
-bool SQLiteIDBBackingStore::hasTransaction(const IDBResourceIdentifier& transactionIdentifier) const
+bool SQLiteIDBBackingStore::hasTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) const
{
ASSERT(isMainThread());
return m_transactions.contains(transactionIdentifier);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2019-11-22 19:14:21 UTC (rev 252787)
@@ -54,41 +54,44 @@
~SQLiteIDBBackingStore() final;
- IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&) final;
+ IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&, const LockHolder&) final;
- IDBError beginTransaction(const IDBTransactionInfo&) final;
- IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
- IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
- IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) final;
- IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
- IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) final;
- IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
- IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) final;
- IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;
- IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) final;
- IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
- IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
- IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) final;
- IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue) final;
- IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue) final;
- IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) final;
- IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) final;
- IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) final;
- IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber) final;
- IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber) final;
- IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) final;
- IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult) final;
- bool prefetchCursor(const IDBResourceIdentifier&, const IDBResourceIdentifier&) final;
+ IDBError beginTransaction(const IDBTransactionInfo&, const LockHolder&) final;
+ IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) final;
+ IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) final;
+ IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const LockHolder&) final;
+ IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) final;
+ IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&) final;
+ IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) final;
+ IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&, const LockHolder&) final;
+ IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&) final;
+ IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&) final;
+ IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists, const LockHolder&) final;
+ IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, const LockHolder&) final;
+ IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&, const LockHolder&) final;
+ IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue, const LockHolder&) final;
+ IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue, const LockHolder&) final;
+ IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue, const LockHolder&) final;
+ IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount, const LockHolder&) final;
+ IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber, const LockHolder&) final;
+ IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber, const LockHolder&) final;
+ IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber, const LockHolder&) final;
+ IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult, const LockHolder&) final;
+ IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult, const LockHolder&) final;
+ bool prefetchCursor(const IDBResourceIdentifier&, const IDBResourceIdentifier&, const LockHolder&) final;
- IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) final;
- void deleteBackingStore() final;
+ IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&) final;
+ void deleteBackingStore(const LockHolder&) final;
- bool supportsSimultaneousTransactions() final { return false; }
- bool isEphemeral() final { return false; }
+ bool supportsSimultaneousTransactions(const LockHolder&) final { return false; }
+ bool isEphemeral(const LockHolder&) final { return false; }
+ bool hasTransaction(const IDBResourceIdentifier&, const LockHolder&) const final;
+
void unregisterCursor(SQLiteIDBCursor&);
IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths);
+ IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier);
static String databaseNameFromEncodedFilename(const String&);
static uint64_t databasesSizeForDirectory(const String& directory);
@@ -97,8 +100,6 @@
static String fullDatabasePathForDirectory(const String&);
static String databaseNameFromFile(const String&);
- bool hasTransaction(const IDBResourceIdentifier&) const final;
-
PAL::SessionID sessionID() const { return m_sessionID; }
private:
@@ -132,9 +133,7 @@
IDBError getAllIndexRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue);
void closeSQLiteDB();
- void close() final;
-
- uint64_t databaseSize() const final;
+ void close(const LockHolder&) final;
enum class SQL : size_t {
CreateObjectStoreInfo,
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2019-11-22 19:14:21 UTC (rev 252787)
@@ -122,6 +122,7 @@
, m_identifier(identifier)
, m_operationAndTransactionTimer(*this, &UniqueIDBDatabase::operationAndTransactionTimerFired)
{
+ m_server->addDatabase(*this);
LOG(IndexedDB, "UniqueIDBDatabase::UniqueIDBDatabase() (%p) %s", this, m_identifier.debugString().utf8().data());
}
@@ -139,6 +140,8 @@
RELEASE_ASSERT(m_databaseQueue.isKilled());
RELEASE_ASSERT(m_databaseReplyQueue.isKilled());
RELEASE_ASSERT(!m_backingStore);
+
+ m_server->removeDatabase(*this);
}
const IDBDatabaseInfo& UniqueIDBDatabase::info() const
@@ -377,22 +380,24 @@
uint64_t deletedVersion = 0;
- if (m_backingStore) {
- m_backingStore->deleteBackingStore();
+ {
+ LockHolder locker(m_backingStoreLock);
+ if (m_backingStore) {
+ m_backingStore->deleteBackingStore(locker);
+ m_backingStore = nullptr;
+ m_backingStoreSupportsSimultaneousTransactions = false;
+ m_backingStoreIsEphemeral = false;
+ } else {
+ auto backingStore = m_server->createBackingStore(identifier);
- m_backingStore = nullptr;
- m_backingStoreSupportsSimultaneousTransactions = false;
- m_backingStoreIsEphemeral = false;
- } else {
- auto backingStore = m_server->createBackingStore(identifier);
+ IDBDatabaseInfo databaseInfo;
+ auto error = backingStore->getOrEstablishDatabaseInfo(databaseInfo, locker);
+ if (!error.isNull())
+ LOG_ERROR("Error getting database info from database %s that we are trying to delete", identifier.debugString().utf8().data());
- IDBDatabaseInfo databaseInfo;
- auto error = backingStore->getOrEstablishDatabaseInfo(databaseInfo);
- if (!error.isNull())
- LOG_ERROR("Error getting database info from database %s that we are trying to delete", identifier.debugString().utf8().data());
-
- deletedVersion = databaseInfo.version();
- backingStore->deleteBackingStore();
+ deletedVersion = databaseInfo.version();
+ backingStore->deleteBackingStore(locker);
+ }
}
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didDeleteBackingStore, deletedVersion));
@@ -403,8 +408,11 @@
ASSERT(!isMainThread());
LOG(IndexedDB, "(db) UniqueIDBDatabase::performUnconditionalDeleteBackingStore");
- if (m_backingStore)
- m_backingStore->deleteBackingStore();
+ {
+ LockHolder locker(m_backingStoreLock);
+ if (m_backingStore)
+ m_backingStore->deleteBackingStore(locker);
+ }
shutdownForClose();
}
@@ -428,10 +436,11 @@
LOG(IndexedDB, "(db) UniqueIDBDatabase::shutdownForClose");
- if (m_backingStore)
- m_backingStore->close();
-
- m_backingStore = nullptr;
+ if (m_backingStore) {
+ LockHolder locker(m_backingStoreLock);
+ m_backingStore->close(locker);
+ m_backingStore = nullptr;
+ }
m_backingStoreSupportsSimultaneousTransactions = false;
m_backingStoreIsEphemeral = false;
@@ -670,7 +679,12 @@
{
LOG(IndexedDB, "(db) UniqueIDBDatabase::performStartVersionChangeTransaction");
- IDBError error = m_backingStore->beginTransaction(info);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->beginTransaction(info, locker);
+ }
+
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformStartVersionChangeTransaction, error));
}
@@ -827,12 +841,16 @@
LOG(IndexedDB, "(db) UniqueIDBDatabase::openBackingStore (%p)", this);
ASSERT(!m_backingStore);
- m_backingStore = m_server->createBackingStore(identifier);
- m_backingStoreSupportsSimultaneousTransactions = m_backingStore->supportsSimultaneousTransactions();
- m_backingStoreIsEphemeral = m_backingStore->isEphemeral();
IDBDatabaseInfo databaseInfo;
- auto error = m_backingStore->getOrEstablishDatabaseInfo(databaseInfo);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ m_backingStore = m_server->createBackingStore(identifier);
+ m_backingStoreSupportsSimultaneousTransactions = m_backingStore->supportsSimultaneousTransactions(locker);
+ m_backingStoreIsEphemeral = m_backingStore->isEphemeral(locker);
+ error = m_backingStore->getOrEstablishDatabaseInfo(databaseInfo, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didOpenBackingStore, databaseInfo, error, taskIdentifier));
}
@@ -892,7 +910,11 @@
}
ASSERT(m_backingStore);
- IDBError error = m_backingStore->createObjectStore(transactionIdentifier, info);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->createObjectStore(transactionIdentifier, info, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCreateObjectStore, callbackIdentifier, error, info));
}
@@ -944,7 +966,11 @@
LOG(IndexedDB, "(db) UniqueIDBDatabase::performDeleteObjectStore");
ASSERT(m_backingStore);
- IDBError error = m_backingStore->deleteObjectStore(transactionIdentifier, objectStoreIdentifier);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->deleteObjectStore(transactionIdentifier, objectStoreIdentifier, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteObjectStore, callbackIdentifier, error, objectStoreIdentifier));
}
@@ -1001,7 +1027,10 @@
}
ASSERT(m_backingStore);
- m_backingStore->renameObjectStore(transactionIdentifier, objectStoreIdentifier, newName);
+ {
+ LockHolder locker(m_backingStoreLock);
+ m_backingStore->renameObjectStore(transactionIdentifier, objectStoreIdentifier, newName, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformRenameObjectStore, callbackIdentifier, error, objectStoreIdentifier, newName));
}
@@ -1046,7 +1075,11 @@
LOG(IndexedDB, "(db) UniqueIDBDatabase::performClearObjectStore");
ASSERT(m_backingStore);
- IDBError error = m_backingStore->clearObjectStore(transactionIdentifier, objectStoreIdentifier);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->clearObjectStore(transactionIdentifier, objectStoreIdentifier, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformClearObjectStore, callbackIdentifier, error));
}
@@ -1096,14 +1129,17 @@
IDBError error;
ASSERT(m_backingStore);
- if (!m_backingStore) {
- RELEASE_LOG_ERROR(IndexedDB, "%p - UniqueIDBDatabase::performCreateIndex: m_backingStore is null", this);
- error = IDBError(InvalidStateError, "Backing store is invalid for call to create index"_s);
- postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCreateIndex, callbackIdentifier, error, info));
- return;
+ {
+ LockHolder locker(m_backingStoreLock);
+ if (!m_backingStore) {
+ RELEASE_LOG_ERROR(IndexedDB, "%p - UniqueIDBDatabase::performCreateIndex: m_backingStore is null", this);
+ error = IDBError(InvalidStateError, "Backing store is invalid for call to create index"_s);
+ postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCreateIndex, callbackIdentifier, error, info));
+ return;
+ }
+ error = m_backingStore->createIndex(transactionIdentifier, info, locker);
}
- error = m_backingStore->createIndex(transactionIdentifier, info);
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCreateIndex, callbackIdentifier, error, info));
}
@@ -1165,7 +1201,11 @@
LOG(IndexedDB, "(db) UniqueIDBDatabase::performDeleteIndex");
ASSERT(m_backingStore);
- IDBError error = m_backingStore->deleteIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->deleteIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteIndex, callbackIdentifier, error, objectStoreIdentifier, indexIdentifier));
}
@@ -1229,7 +1269,10 @@
}
ASSERT(m_backingStore);
- m_backingStore->renameIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier, newName);
+ {
+ LockHolder locker(m_backingStoreLock);
+ m_backingStore->renameIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier, newName, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformRenameIndex, callbackIdentifier, error, objectStoreIdentifier, indexIdentifier, newName));
}
@@ -1299,71 +1342,74 @@
return;
}
- if (!m_backingStore) {
- RELEASE_LOG_ERROR(IndexedDB, "%p - UniqueIDBDatabase::performPutOrAdd: m_backingStore is null", this);
- error = IDBError(InvalidStateError, "Backing store is invalid for call to put or add"_s);
- postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
- return;
- }
+ {
+ LockHolder locker(m_backingStoreLock);
+ if (!m_backingStore) {
+ RELEASE_LOG_ERROR(IndexedDB, "%p - UniqueIDBDatabase::performPutOrAdd: m_backingStore is null", this);
+ error = IDBError(InvalidStateError, "Backing store is invalid for call to put or add"_s);
+ postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
+ return;
+ }
- auto* objectStoreInfo = m_backingStore->infoForObjectStore(objectStoreIdentifier);
- if (!objectStoreInfo) {
- error = IDBError(InvalidStateError, "Object store cannot be found in the backing store"_s);
- postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
- return;
- }
+ auto* objectStoreInfo = m_backingStore->infoForObjectStore(objectStoreIdentifier, locker);
+ if (!objectStoreInfo) {
+ error = IDBError(InvalidStateError, "Object store cannot be found in the backing store"_s);
+ postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
+ return;
+ }
- bool usedKeyIsGenerated = false;
- uint64_t keyNumber;
- auto generatedKeyResetter = WTF::makeScopeExit([this, transactionIdentifier, objectStoreIdentifier, &keyNumber, &usedKeyIsGenerated]() {
- if (usedKeyIsGenerated)
- m_backingStore->revertGeneratedKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber);
- });
- if (objectStoreInfo->autoIncrement() && !keyData.isValid()) {
- error = m_backingStore->generateKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber);
+ bool usedKeyIsGenerated = false;
+ uint64_t keyNumber;
+ auto generatedKeyResetter = WTF::makeScopeExit([this, transactionIdentifier, objectStoreIdentifier, &keyNumber, &usedKeyIsGenerated, &locker]() {
+ if (usedKeyIsGenerated)
+ m_backingStore->revertGeneratedKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber, locker);
+ });
+ if (objectStoreInfo->autoIncrement() && !keyData.isValid()) {
+ error = m_backingStore->generateKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber, locker);
+ if (!error.isNull()) {
+ postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
+ return;
+ }
+
+ usedKey.setNumberValue(keyNumber);
+ usedKeyIsGenerated = true;
+ } else
+ usedKey = keyData;
+
+ if (overwriteMode == IndexedDB::ObjectStoreOverwriteMode::NoOverwrite) {
+ bool keyExists;
+ error = m_backingStore->keyExistsInObjectStore(transactionIdentifier, objectStoreIdentifier, usedKey, keyExists, locker);
+ if (error.isNull() && keyExists)
+ error = IDBError(ConstraintError, "Key already exists in the object store"_s);
+
+ if (!error.isNull()) {
+ postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
+ return;
+ }
+ }
+
+ // 3.4.1 Object Store Storage Operation
+ // ...If a record already exists in store ...
+ // then remove the record from store using the steps for deleting records from an object store...
+ // This is important because formally deleting it from from the object store also removes it from the appropriate indexes.
+ error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, usedKey, locker);
if (!error.isNull()) {
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
return;
}
-
- usedKey.setNumberValue(keyNumber);
- usedKeyIsGenerated = true;
- } else
- usedKey = keyData;
- if (overwriteMode == IndexedDB::ObjectStoreOverwriteMode::NoOverwrite) {
- bool keyExists;
- error = m_backingStore->keyExistsInObjectStore(transactionIdentifier, objectStoreIdentifier, usedKey, keyExists);
- if (error.isNull() && keyExists)
- error = IDBError(ConstraintError, "Key already exists in the object store"_s);
+ error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue, locker);
if (!error.isNull()) {
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
return;
}
- }
- // 3.4.1 Object Store Storage Operation
- // ...If a record already exists in store ...
- // then remove the record from store using the steps for deleting records from an object store...
- // This is important because formally deleting it from from the object store also removes it from the appropriate indexes.
- error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, usedKey);
- if (!error.isNull()) {
- postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
- return;
- }
+ if (overwriteMode != IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor && objectStoreInfo->autoIncrement() && keyData.type() == IndexedDB::KeyType::Number)
+ error = m_backingStore->maybeUpdateKeyGeneratorNumber(transactionIdentifier, objectStoreIdentifier, keyData.number(), locker);
- error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue);
-
- if (!error.isNull()) {
- postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
- return;
+ generatedKeyResetter.release();
}
-
- if (overwriteMode != IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor && objectStoreInfo->autoIncrement() && keyData.type() == IndexedDB::KeyType::Number)
- error = m_backingStore->maybeUpdateKeyGeneratorNumber(transactionIdentifier, objectStoreIdentifier, keyData.number());
-
- generatedKeyResetter.release();
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
}
@@ -1433,7 +1479,11 @@
ASSERT(m_backingStore);
IDBGetResult result;
- IDBError error = m_backingStore->getRecord(transactionIdentifier, objectStoreIdentifier, keyRangeData, type, result);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->getRecord(transactionIdentifier, objectStoreIdentifier, keyRangeData, type, result, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetRecord, callbackIdentifier, error, result));
}
@@ -1444,9 +1494,12 @@
LOG(IndexedDB, "(db) UniqueIDBDatabase::performGetIndexRecord");
ASSERT(m_backingStore);
-
IDBGetResult result;
- IDBError error = m_backingStore->getIndexRecord(transactionIdentifier, objectStoreIdentifier, indexIdentifier, recordType, range, result);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->getIndexRecord(transactionIdentifier, objectStoreIdentifier, indexIdentifier, recordType, range, result, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetRecord, callbackIdentifier, error, result));
}
@@ -1467,7 +1520,11 @@
ASSERT(m_backingStore);
IDBGetAllResult result;
- IDBError error = m_backingStore->getAllRecords(transactionIdentifier, getAllRecordsData, result);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->getAllRecords(transactionIdentifier, getAllRecordsData, result, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetAllRecords, callbackIdentifier, error, WTFMove(result)));
}
@@ -1511,7 +1568,11 @@
ASSERT(objectStoreIdentifier);
uint64_t count;
- IDBError error = m_backingStore->getCount(transactionIdentifier, objectStoreIdentifier, indexIdentifier, keyRangeData, count);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->getCount(transactionIdentifier, objectStoreIdentifier, indexIdentifier, keyRangeData, count, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetCount, callbackIdentifier, error, count));
}
@@ -1551,7 +1612,11 @@
ASSERT(!isMainThread());
LOG(IndexedDB, "(db) UniqueIDBDatabase::performDeleteRecord");
- IDBError error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, range);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, range, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteRecord, callbackIdentifier, error));
}
@@ -1592,7 +1657,11 @@
LOG(IndexedDB, "(db) UniqueIDBDatabase::performOpenCursor");
IDBGetResult result;
- IDBError error = m_backingStore->openCursor(transactionIdentifier, info, result);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->openCursor(transactionIdentifier, info, result, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformOpenCursor, callbackIdentifier, error, result));
}
@@ -1633,7 +1702,11 @@
LOG(IndexedDB, "(db) UniqueIDBDatabase::performIterateCursor");
IDBGetResult result;
- IDBError error = m_backingStore->iterateCursor(transactionIdentifier, cursorIdentifier, data, result);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->iterateCursor(transactionIdentifier, cursorIdentifier, data, result, locker);
+ }
if (error.isNull()) {
auto addResult = m_cursorPrefetches.add(cursorIdentifier);
@@ -1650,10 +1723,20 @@
ASSERT(m_cursorPrefetches.contains(cursorIdentifier));
LOG(IndexedDB, "(db) UniqueIDBDatabase::performPrefetchCursor");
- if (m_hardClosedForUserDelete || !m_backingStore->prefetchCursor(transactionIdentifier, cursorIdentifier))
+ if (m_hardClosedForUserDelete) {
m_cursorPrefetches.remove(cursorIdentifier);
- else
- postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performPrefetchCursor, transactionIdentifier, cursorIdentifier));
+ return;
+ }
+
+ {
+ LockHolder locker(m_backingStoreLock);
+ if (!m_backingStore->prefetchCursor(transactionIdentifier, cursorIdentifier, locker)) {
+ m_cursorPrefetches.remove(cursorIdentifier);
+ return;
+ }
+ }
+
+ postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performPrefetchCursor, transactionIdentifier, cursorIdentifier));
}
void UniqueIDBDatabase::didPerformIterateCursor(uint64_t callbackIdentifier, const IDBError& error, const IDBGetResult& result)
@@ -1718,7 +1801,11 @@
ASSERT(!isMainThread());
LOG(IndexedDB, "(db) UniqueIDBDatabase::performCommitTransaction - %s", transactionIdentifier.loggingString().utf8().data());
- IDBError error = m_backingStore->commitTransaction(transactionIdentifier);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->commitTransaction(transactionIdentifier, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCommitTransaction, callbackIdentifier, error, transactionIdentifier));
}
@@ -1808,7 +1895,11 @@
ASSERT(!isMainThread());
LOG(IndexedDB, "(db) UniqueIDBDatabase::performAbortTransaction - %s", transactionIdentifier.loggingString().utf8().data());
- IDBError error = m_backingStore->abortTransaction(transactionIdentifier);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->abortTransaction(transactionIdentifier, locker);
+ }
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformAbortTransaction, callbackIdentifier, error, transactionIdentifier));
}
@@ -2018,7 +2109,12 @@
{
LOG(IndexedDB, "(db) UniqueIDBDatabase::performActivateTransactionInBackingStore");
- IDBError error = m_backingStore->beginTransaction(info);
+ IDBError error;
+ {
+ LockHolder locker(m_backingStoreLock);
+ error = m_backingStore->beginTransaction(info, locker);
+ }
+
postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformActivateTransactionInBackingStore, callbackIdentifier, error));
}
@@ -2351,47 +2447,68 @@
m_errorCallbacks.remove(callbackIdentifier);
}
-void UniqueIDBDatabase::abortTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction)
+void UniqueIDBDatabase::abortTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction, const LockHolder& locker)
{
- transaction.setResult(m_backingStore->abortTransaction(transaction.info().identifier()));
+ transaction.setResult(m_backingStore->abortTransaction(transaction.info().identifier(), locker));
transaction.setState(UniqueIDBDatabaseTransaction::State::Aborted);
}
-void UniqueIDBDatabase::commitTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction)
+void UniqueIDBDatabase::commitTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction, const LockHolder& locker)
{
- transaction.setResult(m_backingStore->commitTransaction(transaction.info().identifier()));
+ transaction.setResult(m_backingStore->commitTransaction(transaction.info().identifier(), locker));
transaction.setState(UniqueIDBDatabaseTransaction::State::Committed);
}
-void UniqueIDBDatabase::finishActiveTransactions()
+void UniqueIDBDatabase::suspend()
{
ASSERT(isMainThread());
- for (auto& identifier : copyToVector(m_inProgressTransactions.keys())) {
- auto transaction = m_inProgressTransactions.get(identifier);
- abortTransactionOnMainThread(*transaction);
- }
+ if (m_isSuspended)
+ return;
+ m_isSuspended = true;
- for (auto& identifier : copyToVector(m_finishingTransactions.keys())) {
- if (!m_backingStore->hasTransaction(identifier))
- continue;
+ {
+ LockHolder locker(m_backingStoreLock);
+ for (auto& identifier : copyToVector(m_inProgressTransactions.keys())) {
+ auto transaction = m_inProgressTransactions.get(identifier);
+ abortTransactionOnMainThread(*transaction, locker);
+ }
- auto transaction = m_finishingTransactions.get(identifier);
- switch (transaction->state()) {
- case UniqueIDBDatabaseTransaction::State::Aborting:
- abortTransactionOnMainThread(*transaction);
- break;
- case UniqueIDBDatabaseTransaction::State::Committing:
- commitTransactionOnMainThread(*transaction);
- break;
- case UniqueIDBDatabaseTransaction::State::Running:
- case UniqueIDBDatabaseTransaction::State::Aborted:
- case UniqueIDBDatabaseTransaction::State::Committed:
- ASSERT_NOT_REACHED();
+ for (auto& identifier : copyToVector(m_finishingTransactions.keys())) {
+ if (!m_backingStore->hasTransaction(identifier, locker))
+ continue;
+
+ auto transaction = m_finishingTransactions.get(identifier);
+ switch (transaction->state()) {
+ case UniqueIDBDatabaseTransaction::State::Aborting:
+ abortTransactionOnMainThread(*transaction, locker);
+ break;
+ case UniqueIDBDatabaseTransaction::State::Committing:
+ commitTransactionOnMainThread(*transaction, locker);
+ break;
+ case UniqueIDBDatabaseTransaction::State::Running:
+ case UniqueIDBDatabaseTransaction::State::Aborted:
+ case UniqueIDBDatabaseTransaction::State::Committed:
+ ASSERT_NOT_REACHED();
+ }
}
}
+
+ m_backingStoreLock.lock();
}
+void UniqueIDBDatabase::resume()
+{
+ ASSERT(isMainThread());
+
+ if (!m_isSuspended)
+ return;
+ m_isSuspended = false;
+
+ ASSERT(m_backingStoreLock.isHeld());
+ m_backingStoreLock.unlock();
+}
+
} // namespace IDBServer
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (252786 => 252787)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h 2019-11-22 19:08:32 UTC (rev 252786)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h 2019-11-22 19:14:21 UTC (rev 252787)
@@ -116,7 +116,8 @@
bool hardClosedForUserDelete() const { return m_hardClosedForUserDelete; }
- void finishActiveTransactions();
+ void suspend();
+ void resume();
private:
void handleDatabaseOperations();
@@ -232,9 +233,9 @@
RefPtr<UniqueIDBDatabaseTransaction> takeNextRunnableTransaction(bool& hadDeferredTransactions);
bool prepareToFinishTransaction(UniqueIDBDatabaseTransaction&, UniqueIDBDatabaseTransaction::State);
- void abortTransactionOnMainThread(UniqueIDBDatabaseTransaction&);
- void commitTransactionOnMainThread(UniqueIDBDatabaseTransaction&);
-
+ void abortTransactionOnMainThread(UniqueIDBDatabaseTransaction&, const LockHolder&);
+ void commitTransactionOnMainThread(UniqueIDBDatabaseTransaction&, const LockHolder&);
+
void clearStalePendingOpenDBRequests();
void postDatabaseTask(CrossThreadTask&&);
@@ -269,6 +270,11 @@
bool m_isOpeningBackingStore { false };
IDBError m_backingStoreOpenError;
+
+ // Usually IDBBackingStore activities happens on the background thread only, but on process suspension,
+ // we need to force transactions of IDBBackingStore to stop on the main thread, and we need to make sure
+ // no IDBBackingStore activity can happen after process acknowledges suspension.
+ Lock m_backingStoreLock;
std::unique_ptr<IDBBackingStore> m_backingStore;
std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
std::unique_ptr<IDBDatabaseInfo> m_mostRecentDeletedDatabaseInfo;
@@ -306,6 +312,8 @@
HashSet<IDBResourceIdentifier> m_cursorPrefetches;
HashMap<uint64_t, uint64_t> m_pendingSpaceIncreaseTasks;
+
+ bool m_isSuspended { false };
};
} // namespace IDBServer