IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& info) : WebCore::IDBTransaction(database.scriptExecutionContext()) , m_database(database) , m_info(info) , m_operationTimer(*this, &IDBTransaction::operationTimerFired) { relaxAdoptionRequirement(); if (m_info.mode() == IndexedDB::TransactionMode::VersionChange) { m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(m_database->info()); m_startedOnServer = true; } else { activate(); RefPtr<IDBTransaction> self; JSC::VM& vm = JSDOMWindowBase::commonVM(); vm.whenIdle([self, this]() { deactivate(); }); establishOnServer(); } suspendIfNeeded(); }
IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& info, IDBOpenDBRequest* request) : WebCore::IDBTransaction(database.scriptExecutionContext()) , m_database(database) , m_info(info) , m_operationTimer(*this, &IDBTransaction::operationTimerFired) , m_openDBRequest(request) { LOG(IndexedDB, "IDBTransaction::IDBTransaction - %s", m_info.loggingString().utf8().data()); relaxAdoptionRequirement(); if (m_info.mode() == IndexedDB::TransactionMode::VersionChange) { ASSERT(m_openDBRequest); m_openDBRequest->setVersionChangeTransaction(*this); m_startedOnServer = true; } else { activate(); RefPtr<IDBTransaction> self; JSC::VM& vm = JSDOMWindowBase::commonVM(); vm.whenIdle([self, this]() { deactivate(); }); establishOnServer(); } suspendIfNeeded(); }
JSValue jsIDBDatabaseOnversionchange(ExecState* exec, JSValue slotBase, const Identifier&) { JSIDBDatabase* castedThis = static_cast<JSIDBDatabase*>(asObject(slotBase)); UNUSED_PARAM(exec); IDBDatabase* imp = static_cast<IDBDatabase*>(castedThis->impl()); if (EventListener* listener = imp->onversionchange()) { if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) return jsFunction; } } return jsNull(); }