⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 252787 in webkit


Ignore:
Timestamp:
Nov 22, 2019, 11:14:21 AM (7 years ago)
Author:
sihui_liu@apple.com
Message:

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:
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252785 r252787  
     12019-11-22  Sihui Liu  <sihui_liu@apple.com>
     2
     3        IndexedDB: lock-based implementation of suspension
     4        https://bugs.webkit.org/show_bug.cgi?id=204379
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Covered by existing API test: IndexedDB.IndexedDBSuspendImminently
     9
     10        * Modules/indexeddb/server/IDBBackingStore.h:
     11        * Modules/indexeddb/server/IDBServer.cpp:
     12        (WebCore::IDBServer::IDBServer::tryStop):
     13        (WebCore::IDBServer::IDBServer::resume):
     14        * Modules/indexeddb/server/IDBServer.h:
     15        (WebCore::IDBServer::IDBServer::addDatabase):
     16        (WebCore::IDBServer::IDBServer::removeDatabase):
     17        * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
     18        (WebCore::IDBServer::MemoryIDBBackingStore::getOrEstablishDatabaseInfo):
     19        (WebCore::IDBServer::MemoryIDBBackingStore::beginTransaction):
     20        (WebCore::IDBServer::MemoryIDBBackingStore::abortTransaction):
     21        (WebCore::IDBServer::MemoryIDBBackingStore::commitTransaction):
     22        (WebCore::IDBServer::MemoryIDBBackingStore::createObjectStore):
     23        (WebCore::IDBServer::MemoryIDBBackingStore::deleteObjectStore):
     24        (WebCore::IDBServer::MemoryIDBBackingStore::renameObjectStore):
     25        (WebCore::IDBServer::MemoryIDBBackingStore::clearObjectStore):
     26        (WebCore::IDBServer::MemoryIDBBackingStore::createIndex):
     27        (WebCore::IDBServer::MemoryIDBBackingStore::deleteIndex):
     28        (WebCore::IDBServer::MemoryIDBBackingStore::renameIndex):
     29        (WebCore::IDBServer::MemoryIDBBackingStore::keyExistsInObjectStore):
     30        (WebCore::IDBServer::MemoryIDBBackingStore::deleteRange):
     31        (WebCore::IDBServer::MemoryIDBBackingStore::addRecord):
     32        (WebCore::IDBServer::MemoryIDBBackingStore::getRecord):
     33        (WebCore::IDBServer::MemoryIDBBackingStore::getAllRecords):
     34        (WebCore::IDBServer::MemoryIDBBackingStore::getIndexRecord):
     35        (WebCore::IDBServer::MemoryIDBBackingStore::getCount):
     36        (WebCore::IDBServer::MemoryIDBBackingStore::generateKeyNumber):
     37        (WebCore::IDBServer::MemoryIDBBackingStore::revertGeneratedKeyNumber):
     38        (WebCore::IDBServer::MemoryIDBBackingStore::maybeUpdateKeyGeneratorNumber):
     39        (WebCore::IDBServer::MemoryIDBBackingStore::openCursor):
     40        (WebCore::IDBServer::MemoryIDBBackingStore::iterateCursor):
     41        (WebCore::IDBServer::MemoryIDBBackingStore::infoForObjectStore):
     42        (WebCore::IDBServer::MemoryIDBBackingStore::deleteBackingStore):
     43        (WebCore::IDBServer::MemoryIDBBackingStore::close):
     44        (WebCore::IDBServer::MemoryIDBBackingStore::databaseSize const): Deleted.
     45        * Modules/indexeddb/server/MemoryIDBBackingStore.h:
     46        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
     47        (WebCore::IDBServer::SQLiteIDBBackingStore::getOrEstablishDatabaseInfo):
     48        (WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction):
     49        (WebCore::IDBServer::SQLiteIDBBackingStore::abortTransaction):
     50        (WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction):
     51        (WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore):
     52        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore):
     53        (WebCore::IDBServer::SQLiteIDBBackingStore::renameObjectStore):
     54        (WebCore::IDBServer::SQLiteIDBBackingStore::clearObjectStore):
     55        (WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
     56        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteIndex):
     57        (WebCore::IDBServer::SQLiteIDBBackingStore::renameIndex):
     58        (WebCore::IDBServer::SQLiteIDBBackingStore::keyExistsInObjectStore):
     59        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteRange):
     60        (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
     61        (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
     62        (WebCore::IDBServer::SQLiteIDBBackingStore::getAllRecords):
     63        (WebCore::IDBServer::SQLiteIDBBackingStore::getIndexRecord):
     64        (WebCore::IDBServer::SQLiteIDBBackingStore::getCount):
     65        (WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber):
     66        (WebCore::IDBServer::SQLiteIDBBackingStore::revertGeneratedKeyNumber):
     67        (WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber):
     68        (WebCore::IDBServer::SQLiteIDBBackingStore::openCursor):
     69        (WebCore::IDBServer::SQLiteIDBBackingStore::iterateCursor):
     70        (WebCore::IDBServer::SQLiteIDBBackingStore::prefetchCursor):
     71        (WebCore::IDBServer::SQLiteIDBBackingStore::infoForObjectStore):
     72        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore):
     73        (WebCore::IDBServer::SQLiteIDBBackingStore::close):
     74        (WebCore::IDBServer::SQLiteIDBBackingStore::hasTransaction const):
     75        (WebCore::IDBServer::SQLiteIDBBackingStore::databaseSize const): Deleted.
     76        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
     77        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     78        (WebCore::IDBServer::UniqueIDBDatabase::UniqueIDBDatabase):
     79        (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase):
     80        (WebCore::IDBServer::UniqueIDBDatabase::deleteBackingStore):
     81        (WebCore::IDBServer::UniqueIDBDatabase::performUnconditionalDeleteBackingStore):
     82        (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose):
     83        (WebCore::IDBServer::UniqueIDBDatabase::performStartVersionChangeTransaction):
     84        (WebCore::IDBServer::UniqueIDBDatabase::openBackingStore):
     85        (WebCore::IDBServer::UniqueIDBDatabase::performCreateObjectStore):
     86        (WebCore::IDBServer::UniqueIDBDatabase::performDeleteObjectStore):
     87        (WebCore::IDBServer::UniqueIDBDatabase::performRenameObjectStore):
     88        (WebCore::IDBServer::UniqueIDBDatabase::performClearObjectStore):
     89        (WebCore::IDBServer::UniqueIDBDatabase::performCreateIndex):
     90        (WebCore::IDBServer::UniqueIDBDatabase::performDeleteIndex):
     91        (WebCore::IDBServer::UniqueIDBDatabase::performRenameIndex):
     92        (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
     93        (WebCore::IDBServer::UniqueIDBDatabase::performGetRecord):
     94        (WebCore::IDBServer::UniqueIDBDatabase::performGetIndexRecord):
     95        (WebCore::IDBServer::UniqueIDBDatabase::performGetAllRecords):
     96        (WebCore::IDBServer::UniqueIDBDatabase::performGetCount):
     97        (WebCore::IDBServer::UniqueIDBDatabase::performDeleteRecord):
     98        (WebCore::IDBServer::UniqueIDBDatabase::performOpenCursor):
     99        (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor):
     100        (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor):
     101        (WebCore::IDBServer::UniqueIDBDatabase::performCommitTransaction):
     102        (WebCore::IDBServer::UniqueIDBDatabase::performAbortTransaction):
     103        (WebCore::IDBServer::UniqueIDBDatabase::performActivateTransactionInBackingStore):
     104        (WebCore::IDBServer::UniqueIDBDatabase::abortTransactionOnMainThread):
     105        (WebCore::IDBServer::UniqueIDBDatabase::commitTransactionOnMainThread):
     106        (WebCore::IDBServer::UniqueIDBDatabase::suspend):
     107        (WebCore::IDBServer::UniqueIDBDatabase::resume):
     108        (WebCore::IDBServer::UniqueIDBDatabase::finishActiveTransactions): Deleted.
     109        * Modules/indexeddb/server/UniqueIDBDatabase.h:
     110
    11112019-11-22  Chris Lord  <clord@igalia.com>
    2112
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h

    r251404 r252787  
    6161    virtual ~IDBBackingStore() { RELEASE_ASSERT(!isMainThread()); }
    6262
    63     virtual IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&) = 0;
     63    // All functions should take a LockHolder to make sure they have acquired lock when being called.
     64    // This is used to make sure database operations would not be performed when process is suspended.
     65    virtual IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&, const LockHolder&) = 0;
    6466
    65     virtual IDBError beginTransaction(const IDBTransactionInfo&) = 0;
    66     virtual IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) = 0;
    67     virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) = 0;
     67    virtual IDBError beginTransaction(const IDBTransactionInfo&, const LockHolder&) = 0;
     68    virtual IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) = 0;
     69    virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) = 0;
    6870
    69     virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) = 0;
    70     virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
    71     virtual IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) = 0;
    72     virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
    73     virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) = 0;
    74     virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) = 0;
    75     virtual IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) = 0;
    76     virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
    77     virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0;
    78     virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) = 0;
    79     virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue) = 0;
    80     virtual IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue) = 0;
    81     virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) = 0;
    82     virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0;
    83     virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) = 0;
    84     virtual IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber) = 0;
    85     virtual IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber) = 0;
    86     virtual IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) = 0;
    87     virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult) = 0;
    88     virtual bool prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier) = 0;
     71    virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const LockHolder&) = 0;
     72    virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) = 0;
     73    virtual IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&) = 0;
     74    virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) = 0;
     75    virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&, const LockHolder&) = 0;
     76    virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&) = 0;
     77    virtual IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&) = 0;
     78    virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists, const LockHolder&) = 0;
     79    virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, const LockHolder&) = 0;
     80    virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&, const LockHolder&) = 0;
     81    virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue, const LockHolder&) = 0;
     82    virtual IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue, const LockHolder&) = 0;
     83    virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue, const LockHolder&) = 0;
     84    virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount, const LockHolder&) = 0;
     85    virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber, const LockHolder&) = 0;
     86    virtual IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber, const LockHolder&) = 0;
     87    virtual IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber, const LockHolder&) = 0;
     88    virtual IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult, const LockHolder&) = 0;
     89    virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult, const LockHolder&) = 0;
     90    virtual bool prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const LockHolder&) = 0;
    8991
    90     virtual IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) = 0;
    91     virtual void deleteBackingStore() = 0;
     92    virtual IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&) = 0;
     93    virtual void deleteBackingStore(const LockHolder&) = 0;
    9294
    93     virtual bool supportsSimultaneousTransactions() = 0;
    94     virtual bool isEphemeral() = 0;
     95    virtual bool supportsSimultaneousTransactions(const LockHolder&) = 0;
     96    virtual bool isEphemeral(const LockHolder&) = 0;
    9597
    96     virtual void close() = 0;
    97     virtual uint64_t databaseSize() const = 0;
     98    virtual void close(const LockHolder&) = 0;
    9899
    99     virtual bool hasTransaction(const IDBResourceIdentifier&) const = 0;
     100    virtual bool hasTransaction(const IDBResourceIdentifier&, const LockHolder&) const = 0;
    100101protected:
    101102    IDBBackingStore() { RELEASE_ASSERT(!isMainThread()); }
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

    r252060 r252787  
    854854        return;
    855855
    856     suspendAndWait();
    857     if (shouldForceStop == ShouldForceStop::No && SQLiteDatabaseTracker::hasTransactionInProgress()) {
    858         CrossThreadTaskHandler::resume();
    859         return;
    860     }
    861 
    862     for (auto& database : m_uniqueIDBDatabaseMap.values())
    863         database->finishActiveTransactions();
     856    if (shouldForceStop == ShouldForceStop::No && SQLiteDatabaseTracker::hasTransactionInProgress())
     857        return;
     858
     859    for (auto& database : m_allUniqueIDBDatabases)
     860        database.suspend();
    864861}
    865862
     
    869866        return;
    870867
    871     CrossThreadTaskHandler::resume();
     868    for (auto& database : m_allUniqueIDBDatabases)
     869        database.resume();
    872870}
    873871
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h

    r252060 r252787  
    4242#include <wtf/RefCounted.h>
    4343#include <wtf/RefPtr.h>
    44 #include <wtf/WeakPtr.h>
     44#include <wtf/WeakHashSet.h>
    4545
    4646namespace WebCore {
     
    124124    WEBCORE_EXPORT void resume();
    125125
     126    void addDatabase(UniqueIDBDatabase& database) { m_allUniqueIDBDatabases.add(database); }
     127    void removeDatabase(UniqueIDBDatabase& database) { m_allUniqueIDBDatabases.remove(database); }
     128
    126129private:
    127130    IDBServer(PAL::SessionID, QuotaManagerGetter&&);
     
    191194    HashMap<IDBConnectionIdentifier, RefPtr<IDBConnectionToClient>> m_connectionMap;
    192195    HashMap<IDBDatabaseIdentifier, std::unique_ptr<UniqueIDBDatabase>> m_uniqueIDBDatabaseMap;
     196    WeakHashSet<UniqueIDBDatabase> m_allUniqueIDBDatabases;
    193197
    194198    HashMap<uint64_t, UniqueIDBDatabaseConnection*> m_databaseConnections;
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp

    r252672 r252787  
    6060MemoryIDBBackingStore::~MemoryIDBBackingStore() = default;
    6161
     62IDBError MemoryIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info, const LockHolder&)
     63{
     64    return getOrEstablishDatabaseInfo(info);
     65}
     66
    6267IDBError MemoryIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info)
    6368{
     
    7782}
    7883
    79 IDBError MemoryIDBBackingStore::beginTransaction(const IDBTransactionInfo& info)
     84IDBError MemoryIDBBackingStore::beginTransaction(const IDBTransactionInfo& info, const LockHolder&)
    8085{
    8186    LOG(IndexedDB, "MemoryIDBBackingStore::beginTransaction");
     
    102107}
    103108
    104 IDBError MemoryIDBBackingStore::abortTransaction(const IDBResourceIdentifier& transactionIdentifier)
     109IDBError MemoryIDBBackingStore::abortTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&)
    105110{
    106111    LOG(IndexedDB, "MemoryIDBBackingStore::abortTransaction - %s", transactionIdentifier.loggingString().utf8().data());
     
    115120}
    116121
    117 IDBError MemoryIDBBackingStore::commitTransaction(const IDBResourceIdentifier& transactionIdentifier)
     122IDBError MemoryIDBBackingStore::commitTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&)
    118123{
    119124    LOG(IndexedDB, "MemoryIDBBackingStore::commitTransaction - %s", transactionIdentifier.loggingString().utf8().data());
     
    128133}
    129134
    130 IDBError MemoryIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info)
     135IDBError MemoryIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info, const LockHolder&)
    131136{
    132137    LOG(IndexedDB, "MemoryIDBBackingStore::createObjectStore - adding OS %s with ID %" PRIu64, info.name().utf8().data(), info.identifier());
     
    151156}
    152157
    153 IDBError MemoryIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
     158IDBError MemoryIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&)
    154159{
    155160    LOG(IndexedDB, "MemoryIDBBackingStore::deleteObjectStore");
     
    174179}
    175180
    176 IDBError MemoryIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName)
     181IDBError MemoryIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&)
    177182{
    178183    LOG(IndexedDB, "MemoryIDBBackingStore::renameObjectStore");
     
    203208}
    204209
    205 IDBError MemoryIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
     210IDBError MemoryIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&)
    206211{
    207212    LOG(IndexedDB, "MemoryIDBBackingStore::clearObjectStore");
     
    224229}
    225230
    226 IDBError MemoryIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info)
     231IDBError MemoryIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info, const LockHolder&)
    227232{
    228233    LOG(IndexedDB, "MemoryIDBBackingStore::createIndex");
     
    239244}
    240245
    241 IDBError MemoryIDBBackingStore::deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier)
     246IDBError MemoryIDBBackingStore::deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&)
    242247{
    243248    LOG(IndexedDB, "MemoryIDBBackingStore::deleteIndex");
     
    254259}
    255260
    256 IDBError MemoryIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     261IDBError MemoryIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&)
    257262{
    258263    LOG(IndexedDB, "MemoryIDBBackingStore::renameIndex");
     
    307312}
    308313
    309 IDBError MemoryIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier&, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, bool& keyExists)
     314IDBError MemoryIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier&, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, bool& keyExists, const LockHolder&)
    310315{
    311316    LOG(IndexedDB, "MemoryIDBBackingStore::keyExistsInObjectStore");
     
    320325}
    321326
    322 IDBError MemoryIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range)
     327IDBError MemoryIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, const LockHolder&)
    323328{
    324329    LOG(IndexedDB, "MemoryIDBBackingStore::deleteRange");
     
    337342}
    338343
    339 IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value)
     344IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value, const LockHolder&)
    340345{
    341346    LOG(IndexedDB, "MemoryIDBBackingStore::addRecord");
     
    354359}
    355360
    356 IDBError MemoryIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, IDBGetRecordDataType type, IDBGetResult& outValue)
     361IDBError MemoryIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, IDBGetRecordDataType type, IDBGetResult& outValue, const LockHolder&)
    357362{
    358363    LOG(IndexedDB, "MemoryIDBBackingStore::getRecord");
     
    381386}
    382387
    383 IDBError MemoryIDBBackingStore::getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData& getAllRecordsData, IDBGetAllResult& result)
     388IDBError MemoryIDBBackingStore::getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData& getAllRecordsData, IDBGetAllResult& result, const LockHolder&)
    384389{
    385390    LOG(IndexedDB, "MemoryIDBBackingStore::getAllRecords");
     
    406411}
    407412
    408 IDBError MemoryIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType recordType, const IDBKeyRangeData& range, IDBGetResult& outValue)
     413IDBError MemoryIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType recordType, const IDBKeyRangeData& range, IDBGetResult& outValue, const LockHolder&)
    409414{
    410415    LOG(IndexedDB, "MemoryIDBBackingStore::getIndexRecord");
     
    423428}
    424429
    425 IDBError MemoryIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData& range, uint64_t& outCount)
     430IDBError MemoryIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData& range, uint64_t& outCount, const LockHolder&)
    426431{
    427432    LOG(IndexedDB, "MemoryIDBBackingStore::getCount");
     
    441446}
    442447
    443 IDBError MemoryIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber)
     448IDBError MemoryIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber, const LockHolder&)
    444449{
    445450    LOG(IndexedDB, "MemoryIDBBackingStore::generateKeyNumber");
     
    460465}
    461466
    462 IDBError MemoryIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber)
     467IDBError MemoryIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber, const LockHolder&)
    463468{
    464469    LOG(IndexedDB, "MemoryIDBBackingStore::revertGeneratedKeyNumber");
     
    475480}
    476481
    477 IDBError MemoryIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber)
     482IDBError MemoryIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber, const LockHolder&)
    478483{
    479484    LOG(IndexedDB, "MemoryIDBBackingStore::maybeUpdateKeyGeneratorNumber");
     
    504509}
    505510
    506 IDBError MemoryIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& outData)
     511IDBError MemoryIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& outData, const LockHolder&)
    507512{
    508513    LOG(IndexedDB, "MemoryIDBBackingStore::openCursor");
     
    546551}
    547552
    548 IDBError MemoryIDBBackingStore::iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData& data, IDBGetResult& outData)
     553IDBError MemoryIDBBackingStore::iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData& data, IDBGetResult& outData, const LockHolder&)
    549554{
    550555    LOG(IndexedDB, "MemoryIDBBackingStore::iterateCursor");
     
    593598}
    594599
    595 IDBObjectStoreInfo* MemoryIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier)
     600IDBObjectStoreInfo* MemoryIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&)
    596601{
    597602    ASSERT(m_databaseInfo);
     
    599604}
    600605
    601 void MemoryIDBBackingStore::deleteBackingStore()
     606void MemoryIDBBackingStore::deleteBackingStore(const LockHolder&)
    602607{
    603608    // The in-memory IDB backing store doesn't need to do any cleanup when it is deleted.
    604609}
    605610
    606 uint64_t MemoryIDBBackingStore::databaseSize() const
    607 {
    608     // FIXME: Implement this.
    609     return 0;
    610 }
    611 
    612 void MemoryIDBBackingStore::close()
     611void MemoryIDBBackingStore::close(const LockHolder&)
    613612{
    614613}
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h

    r250287 r252787  
    4848    ~MemoryIDBBackingStore() final;
    4949
    50     IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&) final;
     50    IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&, const LockHolder&) final;
     51    IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&);
    5152    void setDatabaseInfo(const IDBDatabaseInfo&);
    5253
    53     IDBError beginTransaction(const IDBTransactionInfo&) final;
    54     IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
    55     IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
    56     IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) final;
    57     IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
    58     IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) final;
    59     IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
    60     IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) final;
    61     IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;
    62     IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) final;
    63     IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
    64     IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
    65     IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) final;
    66     IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue) final;
    67     IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue) final;
    68     IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) final;
    69     IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) final;
    70     IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) final;
    71     IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber) final;
    72     IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber) final;
    73     IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) final;
    74     IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult) final;
    75     bool prefetchCursor(const IDBResourceIdentifier&, const IDBResourceIdentifier&) final { return false; }
     54    IDBError beginTransaction(const IDBTransactionInfo&, const LockHolder&) final;
     55    IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) final;
     56    IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) final;
     57    IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const LockHolder&) final;
     58    IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) final;
     59    IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&) final;
     60    IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) final;
     61    IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&, const LockHolder&) final;
     62    IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&) final;
     63    IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&) final;
     64    IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists, const LockHolder&) final;
     65    IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, const LockHolder&) final;
     66    IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&, const LockHolder&) final;
     67    IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue, const LockHolder&) final;
     68    IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue, const LockHolder&) final;
     69    IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue, const LockHolder&) final;
     70    IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount, const LockHolder&) final;
     71    IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber, const LockHolder&) final;
     72    IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber, const LockHolder&) final;
     73    IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber, const LockHolder&) final;
     74    IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult, const LockHolder&) final;
     75    IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult, const LockHolder&) final;
     76    bool prefetchCursor(const IDBResourceIdentifier&, const IDBResourceIdentifier&, const LockHolder&) final { return false; }
    7677
    77     IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) final;
    78     void deleteBackingStore() final;
     78    IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&) final;
     79    void deleteBackingStore(const LockHolder&) final;
    7980
    80     bool supportsSimultaneousTransactions() final { return true; }
    81     bool isEphemeral() final { return true; }
     81    bool supportsSimultaneousTransactions(const LockHolder&) final { return true; }
     82    bool isEphemeral(const LockHolder&) final { return true; }
    8283
    8384    void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&);
    8485    void restoreObjectStoreForVersionChangeAbort(Ref<MemoryObjectStore>&&);
    8586
    86     bool hasTransaction(const IDBResourceIdentifier& identifier) const final { return m_transactions.contains(identifier); }
     87    bool hasTransaction(const IDBResourceIdentifier& identifier, const LockHolder&) const final { return m_transactions.contains(identifier); }
    8788
    8889private:
    8990    RefPtr<MemoryObjectStore> takeObjectStoreByIdentifier(uint64_t identifier);
    90    
    91     uint64_t databaseSize() const final;
    92     void close() final;
     91
     92    void close(const LockHolder&) final;
    9393
    9494    IDBDatabaseIdentifier m_identifier;
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r251404 r252787  
    782782}
    783783
    784 IDBError SQLiteIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info)
     784IDBError SQLiteIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info, const LockHolder&)
    785785{
    786786    LOG(IndexedDB, "SQLiteIDBBackingStore::getOrEstablishDatabaseInfo - database %s", m_identifier.databaseName().utf8().data());
     
    855855}
    856856
    857 uint64_t SQLiteIDBBackingStore::databaseSize() const
    858 {
    859     ASSERT(!isMainThread());
    860     return SQLiteFileSystem::getDatabaseFileSize(fullDatabasePath());
    861 }
    862 
    863 IDBError SQLiteIDBBackingStore::beginTransaction(const IDBTransactionInfo& info)
     857IDBError SQLiteIDBBackingStore::beginTransaction(const IDBTransactionInfo& info, const LockHolder&)
    864858{
    865859    LOG(IndexedDB, "SQLiteIDBBackingStore::beginTransaction - %s", info.identifier().loggingString().utf8().data());
     
    892886}
    893887
    894 IDBError SQLiteIDBBackingStore::abortTransaction(const IDBResourceIdentifier& identifier)
     888IDBError SQLiteIDBBackingStore::abortTransaction(const IDBResourceIdentifier& identifier, const LockHolder&)
    895889{
    896890    LOG(IndexedDB, "SQLiteIDBBackingStore::abortTransaction - %s", identifier.loggingString().utf8().data());
     
    911905}
    912906
    913 IDBError SQLiteIDBBackingStore::commitTransaction(const IDBResourceIdentifier& identifier)
     907IDBError SQLiteIDBBackingStore::commitTransaction(const IDBResourceIdentifier& identifier, const LockHolder&)
    914908{
    915909    LOG(IndexedDB, "SQLiteIDBBackingStore::commitTransaction - %s", identifier.loggingString().utf8().data());
     
    936930}
    937931
    938 IDBError SQLiteIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info)
     932IDBError SQLiteIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info, const LockHolder&)
    939933{
    940934    LOG(IndexedDB, "SQLiteIDBBackingStore::createObjectStore - adding OS %s with ID %" PRIu64, info.name().utf8().data(), info.identifier());
     
    987981}
    988982
    989 IDBError SQLiteIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
     983IDBError SQLiteIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&)
    990984{
    991985    LOG(IndexedDB, "SQLiteIDBBackingStore::deleteObjectStore - object store %" PRIu64, objectStoreIdentifier);
     
    10781072}
    10791073
    1080 IDBError SQLiteIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName)
     1074IDBError SQLiteIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&)
    10811075{
    10821076    LOG(IndexedDB, "SQLiteIDBBackingStore::renameObjectStore - object store %" PRIu64, objectStoreIdentifier);
     
    11101104}
    11111105
    1112 IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID)
     1106IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const LockHolder&)
    11131107{
    11141108    LOG(IndexedDB, "SQLiteIDBBackingStore::clearObjectStore - object store %" PRIu64, objectStoreID);
     
    11511145}
    11521146
    1153 IDBError SQLiteIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info)
     1147IDBError SQLiteIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info, const LockHolder&)
    11541148{
    11551149    LOG(IndexedDB, "SQLiteIDBBackingStore::createIndex - ObjectStore %" PRIu64 ", Index %" PRIu64, info.objectStoreIdentifier(), info.identifier());
     
    13381332
    13391333
    1340 IDBError SQLiteIDBBackingStore::deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier)
     1334IDBError SQLiteIDBBackingStore::deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&)
    13411335{
    13421336    LOG(IndexedDB, "SQLiteIDBBackingStore::deleteIndex - object store %" PRIu64, objectStoreIdentifier);
     
    13831377}
    13841378
    1385 IDBError SQLiteIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     1379IDBError SQLiteIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&)
    13861380{
    13871381    LOG(IndexedDB, "SQLiteIDBBackingStore::renameIndex - object store %" PRIu64 ", index %" PRIu64, objectStoreIdentifier, indexIdentifier);
     
    14241418}
    14251419
    1426 IDBError SQLiteIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyData& keyData, bool& keyExists)
     1420IDBError SQLiteIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyData& keyData, bool& keyExists, const LockHolder&)
    14271421{
    14281422    LOG(IndexedDB, "SQLiteIDBBackingStore::keyExistsInObjectStore - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreID);
     
    15991593}
    16001594
    1601 IDBError SQLiteIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange)
     1595IDBError SQLiteIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, const LockHolder&)
    16021596{
    16031597    LOG(IndexedDB, "SQLiteIDBBackingStore::deleteRange - range %s, object store %" PRIu64, keyRange.loggingString().utf8().data(), objectStoreID);
     
    17191713}
    17201714
    1721 IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value)
     1715IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& objectStoreInfo, const IDBKeyData& keyData, const IDBValue& value, const LockHolder&)
    17221716{
    17231717    LOG(IndexedDB, "SQLiteIDBBackingStore::addRecord - key %s, object store %" PRIu64, keyData.loggingString().utf8().data(), objectStoreInfo.identifier());
     
    18811875}
    18821876
    1883 IDBError SQLiteIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, IDBGetRecordDataType type, IDBGetResult& resultValue)
     1877IDBError SQLiteIDBBackingStore::getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyRangeData& keyRange, IDBGetRecordDataType type, IDBGetResult& resultValue, const LockHolder&)
    18841878{
    18851879    LOG(IndexedDB, "SQLiteIDBBackingStore::getRecord - key range %s, object store %" PRIu64, keyRange.loggingString().utf8().data(), objectStoreID);
     
    20162010}
    20172011
    2018 IDBError SQLiteIDBBackingStore::getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData& getAllRecordsData, IDBGetAllResult& result)
     2012IDBError SQLiteIDBBackingStore::getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData& getAllRecordsData, IDBGetAllResult& result, const LockHolder&)
    20192013{
    20202014    return getAllRecordsData.indexIdentifier ? getAllIndexRecords(transactionIdentifier, getAllRecordsData, result) : getAllObjectStoreRecords(transactionIdentifier, getAllRecordsData, result);
     
    21962190}
    21972191
    2198 IDBError SQLiteIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t indexID, IndexedDB::IndexRecordType type, const IDBKeyRangeData& range, IDBGetResult& getResult)
     2192IDBError SQLiteIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t indexID, IndexedDB::IndexRecordType type, const IDBKeyRangeData& range, IDBGetResult& getResult, const LockHolder&)
    21992193{
    22002194    LOG(IndexedDB, "SQLiteIDBBackingStore::getIndexRecord - %s", range.loggingString().utf8().data());
     
    22982292}
    22992293
    2300 IDBError SQLiteIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData& range, uint64_t& outCount)
     2294IDBError SQLiteIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData& range, uint64_t& outCount, const LockHolder&)
    23012295{
    23022296    LOG(IndexedDB, "SQLiteIDBBackingStore::getCount - object store %" PRIu64, objectStoreIdentifier);
     
    24152409}
    24162410
    2417 IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t& generatedKey)
     2411IDBError SQLiteIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t& generatedKey, const LockHolder&)
    24182412{
    24192413    LOG(IndexedDB, "SQLiteIDBBackingStore::generateKeyNumber");
     
    24432437}
    24442438
    2445 IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t newKeyNumber)
     2439IDBError SQLiteIDBBackingStore::revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, uint64_t newKeyNumber, const LockHolder&)
    24462440{
    24472441    LOG(IndexedDB, "SQLiteIDBBackingStore::revertGeneratedKeyNumber - object store %" PRIu64 ", reverted number %" PRIu64, objectStoreID, newKeyNumber);
     
    24632457}
    24642458
    2465 IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, double newKeyNumber)
     2459IDBError SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, double newKeyNumber, const LockHolder&)
    24662460{
    24672461    LOG(IndexedDB, "SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber");
     
    24902484}
    24912485
    2492 IDBError SQLiteIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& result)
     2486IDBError SQLiteIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& result, const LockHolder&)
    24932487{
    24942488    ASSERT(m_sqliteDB);
     
    25132507}
    25142508
    2515 IDBError SQLiteIDBBackingStore::iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData& data, IDBGetResult& result)
     2509IDBError SQLiteIDBBackingStore::iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData& data, IDBGetResult& result, const LockHolder&)
    25162510{
    25172511    LOG(IndexedDB, "SQLiteIDBBackingStore::iterateCursor");
     
    25562550}
    25572551
    2558 bool SQLiteIDBBackingStore::prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier)
     2552bool SQLiteIDBBackingStore::prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const LockHolder&)
    25592553{
    25602554    LOG(IndexedDB, "SQLiteIDBBackingStore::prefetchCursor");
     
    25722566}
    25732567
     2568IDBObjectStoreInfo* SQLiteIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&)
     2569{
     2570    return infoForObjectStore(objectStoreIdentifier);
     2571}
     2572
    25742573IDBObjectStoreInfo* SQLiteIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier)
    25752574{
     
    25782577}
    25792578
    2580 void SQLiteIDBBackingStore::deleteBackingStore()
     2579void SQLiteIDBBackingStore::deleteBackingStore(const LockHolder&)
    25812580{
    25822581    String dbFilename = fullDatabasePath();
     
    26482647}
    26492648
    2650 void SQLiteIDBBackingStore::close()
     2649void SQLiteIDBBackingStore::close(const LockHolder&)
    26512650{
    26522651    closeSQLiteDB();
     
    26642663}
    26652664
    2666 bool SQLiteIDBBackingStore::hasTransaction(const IDBResourceIdentifier& transactionIdentifier) const
     2665bool SQLiteIDBBackingStore::hasTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) const
    26672666{
    26682667    ASSERT(isMainThread());
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h

    r251404 r252787  
    5555    ~SQLiteIDBBackingStore() final;
    5656
    57     IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&) final;
    58 
    59     IDBError beginTransaction(const IDBTransactionInfo&) final;
    60     IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
    61     IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
    62     IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) final;
    63     IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
    64     IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) final;
    65     IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
    66     IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) final;
    67     IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;
    68     IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) final;
    69     IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
    70     IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
    71     IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) final;
    72     IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue) final;
    73     IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue) final;
    74     IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) final;
    75     IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) final;
    76     IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) final;
    77     IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber) final;
    78     IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber) final;
    79     IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) final;
    80     IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult) final;
    81     bool prefetchCursor(const IDBResourceIdentifier&, const IDBResourceIdentifier&) final;
    82 
    83     IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) final;
    84     void deleteBackingStore() final;
    85 
    86     bool supportsSimultaneousTransactions() final { return false; }
    87     bool isEphemeral() final { return false; }
     57    IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&, const LockHolder&) final;
     58
     59    IDBError beginTransaction(const IDBTransactionInfo&, const LockHolder&) final;
     60    IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) final;
     61    IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier, const LockHolder&) final;
     62    IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const LockHolder&) final;
     63    IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) final;
     64    IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName, const LockHolder&) final;
     65    IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const LockHolder&) final;
     66    IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&, const LockHolder&) final;
     67    IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const LockHolder&) final;
     68    IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, const LockHolder&) final;
     69    IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists, const LockHolder&) final;
     70    IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, const LockHolder&) final;
     71    IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&, const LockHolder&) final;
     72    IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue, const LockHolder&) final;
     73    IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue, const LockHolder&) final;
     74    IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue, const LockHolder&) final;
     75    IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount, const LockHolder&) final;
     76    IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber, const LockHolder&) final;
     77    IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber, const LockHolder&) final;
     78    IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber, const LockHolder&) final;
     79    IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult, const LockHolder&) final;
     80    IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult, const LockHolder&) final;
     81    bool prefetchCursor(const IDBResourceIdentifier&, const IDBResourceIdentifier&, const LockHolder&) final;
     82
     83    IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier, const LockHolder&) final;
     84    void deleteBackingStore(const LockHolder&) final;
     85
     86    bool supportsSimultaneousTransactions(const LockHolder&) final { return false; }
     87    bool isEphemeral(const LockHolder&) final { return false; }
     88
     89    bool hasTransaction(const IDBResourceIdentifier&, const LockHolder&) const final;
    8890
    8991    void unregisterCursor(SQLiteIDBCursor&);
    9092
    9193    IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths);
     94    IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier);
    9295
    9396    static String databaseNameFromEncodedFilename(const String&);
     
    97100    static String fullDatabasePathForDirectory(const String&);
    98101    static String databaseNameFromFile(const String&);
    99 
    100     bool hasTransaction(const IDBResourceIdentifier&) const final;
    101102
    102103    PAL::SessionID sessionID() const { return m_sessionID; }
     
    133134
    134135    void closeSQLiteDB();
    135     void close() final;
    136    
    137     uint64_t databaseSize() const final;
     136    void close(const LockHolder&) final;
    138137
    139138    enum class SQL : size_t {
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r252673 r252787  
    123123    , m_operationAndTransactionTimer(*this, &UniqueIDBDatabase::operationAndTransactionTimerFired)
    124124{
     125    m_server->addDatabase(*this);
    125126    LOG(IndexedDB, "UniqueIDBDatabase::UniqueIDBDatabase() (%p) %s", this, m_identifier.debugString().utf8().data());
    126127}
     
    140141    RELEASE_ASSERT(m_databaseReplyQueue.isKilled());
    141142    RELEASE_ASSERT(!m_backingStore);
     143
     144    m_server->removeDatabase(*this);
    142145}
    143146
     
    378381    uint64_t deletedVersion = 0;
    379382
    380     if (m_backingStore) {
    381         m_backingStore->deleteBackingStore();
    382 
    383         m_backingStore = nullptr;
    384         m_backingStoreSupportsSimultaneousTransactions = false;
    385         m_backingStoreIsEphemeral = false;
    386     } else {
    387         auto backingStore = m_server->createBackingStore(identifier);
    388 
    389         IDBDatabaseInfo databaseInfo;
    390         auto error = backingStore->getOrEstablishDatabaseInfo(databaseInfo);
    391         if (!error.isNull())
    392             LOG_ERROR("Error getting database info from database %s that we are trying to delete", identifier.debugString().utf8().data());
    393 
    394         deletedVersion = databaseInfo.version();
    395         backingStore->deleteBackingStore();
     383    {
     384        LockHolder locker(m_backingStoreLock);
     385        if (m_backingStore) {
     386            m_backingStore->deleteBackingStore(locker);
     387            m_backingStore = nullptr;
     388            m_backingStoreSupportsSimultaneousTransactions = false;
     389            m_backingStoreIsEphemeral = false;
     390        } else {
     391            auto backingStore = m_server->createBackingStore(identifier);
     392
     393            IDBDatabaseInfo databaseInfo;
     394            auto error = backingStore->getOrEstablishDatabaseInfo(databaseInfo, locker);
     395            if (!error.isNull())
     396                LOG_ERROR("Error getting database info from database %s that we are trying to delete", identifier.debugString().utf8().data());
     397
     398            deletedVersion = databaseInfo.version();
     399            backingStore->deleteBackingStore(locker);
     400        }
    396401    }
    397402
     
    404409    LOG(IndexedDB, "(db) UniqueIDBDatabase::performUnconditionalDeleteBackingStore");
    405410
    406     if (m_backingStore)
    407         m_backingStore->deleteBackingStore();
     411    {
     412        LockHolder locker(m_backingStoreLock);
     413        if (m_backingStore)
     414            m_backingStore->deleteBackingStore(locker);
     415    }
    408416
    409417    shutdownForClose();
     
    429437    LOG(IndexedDB, "(db) UniqueIDBDatabase::shutdownForClose");
    430438
    431     if (m_backingStore)
    432         m_backingStore->close();
    433 
    434     m_backingStore = nullptr;
     439    if (m_backingStore) {
     440        LockHolder locker(m_backingStoreLock);
     441        m_backingStore->close(locker);
     442        m_backingStore = nullptr;
     443    }
    435444    m_backingStoreSupportsSimultaneousTransactions = false;
    436445    m_backingStoreIsEphemeral = false;
     
    671680    LOG(IndexedDB, "(db) UniqueIDBDatabase::performStartVersionChangeTransaction");
    672681
    673     IDBError error = m_backingStore->beginTransaction(info);
     682    IDBError error;
     683    {
     684        LockHolder locker(m_backingStoreLock);
     685        error = m_backingStore->beginTransaction(info, locker);
     686    }
     687
    674688    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformStartVersionChangeTransaction, error));
    675689}
     
    828842
    829843    ASSERT(!m_backingStore);
    830     m_backingStore = m_server->createBackingStore(identifier);
    831     m_backingStoreSupportsSimultaneousTransactions = m_backingStore->supportsSimultaneousTransactions();
    832     m_backingStoreIsEphemeral = m_backingStore->isEphemeral();
    833844
    834845    IDBDatabaseInfo databaseInfo;
    835     auto error = m_backingStore->getOrEstablishDatabaseInfo(databaseInfo);
     846    IDBError error;
     847    {
     848        LockHolder locker(m_backingStoreLock);
     849        m_backingStore = m_server->createBackingStore(identifier);
     850        m_backingStoreSupportsSimultaneousTransactions = m_backingStore->supportsSimultaneousTransactions(locker);
     851        m_backingStoreIsEphemeral = m_backingStore->isEphemeral(locker);
     852        error = m_backingStore->getOrEstablishDatabaseInfo(databaseInfo, locker);
     853    }
    836854
    837855    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didOpenBackingStore, databaseInfo, error,  taskIdentifier));
     
    893911
    894912    ASSERT(m_backingStore);
    895     IDBError error = m_backingStore->createObjectStore(transactionIdentifier, info);
     913    IDBError error;
     914    {
     915        LockHolder locker(m_backingStoreLock);
     916        error = m_backingStore->createObjectStore(transactionIdentifier, info, locker);
     917    }
    896918
    897919    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCreateObjectStore, callbackIdentifier, error, info));
     
    945967
    946968    ASSERT(m_backingStore);
    947     IDBError error = m_backingStore->deleteObjectStore(transactionIdentifier, objectStoreIdentifier);
     969    IDBError error;
     970    {
     971        LockHolder locker(m_backingStoreLock);
     972        error = m_backingStore->deleteObjectStore(transactionIdentifier, objectStoreIdentifier, locker);
     973    }
    948974
    949975    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteObjectStore, callbackIdentifier, error, objectStoreIdentifier));
     
    10021028
    10031029    ASSERT(m_backingStore);
    1004     m_backingStore->renameObjectStore(transactionIdentifier, objectStoreIdentifier, newName);
     1030    {
     1031        LockHolder locker(m_backingStoreLock);
     1032        m_backingStore->renameObjectStore(transactionIdentifier, objectStoreIdentifier, newName, locker);
     1033    }
    10051034
    10061035    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformRenameObjectStore, callbackIdentifier, error, objectStoreIdentifier, newName));
     
    10471076
    10481077    ASSERT(m_backingStore);
    1049     IDBError error = m_backingStore->clearObjectStore(transactionIdentifier, objectStoreIdentifier);
     1078    IDBError error;
     1079    {
     1080        LockHolder locker(m_backingStoreLock);
     1081        error = m_backingStore->clearObjectStore(transactionIdentifier, objectStoreIdentifier, locker);
     1082    }
    10501083
    10511084    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformClearObjectStore, callbackIdentifier, error));
     
    10971130    IDBError error;
    10981131    ASSERT(m_backingStore);
    1099     if (!m_backingStore) {
    1100         RELEASE_LOG_ERROR(IndexedDB, "%p - UniqueIDBDatabase::performCreateIndex: m_backingStore is null", this);
    1101         error = IDBError(InvalidStateError, "Backing store is invalid for call to create index"_s);
    1102         postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCreateIndex, callbackIdentifier, error, info));
    1103         return;
    1104     }
    1105 
    1106     error = m_backingStore->createIndex(transactionIdentifier, info);
     1132    {
     1133        LockHolder locker(m_backingStoreLock);
     1134        if (!m_backingStore) {
     1135            RELEASE_LOG_ERROR(IndexedDB, "%p - UniqueIDBDatabase::performCreateIndex: m_backingStore is null", this);
     1136            error = IDBError(InvalidStateError, "Backing store is invalid for call to create index"_s);
     1137            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCreateIndex, callbackIdentifier, error, info));
     1138            return;
     1139        }
     1140        error = m_backingStore->createIndex(transactionIdentifier, info, locker);
     1141    }
     1142
    11071143    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCreateIndex, callbackIdentifier, error, info));
    11081144}
     
    11661202
    11671203    ASSERT(m_backingStore);
    1168     IDBError error = m_backingStore->deleteIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier);
     1204    IDBError error;
     1205    {
     1206        LockHolder locker(m_backingStoreLock);
     1207        error = m_backingStore->deleteIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier, locker);
     1208    }
    11691209
    11701210    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteIndex, callbackIdentifier, error, objectStoreIdentifier, indexIdentifier));
     
    12301270
    12311271    ASSERT(m_backingStore);
    1232     m_backingStore->renameIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier, newName);
     1272    {
     1273        LockHolder locker(m_backingStoreLock);
     1274        m_backingStore->renameIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier, newName, locker);
     1275    }
    12331276
    12341277    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformRenameIndex, callbackIdentifier, error, objectStoreIdentifier, indexIdentifier, newName));
     
    13001343    }
    13011344
    1302     if (!m_backingStore) {
    1303         RELEASE_LOG_ERROR(IndexedDB, "%p - UniqueIDBDatabase::performPutOrAdd: m_backingStore is null", this);
    1304         error = IDBError(InvalidStateError, "Backing store is invalid for call to put or add"_s);
    1305         postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
    1306         return;
    1307     }
    1308 
    1309     auto* objectStoreInfo = m_backingStore->infoForObjectStore(objectStoreIdentifier);
    1310     if (!objectStoreInfo) {
    1311         error = IDBError(InvalidStateError, "Object store cannot be found in the backing store"_s);
    1312         postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
    1313         return;
    1314     }
    1315 
    1316     bool usedKeyIsGenerated = false;
    1317     uint64_t keyNumber;
    1318     auto generatedKeyResetter = WTF::makeScopeExit([this, transactionIdentifier, objectStoreIdentifier, &keyNumber, &usedKeyIsGenerated]() {
    1319         if (usedKeyIsGenerated)
    1320             m_backingStore->revertGeneratedKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber);
    1321     });
    1322     if (objectStoreInfo->autoIncrement() && !keyData.isValid()) {
    1323         error = m_backingStore->generateKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber);
     1345    {
     1346        LockHolder locker(m_backingStoreLock);
     1347        if (!m_backingStore) {
     1348            RELEASE_LOG_ERROR(IndexedDB, "%p - UniqueIDBDatabase::performPutOrAdd: m_backingStore is null", this);
     1349            error = IDBError(InvalidStateError, "Backing store is invalid for call to put or add"_s);
     1350            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
     1351            return;
     1352        }
     1353
     1354        auto* objectStoreInfo = m_backingStore->infoForObjectStore(objectStoreIdentifier, locker);
     1355        if (!objectStoreInfo) {
     1356            error = IDBError(InvalidStateError, "Object store cannot be found in the backing store"_s);
     1357            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
     1358            return;
     1359        }
     1360
     1361        bool usedKeyIsGenerated = false;
     1362        uint64_t keyNumber;
     1363        auto generatedKeyResetter = WTF::makeScopeExit([this, transactionIdentifier, objectStoreIdentifier, &keyNumber, &usedKeyIsGenerated, &locker]() {
     1364            if (usedKeyIsGenerated)
     1365                m_backingStore->revertGeneratedKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber, locker);
     1366        });
     1367        if (objectStoreInfo->autoIncrement() && !keyData.isValid()) {
     1368            error = m_backingStore->generateKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber, locker);
     1369            if (!error.isNull()) {
     1370                postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
     1371                return;
     1372            }
     1373
     1374            usedKey.setNumberValue(keyNumber);
     1375            usedKeyIsGenerated = true;
     1376        } else
     1377            usedKey = keyData;
     1378
     1379        if (overwriteMode == IndexedDB::ObjectStoreOverwriteMode::NoOverwrite) {
     1380            bool keyExists;
     1381            error = m_backingStore->keyExistsInObjectStore(transactionIdentifier, objectStoreIdentifier, usedKey, keyExists, locker);
     1382            if (error.isNull() && keyExists)
     1383                error = IDBError(ConstraintError, "Key already exists in the object store"_s);
     1384
     1385            if (!error.isNull()) {
     1386                postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
     1387                return;
     1388            }
     1389        }
     1390
     1391        // 3.4.1 Object Store Storage Operation
     1392        // ...If a record already exists in store ...
     1393        // then remove the record from store using the steps for deleting records from an object store...
     1394        // This is important because formally deleting it from from the object store also removes it from the appropriate indexes.
     1395        error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, usedKey, locker);
    13241396        if (!error.isNull()) {
    13251397            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
    13261398            return;
    13271399        }
    1328        
    1329         usedKey.setNumberValue(keyNumber);
    1330         usedKeyIsGenerated = true;
    1331     } else
    1332         usedKey = keyData;
    1333 
    1334     if (overwriteMode == IndexedDB::ObjectStoreOverwriteMode::NoOverwrite) {
    1335         bool keyExists;
    1336         error = m_backingStore->keyExistsInObjectStore(transactionIdentifier, objectStoreIdentifier, usedKey, keyExists);
    1337         if (error.isNull() && keyExists)
    1338             error = IDBError(ConstraintError, "Key already exists in the object store"_s);
     1400
     1401        error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue, locker);
    13391402
    13401403        if (!error.isNull()) {
     
    13421405            return;
    13431406        }
    1344     }
    1345 
    1346     // 3.4.1 Object Store Storage Operation
    1347     // ...If a record already exists in store ...
    1348     // then remove the record from store using the steps for deleting records from an object store...
    1349     // This is important because formally deleting it from from the object store also removes it from the appropriate indexes.
    1350     error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, usedKey);
    1351     if (!error.isNull()) {
    1352         postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
    1353         return;
    1354     }
    1355 
    1356     error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue);
    1357 
    1358     if (!error.isNull()) {
    1359         postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
    1360         return;
    1361     }
    1362 
    1363     if (overwriteMode != IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor && objectStoreInfo->autoIncrement() && keyData.type() == IndexedDB::KeyType::Number)
    1364         error = m_backingStore->maybeUpdateKeyGeneratorNumber(transactionIdentifier, objectStoreIdentifier, keyData.number());
    1365 
    1366     generatedKeyResetter.release();
     1407
     1408        if (overwriteMode != IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor && objectStoreInfo->autoIncrement() && keyData.type() == IndexedDB::KeyType::Number)
     1409            error = m_backingStore->maybeUpdateKeyGeneratorNumber(transactionIdentifier, objectStoreIdentifier, keyData.number(), locker);
     1410
     1411        generatedKeyResetter.release();
     1412    }
    13671413    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
    13681414}
     
    14341480
    14351481    IDBGetResult result;
    1436     IDBError error = m_backingStore->getRecord(transactionIdentifier, objectStoreIdentifier, keyRangeData, type, result);
     1482    IDBError error;
     1483    {
     1484        LockHolder locker(m_backingStoreLock);
     1485        error = m_backingStore->getRecord(transactionIdentifier, objectStoreIdentifier, keyRangeData, type, result, locker);
     1486    }
    14371487
    14381488    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetRecord, callbackIdentifier, error, result));
     
    14451495
    14461496    ASSERT(m_backingStore);
    1447 
    14481497    IDBGetResult result;
    1449     IDBError error = m_backingStore->getIndexRecord(transactionIdentifier, objectStoreIdentifier, indexIdentifier, recordType, range, result);
     1498    IDBError error;
     1499    {
     1500        LockHolder locker(m_backingStoreLock);
     1501        error = m_backingStore->getIndexRecord(transactionIdentifier, objectStoreIdentifier, indexIdentifier, recordType, range, result, locker);
     1502    }
    14501503
    14511504    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetRecord, callbackIdentifier, error, result));
     
    14681521
    14691522    IDBGetAllResult result;
    1470     IDBError error = m_backingStore->getAllRecords(transactionIdentifier, getAllRecordsData, result);
     1523    IDBError error;
     1524    {
     1525        LockHolder locker(m_backingStoreLock);
     1526        error = m_backingStore->getAllRecords(transactionIdentifier, getAllRecordsData, result, locker);
     1527    }
    14711528
    14721529    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetAllRecords, callbackIdentifier, error, WTFMove(result)));
     
    15121569
    15131570    uint64_t count;
    1514     IDBError error = m_backingStore->getCount(transactionIdentifier, objectStoreIdentifier, indexIdentifier, keyRangeData, count);
     1571    IDBError error;
     1572    {
     1573        LockHolder locker(m_backingStoreLock);
     1574        error = m_backingStore->getCount(transactionIdentifier, objectStoreIdentifier, indexIdentifier, keyRangeData, count, locker);
     1575    }
    15151576
    15161577    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetCount, callbackIdentifier, error, count));
     
    15521613    LOG(IndexedDB, "(db) UniqueIDBDatabase::performDeleteRecord");
    15531614
    1554     IDBError error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, range);
     1615    IDBError error;
     1616    {
     1617        LockHolder locker(m_backingStoreLock);
     1618        error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, range, locker);
     1619    }
    15551620
    15561621    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteRecord, callbackIdentifier, error));
     
    15931658
    15941659    IDBGetResult result;
    1595     IDBError error = m_backingStore->openCursor(transactionIdentifier, info, result);
     1660    IDBError error;
     1661    {
     1662        LockHolder locker(m_backingStoreLock);
     1663        error = m_backingStore->openCursor(transactionIdentifier, info, result, locker);
     1664    }
    15961665
    15971666    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformOpenCursor, callbackIdentifier, error, result));
     
    16341703
    16351704    IDBGetResult result;
    1636     IDBError error = m_backingStore->iterateCursor(transactionIdentifier, cursorIdentifier, data, result);
     1705    IDBError error;
     1706    {
     1707        LockHolder locker(m_backingStoreLock);
     1708        error = m_backingStore->iterateCursor(transactionIdentifier, cursorIdentifier, data, result, locker);
     1709    }
    16371710
    16381711    if (error.isNull()) {
     
    16511724    LOG(IndexedDB, "(db) UniqueIDBDatabase::performPrefetchCursor");
    16521725
    1653     if (m_hardClosedForUserDelete || !m_backingStore->prefetchCursor(transactionIdentifier, cursorIdentifier))
     1726    if (m_hardClosedForUserDelete) {
    16541727        m_cursorPrefetches.remove(cursorIdentifier);
    1655     else
    1656         postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performPrefetchCursor, transactionIdentifier, cursorIdentifier));
     1728        return;
     1729    }
     1730
     1731    {
     1732        LockHolder locker(m_backingStoreLock);
     1733        if (!m_backingStore->prefetchCursor(transactionIdentifier, cursorIdentifier, locker)) {
     1734            m_cursorPrefetches.remove(cursorIdentifier);
     1735            return;
     1736        }
     1737    }
     1738
     1739    postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performPrefetchCursor, transactionIdentifier, cursorIdentifier));
    16571740}
    16581741
     
    17191802    LOG(IndexedDB, "(db) UniqueIDBDatabase::performCommitTransaction - %s", transactionIdentifier.loggingString().utf8().data());
    17201803
    1721     IDBError error = m_backingStore->commitTransaction(transactionIdentifier);
     1804    IDBError error;
     1805    {
     1806        LockHolder locker(m_backingStoreLock);
     1807        error = m_backingStore->commitTransaction(transactionIdentifier, locker);
     1808    }
    17221809    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformCommitTransaction, callbackIdentifier, error, transactionIdentifier));
    17231810}
     
    18091896    LOG(IndexedDB, "(db) UniqueIDBDatabase::performAbortTransaction - %s", transactionIdentifier.loggingString().utf8().data());
    18101897
    1811     IDBError error = m_backingStore->abortTransaction(transactionIdentifier);
     1898    IDBError error;
     1899    {
     1900        LockHolder locker(m_backingStoreLock);
     1901        error = m_backingStore->abortTransaction(transactionIdentifier, locker);
     1902    }
    18121903    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformAbortTransaction, callbackIdentifier, error, transactionIdentifier));
    18131904}
     
    20192110    LOG(IndexedDB, "(db) UniqueIDBDatabase::performActivateTransactionInBackingStore");
    20202111
    2021     IDBError error = m_backingStore->beginTransaction(info);
     2112    IDBError error;
     2113    {
     2114        LockHolder locker(m_backingStoreLock);
     2115        error = m_backingStore->beginTransaction(info, locker);
     2116    }
     2117
    20222118    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformActivateTransactionInBackingStore, callbackIdentifier, error));
    20232119}
     
    23522448}
    23532449
    2354 void UniqueIDBDatabase::abortTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction)
    2355 {
    2356     transaction.setResult(m_backingStore->abortTransaction(transaction.info().identifier()));
     2450void UniqueIDBDatabase::abortTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction, const LockHolder& locker)
     2451{
     2452    transaction.setResult(m_backingStore->abortTransaction(transaction.info().identifier(), locker));
    23572453    transaction.setState(UniqueIDBDatabaseTransaction::State::Aborted);
    23582454}
    23592455
    2360 void UniqueIDBDatabase::commitTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction)
    2361 {
    2362     transaction.setResult(m_backingStore->commitTransaction(transaction.info().identifier()));
     2456void UniqueIDBDatabase::commitTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction, const LockHolder& locker)
     2457{
     2458    transaction.setResult(m_backingStore->commitTransaction(transaction.info().identifier(), locker));
    23632459    transaction.setState(UniqueIDBDatabaseTransaction::State::Committed);
    23642460}
    23652461
    2366 void UniqueIDBDatabase::finishActiveTransactions()
    2367 {
    2368     ASSERT(isMainThread());
    2369 
    2370     for (auto& identifier : copyToVector(m_inProgressTransactions.keys())) {
    2371         auto transaction = m_inProgressTransactions.get(identifier);
    2372         abortTransactionOnMainThread(*transaction);
    2373     }
    2374 
    2375     for (auto& identifier : copyToVector(m_finishingTransactions.keys())) {
    2376         if (!m_backingStore->hasTransaction(identifier))
    2377             continue;
    2378 
    2379         auto transaction = m_finishingTransactions.get(identifier);
    2380         switch (transaction->state()) {
    2381         case UniqueIDBDatabaseTransaction::State::Aborting:
    2382             abortTransactionOnMainThread(*transaction);
    2383             break;
    2384         case UniqueIDBDatabaseTransaction::State::Committing:
    2385             commitTransactionOnMainThread(*transaction);
    2386             break;
    2387         case UniqueIDBDatabaseTransaction::State::Running:
    2388         case UniqueIDBDatabaseTransaction::State::Aborted:
    2389         case UniqueIDBDatabaseTransaction::State::Committed:
    2390             ASSERT_NOT_REACHED();
    2391         }
    2392     }
     2462void UniqueIDBDatabase::suspend()
     2463{
     2464    ASSERT(isMainThread());
     2465
     2466    if (m_isSuspended)
     2467        return;
     2468    m_isSuspended = true;
     2469
     2470    {
     2471        LockHolder locker(m_backingStoreLock);
     2472        for (auto& identifier : copyToVector(m_inProgressTransactions.keys())) {
     2473            auto transaction = m_inProgressTransactions.get(identifier);
     2474            abortTransactionOnMainThread(*transaction, locker);
     2475        }
     2476
     2477        for (auto& identifier : copyToVector(m_finishingTransactions.keys())) {
     2478            if (!m_backingStore->hasTransaction(identifier, locker))
     2479                continue;
     2480
     2481            auto transaction = m_finishingTransactions.get(identifier);
     2482            switch (transaction->state()) {
     2483            case UniqueIDBDatabaseTransaction::State::Aborting:
     2484                abortTransactionOnMainThread(*transaction, locker);
     2485                break;
     2486            case UniqueIDBDatabaseTransaction::State::Committing:
     2487                commitTransactionOnMainThread(*transaction, locker);
     2488                break;
     2489            case UniqueIDBDatabaseTransaction::State::Running:
     2490            case UniqueIDBDatabaseTransaction::State::Aborted:
     2491            case UniqueIDBDatabaseTransaction::State::Committed:
     2492                ASSERT_NOT_REACHED();
     2493            }
     2494        }
     2495    }
     2496
     2497    m_backingStoreLock.lock();
     2498}
     2499
     2500void UniqueIDBDatabase::resume()
     2501{
     2502    ASSERT(isMainThread());
     2503
     2504    if (!m_isSuspended)
     2505        return;
     2506    m_isSuspended = false;
     2507
     2508    ASSERT(m_backingStoreLock.isHeld());
     2509    m_backingStoreLock.unlock();
    23932510}
    23942511
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h

    r252060 r252787  
    117117    bool hardClosedForUserDelete() const { return m_hardClosedForUserDelete; }
    118118
    119     void finishActiveTransactions();
     119    void suspend();
     120    void resume();
    120121
    121122private:
     
    233234
    234235    bool prepareToFinishTransaction(UniqueIDBDatabaseTransaction&, UniqueIDBDatabaseTransaction::State);
    235     void abortTransactionOnMainThread(UniqueIDBDatabaseTransaction&);
    236     void commitTransactionOnMainThread(UniqueIDBDatabaseTransaction&);
    237    
     236    void abortTransactionOnMainThread(UniqueIDBDatabaseTransaction&, const LockHolder&);
     237    void commitTransactionOnMainThread(UniqueIDBDatabaseTransaction&, const LockHolder&);
     238
    238239    void clearStalePendingOpenDBRequests();
    239240
     
    270271    bool m_isOpeningBackingStore { false };
    271272    IDBError m_backingStoreOpenError;
     273
     274    // Usually IDBBackingStore activities happens on the background thread only, but on process suspension,
     275    // we need to force transactions of IDBBackingStore to stop on the main thread, and we need to make sure
     276    // no IDBBackingStore activity can happen after process acknowledges suspension.
     277    Lock m_backingStoreLock;
    272278    std::unique_ptr<IDBBackingStore> m_backingStore;
    273279    std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
     
    307313
    308314    HashMap<uint64_t, uint64_t> m_pendingSpaceIncreaseTasks;
     315
     316    bool m_isSuspended { false };
    309317};
    310318
Note: See TracChangeset for help on using the changeset viewer.