void IDBServer::openDBRequestCancelled(const IDBRequestData& requestData) { LOG(IndexedDB, "IDBServer::openDBRequestCancelled"); ASSERT(isMainThread()); auto* uniqueIDBDatabase = m_uniqueIDBDatabaseMap.get(requestData.databaseIdentifier()); if (!uniqueIDBDatabase) return; uniqueIDBDatabase->openDBRequestCancelled(requestData.requestIdentifier()); }
void UniqueIDBDatabaseTransaction::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::clearObjectStore"); ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier()); RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this); m_databaseConnection->database().clearObjectStore(*this, objectStoreIdentifier, [this, protectedThis, requestData](const IDBError& error) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::clearObjectStore (callback)"); if (error.isNull()) m_databaseConnection->didClearObjectStore(IDBResultData::clearObjectStoreSuccess(requestData.requestIdentifier())); else m_databaseConnection->didClearObjectStore(IDBResultData::error(requestData.requestIdentifier(), error)); }); }
void IDBServer::openDatabase(const IDBRequestData& requestData) { LOG(IndexedDB, "IDBServer::openDatabase"); auto& uniqueIDBDatabase = getOrCreateUniqueIDBDatabase(requestData.databaseIdentifier()); auto connection = m_connectionMap.get(requestData.requestIdentifier().connectionIdentifier()); if (!connection) { // If the connection back to the client is gone, there's no way to open the database as // well as no way to message back failure. return; } uniqueIDBDatabase.openDatabaseConnection(*connection, requestData); }
void UniqueIDBDatabaseTransaction::deleteIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& indexName) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::deleteIndex"); ASSERT(isVersionChange()); ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier()); RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this); m_databaseConnection->database().deleteIndex(*this, objectStoreIdentifier, indexName, [this, protectedThis, requestData](const IDBError& error) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::createIndex (callback)"); if (error.isNull()) m_databaseConnection->didDeleteIndex(IDBResultData::deleteIndexSuccess(requestData.requestIdentifier())); else m_databaseConnection->didDeleteIndex(IDBResultData::error(requestData.requestIdentifier(), error)); }); }
void UniqueIDBDatabaseTransaction::createIndex(const IDBRequestData& requestData, const IDBIndexInfo& info) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::createIndex"); ASSERT(isVersionChange()); ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier()); RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this); m_databaseConnection->database().createIndex(*this, info, [this, protectedThis, requestData](const IDBError& error) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::createIndex (callback)"); if (error.isNull()) m_databaseConnection->didCreateIndex(IDBResultData::createIndexSuccess(requestData.requestIdentifier())); else m_databaseConnection->didCreateIndex(IDBResultData::error(requestData.requestIdentifier(), error)); }); }
void IDBServer::deleteDatabase(const IDBRequestData& requestData) { LOG(IndexedDB, "IDBServer::deleteDatabase - %s", requestData.databaseIdentifier().debugString().utf8().data()); auto connection = m_connectionMap.get(requestData.requestIdentifier().connectionIdentifier()); if (!connection) { // If the connection back to the client is gone, there's no way to delete the database as // well as no way to message back failure. return; } // FIXME: During bringup of modern IDB, the database deletion is a no-op, and is // immediately reported back to the WebProcess as failure. auto result = IDBResultData::error(requestData.requestIdentifier(), IDBError(IDBExceptionCode::Unknown)); connection->didDeleteDatabase(result); }
void IDBServer::deleteDatabase(const IDBRequestData& requestData) { LOG(IndexedDB, "IDBServer::deleteDatabase - %s", requestData.databaseIdentifier().debugString().utf8().data()); ASSERT(isMainThread()); auto connection = m_connectionMap.get(requestData.requestIdentifier().connectionIdentifier()); if (!connection) { // If the connection back to the client is gone, there's no way to delete the database as // well as no way to message back failure. return; } auto* database = m_uniqueIDBDatabaseMap.get(requestData.databaseIdentifier()); if (!database) database = &getOrCreateUniqueIDBDatabase(requestData.databaseIdentifier()); database->handleDelete(*connection, requestData); }
void IDBServer::deleteDatabase(const IDBRequestData& requestData) { LOG(IndexedDB, "IDBServer::deleteDatabase - %s", requestData.databaseIdentifier().debugString().utf8().data()); auto connection = m_connectionMap.get(requestData.requestIdentifier().connectionIdentifier()); if (!connection) { // If the connection back to the client is gone, there's no way to delete the database as // well as no way to message back failure. return; } auto* database = m_uniqueIDBDatabaseMap.get(requestData.databaseIdentifier()); if (!database) { connection->didDeleteDatabase(IDBResultData::deleteDatabaseSuccess(requestData.requestIdentifier(), IDBDatabaseInfo(requestData.databaseIdentifier().databaseName(), 0))); return; } database->handleDelete(*connection, requestData); }
void IDBServer::getAllRecords(const IDBRequestData& requestData, const IDBGetAllRecordsData& getAllRecordsData) { LOG(IndexedDB, "IDBServer::getAllRecords"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; transaction->getAllRecords(requestData, getAllRecordsData); }
void IDBServer::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info) { LOG(IndexedDB, "IDBServer::openCursor"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; transaction->openCursor(requestData, info); }
void IDBServer::iterateCursor(const IDBRequestData& requestData, const IDBKeyData& key, unsigned long count) { LOG(IndexedDB, "IDBServer::iterateCursor"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; transaction->iterateCursor(requestData, key, count); }
void IDBServer::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode) { LOG(IndexedDB, "IDBServer::putOrAdd"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; transaction->putOrAdd(requestData, keyData, value, overwriteMode); }
void IDBServer::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData) { LOG(IndexedDB, "IDBServer::deleteRecord"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; transaction->deleteRecord(requestData, keyRangeData); }
void IDBServer::iterateCursor(const IDBRequestData& requestData, const IDBIterateCursorData& data) { LOG(IndexedDB, "IDBServer::iterateCursor"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; transaction->iterateCursor(requestData, data); }
void IDBServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier) { LOG(IndexedDB, "IDBServer::clearObjectStore"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; transaction->clearObjectStore(requestData, objectStoreIdentifier); }
void IDBServer::deleteIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& indexName) { LOG(IndexedDB, "IDBServer::deleteIndex"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; ASSERT(transaction->isVersionChange()); transaction->deleteIndex(requestData, objectStoreIdentifier, indexName); }
void IDBServer::createIndex(const IDBRequestData& requestData, const IDBIndexInfo& info) { LOG(IndexedDB, "IDBServer::createIndex"); auto transaction = m_transactions.get(requestData.transactionIdentifier()); if (!transaction) return; ASSERT(transaction->isVersionChange()); transaction->createIndex(requestData, info); }
void UniqueIDBDatabase::getRecord(const IDBRequestData& requestData, const IDBKeyRangeData& range, GetResultCallback callback) { ASSERT(isMainThread()); LOG(IndexedDB, "(main) UniqueIDBDatabase::getRecord"); uint64_t callbackID = storeCallback(callback); if (uint64_t indexIdentifier = requestData.indexIdentifier()) m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performGetIndexRecord, callbackID, requestData.transactionIdentifier(), requestData.objectStoreIdentifier(), indexIdentifier, requestData.indexRecordType(), range)); else m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performGetRecord, callbackID, requestData.transactionIdentifier(), requestData.objectStoreIdentifier(), range)); }
void UniqueIDBDatabaseTransaction::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::deleteRecord"); ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier()); RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this); m_databaseConnection->database().deleteRecord(requestData, keyRangeData, [this, protectedThis, requestData](const IDBError& error) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::deleteRecord (callback)"); if (error.isNull()) m_databaseConnection->connectionToClient().didDeleteRecord(IDBResultData::deleteRecordSuccess(requestData.requestIdentifier())); else m_databaseConnection->connectionToClient().didDeleteRecord(IDBResultData::error(requestData.requestIdentifier(), error)); }); }
void UniqueIDBDatabaseTransaction::iterateCursor(const IDBRequestData& requestData, const IDBKeyData& key, unsigned long count) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::iterateCursor"); ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier()); RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this); m_databaseConnection->database().iterateCursor(requestData, key, count, [this, protectedThis, requestData](const IDBError& error, const IDBGetResult& result) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::iterateCursor (callback)"); if (error.isNull()) m_databaseConnection->connectionToClient().didIterateCursor(IDBResultData::iterateCursorSuccess(requestData.requestIdentifier(), result)); else m_databaseConnection->connectionToClient().didIterateCursor(IDBResultData::error(requestData.requestIdentifier(), error)); }); }
void UniqueIDBDatabaseTransaction::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::openCursor"); ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier()); RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this); m_databaseConnection->database().openCursor(requestData, info, [this, protectedThis, requestData](const IDBError& error, const IDBGetResult& result) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::openCursor (callback)"); if (error.isNull()) m_databaseConnection->connectionToClient().didOpenCursor(IDBResultData::openCursorSuccess(requestData.requestIdentifier(), result)); else m_databaseConnection->connectionToClient().didOpenCursor(IDBResultData::error(requestData.requestIdentifier(), error)); }); }
void UniqueIDBDatabaseTransaction::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::putOrAdd"); ASSERT(!isReadOnly()); ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier()); RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this); m_databaseConnection->database().putOrAdd(requestData, keyData, value, overwriteMode, [this, protectedThis, requestData](const IDBError& error, const IDBKeyData& key) { LOG(IndexedDB, "UniqueIDBDatabaseTransaction::putOrAdd (callback)"); if (error.isNull()) m_databaseConnection->connectionToClient().didPutOrAdd(IDBResultData::putOrAddSuccess(requestData.requestIdentifier(), key)); else m_databaseConnection->connectionToClient().didPutOrAdd(IDBResultData::error(requestData.requestIdentifier(), error)); }); }
void UniqueIDBDatabase::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData, ErrorCallback callback) { ASSERT(isMainThread()); LOG(IndexedDB, "(main) UniqueIDBDatabase::deleteRecord"); uint64_t callbackID = storeCallback(callback); m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performDeleteRecord, callbackID, requestData.transactionIdentifier(), requestData.objectStoreIdentifier(), keyRangeData)); }
void UniqueIDBDatabase::getCount(const IDBRequestData& requestData, const IDBKeyRangeData& range, CountCallback callback) { ASSERT(isMainThread()); LOG(IndexedDB, "(main) UniqueIDBDatabase::getCount"); uint64_t callbackID = storeCallback(callback); m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performGetCount, callbackID, requestData.transactionIdentifier(), requestData.objectStoreIdentifier(), requestData.indexIdentifier(), range)); }
void UniqueIDBDatabase::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode overwriteMode, KeyDataCallback callback) { ASSERT(isMainThread()); LOG(IndexedDB, "(main) UniqueIDBDatabase::putOrAdd"); uint64_t callbackID = storeCallback(callback); m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performPutOrAdd, callbackID, requestData.transactionIdentifier(), requestData.objectStoreIdentifier(), keyData, valueData, overwriteMode)); }