Modern IDB: Remove abstract base classes for all IDB DOM classes.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Mar 2016 22:49:04 +0000 (22:49 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Mar 2016 22:49:04 +0000 (22:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155951

Reviewed by Alex Christensen.

Source/WebCore:

Refactor - No behavior change.

* Modules/indexeddb/DOMWindowIndexedDatabase.cpp:
(WebCore::DOMWindowIndexedDatabase::indexedDB):
* Modules/indexeddb/IDBAny.cpp:
(WebCore::IDBAny::IDBAny):
(WebCore::IDBAny::~IDBAny):
(WebCore::IDBAny::idbDatabase):
(WebCore::IDBAny::domStringList):
(WebCore::IDBAny::idbCursor):
(WebCore::IDBAny::idbCursorWithValue):
(WebCore::IDBAny::idbFactory):
(WebCore::IDBAny::idbIndex):
(WebCore::IDBAny::idbObjectStore):
(WebCore::IDBAny::idbTransaction):
(WebCore::IDBAny::scriptValue):
(WebCore::IDBAny::integer):
(WebCore::IDBAny::string):
(WebCore::IDBAny::keyPath):
* Modules/indexeddb/IDBAny.h:
(WebCore::IDBAny::create):
(WebCore::IDBAny::createUndefined):
(WebCore::IDBAny::type):
(WebCore::IDBAny::~IDBAny): Deleted.
(WebCore::IDBAny::isLegacy): Deleted.
* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::create):
(WebCore::IDBCursor::IDBCursor):
(WebCore::IDBCursor::~IDBCursor):
(WebCore::IDBCursor::sourcesDeleted):
(WebCore::IDBCursor::effectiveObjectStore):
(WebCore::IDBCursor::transaction):
(WebCore::IDBCursor::direction):
(WebCore::IDBCursor::key):
(WebCore::IDBCursor::primaryKey):
(WebCore::IDBCursor::value):
(WebCore::IDBCursor::source):
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::advance):
(WebCore::IDBCursor::continueFunction):
(WebCore::IDBCursor::uncheckedIterateCursor):
(WebCore::IDBCursor::deleteFunction):
(WebCore::IDBCursor::setGetResult):
(WebCore::IDBCursor::activeDOMObjectName):
(WebCore::IDBCursor::canSuspendForDocumentSuspension):
(WebCore::IDBCursor::hasPendingActivity):
(WebCore::IDBCursor::decrementOutstandingRequestCount):
* Modules/indexeddb/IDBCursor.h:
(WebCore::IDBCursor::info):
(WebCore::IDBCursor::setRequest):
(WebCore::IDBCursor::clearRequest):
(WebCore::IDBCursor::request):
(WebCore::IDBCursor::isKeyCursor):
(WebCore::IDBCursor::~IDBCursor): Deleted.
(WebCore::IDBCursor::continueFunction): Deleted.
(WebCore::IDBCursor::isModernCursor): Deleted.
(WebCore::IDBCursor::hasPendingActivity): Deleted.
* Modules/indexeddb/IDBCursorWithValue.cpp:
(WebCore::IDBCursorWithValue::create):
(WebCore::IDBCursorWithValue::IDBCursorWithValue):
(WebCore::IDBCursorWithValue::~IDBCursorWithValue):
* Modules/indexeddb/IDBCursorWithValue.h:
(WebCore::IDBCursorWithValue::~IDBCursorWithValue): Deleted.
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::create):
(WebCore::IDBDatabase::IDBDatabase):
(WebCore::IDBDatabase::~IDBDatabase):
(WebCore::IDBDatabase::hasPendingActivity):
(WebCore::IDBDatabase::name):
(WebCore::IDBDatabase::version):
(WebCore::IDBDatabase::objectStoreNames):
(WebCore::IDBDatabase::createObjectStore):
(WebCore::IDBDatabase::transaction):
(WebCore::IDBDatabase::deleteObjectStore):
(WebCore::IDBDatabase::close):
(WebCore::IDBDatabase::maybeCloseInServer):
(WebCore::IDBDatabase::activeDOMObjectName):
(WebCore::IDBDatabase::canSuspendForDocumentSuspension):
(WebCore::IDBDatabase::stop):
(WebCore::IDBDatabase::startVersionChangeTransaction):
(WebCore::IDBDatabase::didStartTransaction):
(WebCore::IDBDatabase::willCommitTransaction):
(WebCore::IDBDatabase::didCommitTransaction):
(WebCore::IDBDatabase::willAbortTransaction):
(WebCore::IDBDatabase::didAbortTransaction):
(WebCore::IDBDatabase::didCommitOrAbortTransaction):
(WebCore::IDBDatabase::fireVersionChangeEvent):
(WebCore::IDBDatabase::dispatchEvent):
(WebCore::IDBDatabase::didCreateIndexInfo):
(WebCore::IDBDatabase::didDeleteIndexInfo):
* Modules/indexeddb/IDBDatabase.h:
(WebCore::IDBDatabase::info):
(WebCore::IDBDatabase::databaseConnectionIdentifier):
(WebCore::IDBDatabase::serverConnection):
(WebCore::IDBDatabase::isClosingOrClosed):
(WebCore::IDBDatabase::~IDBDatabase): Deleted.
* Modules/indexeddb/IDBFactory.cpp:
(WebCore::shouldThrowSecurityException):
(WebCore::IDBFactory::create):
(WebCore::IDBFactory::IDBFactory):
(WebCore::IDBFactory::getDatabaseNames):
(WebCore::IDBFactory::open):
(WebCore::IDBFactory::openInternal):
(WebCore::IDBFactory::deleteDatabase):
(WebCore::IDBFactory::cmp):
* Modules/indexeddb/IDBFactory.h:
(WebCore::IDBFactory::~IDBFactory): Deleted.
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::IDBIndex):
(WebCore::IDBIndex::~IDBIndex):
(WebCore::IDBIndex::activeDOMObjectName):
(WebCore::IDBIndex::canSuspendForDocumentSuspension):
(WebCore::IDBIndex::hasPendingActivity):
(WebCore::IDBIndex::name):
(WebCore::IDBIndex::objectStore):
(WebCore::IDBIndex::keyPathAny):
(WebCore::IDBIndex::keyPath):
(WebCore::IDBIndex::unique):
(WebCore::IDBIndex::multiEntry):
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::count):
(WebCore::IDBIndex::doCount):
(WebCore::IDBIndex::openKeyCursor):
(WebCore::IDBIndex::get):
(WebCore::IDBIndex::doGet):
(WebCore::IDBIndex::getKey):
(WebCore::IDBIndex::doGetKey):
(WebCore::IDBIndex::markAsDeleted):
(WebCore::IDBIndex::ref):
(WebCore::IDBIndex::deref):
* Modules/indexeddb/IDBIndex.h:
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::openKeyCursor):
(WebCore::IDBIndex::info):
(WebCore::IDBIndex::modernObjectStore):
(WebCore::IDBIndex::isDeleted):
(WebCore::IDBIndex::~IDBIndex): Deleted.
(WebCore::IDBIndex::isModern): Deleted.
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::create):
(WebCore::IDBObjectStore::IDBObjectStore):
(WebCore::IDBObjectStore::~IDBObjectStore):
(WebCore::IDBObjectStore::activeDOMObjectName):
(WebCore::IDBObjectStore::canSuspendForDocumentSuspension):
(WebCore::IDBObjectStore::hasPendingActivity):
(WebCore::IDBObjectStore::name):
(WebCore::IDBObjectStore::keyPathAny):
(WebCore::IDBObjectStore::keyPath):
(WebCore::IDBObjectStore::indexNames):
(WebCore::IDBObjectStore::transaction):
(WebCore::IDBObjectStore::autoIncrement):
(WebCore::IDBObjectStore::openCursor):
(WebCore::IDBObjectStore::get):
(WebCore::IDBObjectStore::add):
(WebCore::IDBObjectStore::put):
(WebCore::IDBObjectStore::putForCursorUpdate):
(WebCore::IDBObjectStore::putOrAdd):
(WebCore::IDBObjectStore::deleteFunction):
(WebCore::IDBObjectStore::doDelete):
(WebCore::IDBObjectStore::modernDelete):
(WebCore::IDBObjectStore::clear):
(WebCore::IDBObjectStore::createIndex):
(WebCore::IDBObjectStore::index):
(WebCore::IDBObjectStore::deleteIndex):
(WebCore::IDBObjectStore::count):
(WebCore::IDBObjectStore::doCount):
(WebCore::IDBObjectStore::markAsDeleted):
(WebCore::IDBObjectStore::rollbackInfoForVersionChangeAbort):
(WebCore::IDBObjectStore::visitReferencedIndexes):
* Modules/indexeddb/IDBObjectStore.h:
(WebCore::IDBObjectStore::isDeleted):
(WebCore::IDBObjectStore::info):
(WebCore::IDBObjectStore::modernTransaction):
(WebCore::IDBObjectStore::~IDBObjectStore): Deleted.
(WebCore::IDBObjectStore::isModern): Deleted.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::createDeleteRequest):
(WebCore::IDBOpenDBRequest::createOpenRequest):
(WebCore::IDBOpenDBRequest::IDBOpenDBRequest):
(WebCore::IDBOpenDBRequest::~IDBOpenDBRequest):
(WebCore::IDBOpenDBRequest::onError):
(WebCore::IDBOpenDBRequest::versionChangeTransactionDidFinish):
(WebCore::IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit):
(WebCore::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
(WebCore::IDBOpenDBRequest::dispatchEvent):
(WebCore::IDBOpenDBRequest::onSuccess):
(WebCore::IDBOpenDBRequest::onUpgradeNeeded):
(WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
(WebCore::IDBOpenDBRequest::requestCompleted):
(WebCore::IDBOpenDBRequest::requestBlocked):
* Modules/indexeddb/IDBOpenDBRequest.h:
(WebCore::IDBOpenDBRequest::databaseIdentifier):
(WebCore::IDBOpenDBRequest::version):
(WebCore::IDBOpenDBRequest::~IDBOpenDBRequest): Deleted.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::create):
(WebCore::IDBRequest::createCount):
(WebCore::IDBRequest::createGet):
(WebCore::IDBRequest::IDBRequest):
(WebCore::IDBRequest::~IDBRequest):
(WebCore::IDBRequest::result):
(WebCore::IDBRequest::errorCode):
(WebCore::IDBRequest::error):
(WebCore::IDBRequest::source):
(WebCore::IDBRequest::setSource):
(WebCore::IDBRequest::setVersionChangeTransaction):
(WebCore::IDBRequest::transaction):
(WebCore::IDBRequest::readyState):
(WebCore::IDBRequest::sourceObjectStoreIdentifier):
(WebCore::IDBRequest::sourceIndexIdentifier):
(WebCore::IDBRequest::requestedIndexRecordType):
(WebCore::IDBRequest::eventTargetInterface):
(WebCore::IDBRequest::activeDOMObjectName):
(WebCore::IDBRequest::canSuspendForDocumentSuspension):
(WebCore::IDBRequest::hasPendingActivity):
(WebCore::IDBRequest::stop):
(WebCore::IDBRequest::enqueueEvent):
(WebCore::IDBRequest::dispatchEvent):
(WebCore::IDBRequest::uncaughtExceptionInEventHandler):
(WebCore::IDBRequest::setResult):
(WebCore::IDBRequest::setResultToStructuredClone):
(WebCore::IDBRequest::setResultToUndefined):
(WebCore::IDBRequest::resultCursor):
(WebCore::IDBRequest::willIterateCursor):
(WebCore::IDBRequest::didOpenOrIterateCursor):
(WebCore::IDBRequest::requestCompleted):
(WebCore::IDBRequest::onError):
(WebCore::IDBRequest::onSuccess):
* Modules/indexeddb/IDBRequest.h:
(WebCore::IDBRequest::resourceIdentifier):
(WebCore::IDBRequest::connection):
(WebCore::IDBRequest::modernResult):
(WebCore::IDBRequest::pendingCursor):
(WebCore::IDBRequest::requestType):
(WebCore::IDBRequest::isOpenDBRequest):
(WebCore::IDBRequest::~IDBRequest): Deleted.
* Modules/indexeddb/IDBRequestCompletionEvent.cpp:
(WebCore::IDBRequestCompletionEvent::IDBRequestCompletionEvent):
* Modules/indexeddb/IDBRequestCompletionEvent.h:
(WebCore::IDBRequestCompletionEvent::create):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::create):
(WebCore::IDBTransaction::IDBTransaction):
(WebCore::IDBTransaction::~IDBTransaction):
(WebCore::IDBTransaction::mode):
(WebCore::IDBTransaction::db):
(WebCore::IDBTransaction::serverConnection):
(WebCore::IDBTransaction::error):
(WebCore::IDBTransaction::objectStore):
(WebCore::IDBTransaction::abortDueToFailedRequest):
(WebCore::IDBTransaction::transitionedToFinishing):
(WebCore::IDBTransaction::abort):
(WebCore::IDBTransaction::abortOnServerAndCancelRequests):
(WebCore::IDBTransaction::activeDOMObjectName):
(WebCore::IDBTransaction::canSuspendForDocumentSuspension):
(WebCore::IDBTransaction::hasPendingActivity):
(WebCore::IDBTransaction::stop):
(WebCore::IDBTransaction::isActive):
(WebCore::IDBTransaction::isFinishedOrFinishing):
(WebCore::IDBTransaction::addRequest):
(WebCore::IDBTransaction::removeRequest):
(WebCore::IDBTransaction::scheduleOperation):
(WebCore::IDBTransaction::scheduleOperationTimer):
(WebCore::IDBTransaction::operationTimerFired):
(WebCore::IDBTransaction::commit):
(WebCore::IDBTransaction::commitOnServer):
(WebCore::IDBTransaction::finishAbortOrCommit):
(WebCore::IDBTransaction::didStart):
(WebCore::IDBTransaction::notifyDidAbort):
(WebCore::IDBTransaction::didAbort):
(WebCore::IDBTransaction::didCommit):
(WebCore::IDBTransaction::fireOnComplete):
(WebCore::IDBTransaction::fireOnAbort):
(WebCore::IDBTransaction::enqueueEvent):
(WebCore::IDBTransaction::dispatchEvent):
(WebCore::IDBTransaction::createObjectStore):
(WebCore::IDBTransaction::createObjectStoreOnServer):
(WebCore::IDBTransaction::didCreateObjectStoreOnServer):
(WebCore::IDBTransaction::createIndex):
(WebCore::IDBTransaction::createIndexOnServer):
(WebCore::IDBTransaction::didCreateIndexOnServer):
(WebCore::IDBTransaction::requestOpenCursor):
(WebCore::IDBTransaction::doRequestOpenCursor):
(WebCore::IDBTransaction::openCursorOnServer):
(WebCore::IDBTransaction::didOpenCursorOnServer):
(WebCore::IDBTransaction::iterateCursor):
(WebCore::IDBTransaction::iterateCursorOnServer):
(WebCore::IDBTransaction::didIterateCursorOnServer):
(WebCore::IDBTransaction::requestGetRecord):
(WebCore::IDBTransaction::requestGetValue):
(WebCore::IDBTransaction::requestGetKey):
(WebCore::IDBTransaction::requestIndexRecord):
(WebCore::IDBTransaction::getRecordOnServer):
(WebCore::IDBTransaction::didGetRecordOnServer):
(WebCore::IDBTransaction::requestCount):
(WebCore::IDBTransaction::getCountOnServer):
(WebCore::IDBTransaction::didGetCountOnServer):
(WebCore::IDBTransaction::requestDeleteRecord):
(WebCore::IDBTransaction::deleteRecordOnServer):
(WebCore::IDBTransaction::didDeleteRecordOnServer):
(WebCore::IDBTransaction::requestClearObjectStore):
(WebCore::IDBTransaction::clearObjectStoreOnServer):
(WebCore::IDBTransaction::didClearObjectStoreOnServer):
(WebCore::IDBTransaction::requestPutOrAdd):
(WebCore::IDBTransaction::putOrAddOnServer):
(WebCore::IDBTransaction::didPutOrAddOnServer):
(WebCore::IDBTransaction::deleteObjectStore):
(WebCore::IDBTransaction::deleteObjectStoreOnServer):
(WebCore::IDBTransaction::didDeleteObjectStoreOnServer):
(WebCore::IDBTransaction::deleteIndex):
(WebCore::IDBTransaction::deleteIndexOnServer):
(WebCore::IDBTransaction::didDeleteIndexOnServer):
(WebCore::IDBTransaction::operationDidComplete):
(WebCore::IDBTransaction::establishOnServer):
(WebCore::IDBTransaction::activate):
(WebCore::IDBTransaction::deactivate):
* Modules/indexeddb/IDBTransaction.h:
(WebCore::IDBTransaction::info):
(WebCore::IDBTransaction::database):
(WebCore::IDBTransaction::originalDatabaseInfo):
(WebCore::IDBTransaction::isVersionChange):
(WebCore::IDBTransaction::isReadOnly):
(WebCore::IDBTransaction::isFinished):
(WebCore::TransactionActivator::TransactionActivator):
(WebCore::TransactionActivator::~TransactionActivator):
(WebCore::IDBTransaction::~IDBTransaction): Deleted.
* Modules/indexeddb/IDBVersionChangeEvent.cpp:
(WebCore::IDBVersionChangeEvent::IDBVersionChangeEvent):
(WebCore::IDBVersionChangeEvent::newVersion):
(WebCore::IDBVersionChangeEvent::eventInterface):
(WebCore::IDBVersionChangeEvent::create): Deleted.
* Modules/indexeddb/IDBVersionChangeEvent.h:
(isType):
* Modules/indexeddb/client/IDBAnyImpl.cpp: Removed.
* Modules/indexeddb/client/IDBAnyImpl.h: Removed.
* Modules/indexeddb/client/IDBConnectionToServer.cpp:
* Modules/indexeddb/client/IDBConnectionToServer.h:
* Modules/indexeddb/client/IDBCursorImpl.cpp: Removed.
* Modules/indexeddb/client/IDBCursorImpl.h: Removed.
* Modules/indexeddb/client/IDBCursorWithValueImpl.cpp: Removed.
* Modules/indexeddb/client/IDBCursorWithValueImpl.h: Removed.
* Modules/indexeddb/client/IDBDatabaseImpl.cpp: Removed.
* Modules/indexeddb/client/IDBDatabaseImpl.h: Removed.
* Modules/indexeddb/client/IDBFactoryImpl.cpp: Removed.
* Modules/indexeddb/client/IDBFactoryImpl.h: Removed.
* Modules/indexeddb/client/IDBIndexImpl.cpp: Removed.
* Modules/indexeddb/client/IDBIndexImpl.h: Removed.
* Modules/indexeddb/client/IDBObjectStoreImpl.cpp: Removed.
* Modules/indexeddb/client/IDBObjectStoreImpl.h: Removed.
* Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp: Removed.
* Modules/indexeddb/client/IDBOpenDBRequestImpl.h: Removed.
* Modules/indexeddb/client/IDBRequestImpl.cpp: Removed.
* Modules/indexeddb/client/IDBRequestImpl.h: Removed.
* Modules/indexeddb/client/IDBTransactionImpl.cpp: Removed.
* Modules/indexeddb/client/IDBTransactionImpl.h: Removed.
* Modules/indexeddb/client/IDBVersionChangeEventImpl.cpp: Removed.
* Modules/indexeddb/client/IDBVersionChangeEventImpl.h: Removed.
* Modules/indexeddb/client/TransactionOperation.cpp:
* Modules/indexeddb/client/TransactionOperation.h:
* Modules/indexeddb/shared/IDBCursorInfo.cpp:
(WebCore::IDBCursorInfo::objectStoreCursor):
(WebCore::IDBCursorInfo::indexCursor):
(WebCore::IDBCursorInfo::IDBCursorInfo):
* Modules/indexeddb/shared/IDBCursorInfo.h:
* Modules/indexeddb/shared/IDBRequestData.cpp:
(WebCore::IDBRequestData::IDBRequestData):
* Modules/indexeddb/shared/IDBRequestData.h:
* Modules/indexeddb/shared/IDBResourceIdentifier.cpp:
(WebCore::IDBResourceIdentifier::IDBResourceIdentifier):
* Modules/indexeddb/shared/IDBResourceIdentifier.h:
* Modules/indexeddb/shared/IDBTransactionInfo.cpp:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
* Modules/indexeddb/shared/InProcessIDBServer.h:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSIDBCursorCustom.cpp:
(WebCore::JSIDBCursor::visitAdditionalChildren):
* bindings/js/JSIDBCursorWithValueCustom.cpp:
* bindings/js/JSIDBIndexCustom.cpp:
(WebCore::JSIDBIndex::visitAdditionalChildren):
* bindings/js/JSIDBObjectStoreCustom.cpp:
(WebCore::JSIDBObjectStore::visitAdditionalChildren):
* inspector/InspectorIndexedDBAgent.cpp:

Source/WebKit2:

* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@198762 268f45cc-cd09-0410-ab3c-d52691b4dbfc

70 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBAny.cpp
Source/WebCore/Modules/indexeddb/IDBAny.h
Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Source/WebCore/Modules/indexeddb/IDBCursor.h
Source/WebCore/Modules/indexeddb/IDBCursorWithValue.cpp
Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.h
Source/WebCore/Modules/indexeddb/IDBFactory.cpp
Source/WebCore/Modules/indexeddb/IDBFactory.h
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.h
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.h
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.h
Source/WebCore/Modules/indexeddb/IDBRequestCompletionEvent.cpp
Source/WebCore/Modules/indexeddb/IDBRequestCompletionEvent.h
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.cpp
Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.h
Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp
Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h
Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBCursorWithValueImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBCursorWithValueImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBVersionChangeEventImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/client/IDBVersionChangeEventImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/client/TransactionOperation.cpp
Source/WebCore/Modules/indexeddb/client/TransactionOperation.h
Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp
Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h
Source/WebCore/Modules/indexeddb/shared/IDBRequestData.cpp
Source/WebCore/Modules/indexeddb/shared/IDBRequestData.h
Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp
Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h
Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp
Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp
Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSIDBCursorCustom.cpp
Source/WebCore/bindings/js/JSIDBCursorWithValueCustom.cpp
Source/WebCore/bindings/js/JSIDBIndexCustom.cpp
Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp

index dc387d6..db93bab 100644 (file)
@@ -853,18 +853,7 @@ set(WebCore_SOURCES
     Modules/indexeddb/IDBVersionChangeEvent.cpp
     Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp
 
-    Modules/indexeddb/client/IDBAnyImpl.cpp
     Modules/indexeddb/client/IDBConnectionToServer.cpp
-    Modules/indexeddb/client/IDBCursorImpl.cpp
-    Modules/indexeddb/client/IDBCursorWithValueImpl.cpp
-    Modules/indexeddb/client/IDBDatabaseImpl.cpp
-    Modules/indexeddb/client/IDBFactoryImpl.cpp
-    Modules/indexeddb/client/IDBIndexImpl.cpp
-    Modules/indexeddb/client/IDBObjectStoreImpl.cpp
-    Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp
-    Modules/indexeddb/client/IDBRequestImpl.cpp
-    Modules/indexeddb/client/IDBTransactionImpl.cpp
-    Modules/indexeddb/client/IDBVersionChangeEventImpl.cpp
     Modules/indexeddb/client/TransactionOperation.cpp
 
     Modules/indexeddb/server/IDBConnectionToClient.cpp
index c474f25..df99911 100644 (file)
@@ -1,3 +1,393 @@
+2016-03-28  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Remove abstract base classes for all IDB DOM classes.
+        https://bugs.webkit.org/show_bug.cgi?id=155951
+
+        Reviewed by Alex Christensen.
+
+        Refactor - No behavior change.
+
+        * Modules/indexeddb/DOMWindowIndexedDatabase.cpp:
+        (WebCore::DOMWindowIndexedDatabase::indexedDB):
+        * Modules/indexeddb/IDBAny.cpp:
+        (WebCore::IDBAny::IDBAny):
+        (WebCore::IDBAny::~IDBAny):
+        (WebCore::IDBAny::idbDatabase):
+        (WebCore::IDBAny::domStringList):
+        (WebCore::IDBAny::idbCursor):
+        (WebCore::IDBAny::idbCursorWithValue):
+        (WebCore::IDBAny::idbFactory):
+        (WebCore::IDBAny::idbIndex):
+        (WebCore::IDBAny::idbObjectStore):
+        (WebCore::IDBAny::idbTransaction):
+        (WebCore::IDBAny::scriptValue):
+        (WebCore::IDBAny::integer):
+        (WebCore::IDBAny::string):
+        (WebCore::IDBAny::keyPath):
+        * Modules/indexeddb/IDBAny.h:
+        (WebCore::IDBAny::create):
+        (WebCore::IDBAny::createUndefined):
+        (WebCore::IDBAny::type):
+        (WebCore::IDBAny::~IDBAny): Deleted.
+        (WebCore::IDBAny::isLegacy): Deleted.
+        * Modules/indexeddb/IDBCursor.cpp:
+        (WebCore::IDBCursor::create):
+        (WebCore::IDBCursor::IDBCursor):
+        (WebCore::IDBCursor::~IDBCursor):
+        (WebCore::IDBCursor::sourcesDeleted):
+        (WebCore::IDBCursor::effectiveObjectStore):
+        (WebCore::IDBCursor::transaction):
+        (WebCore::IDBCursor::direction):
+        (WebCore::IDBCursor::key):
+        (WebCore::IDBCursor::primaryKey):
+        (WebCore::IDBCursor::value):
+        (WebCore::IDBCursor::source):
+        (WebCore::IDBCursor::update):
+        (WebCore::IDBCursor::advance):
+        (WebCore::IDBCursor::continueFunction):
+        (WebCore::IDBCursor::uncheckedIterateCursor):
+        (WebCore::IDBCursor::deleteFunction):
+        (WebCore::IDBCursor::setGetResult):
+        (WebCore::IDBCursor::activeDOMObjectName):
+        (WebCore::IDBCursor::canSuspendForDocumentSuspension):
+        (WebCore::IDBCursor::hasPendingActivity):
+        (WebCore::IDBCursor::decrementOutstandingRequestCount):
+        * Modules/indexeddb/IDBCursor.h:
+        (WebCore::IDBCursor::info):
+        (WebCore::IDBCursor::setRequest):
+        (WebCore::IDBCursor::clearRequest):
+        (WebCore::IDBCursor::request):
+        (WebCore::IDBCursor::isKeyCursor):
+        (WebCore::IDBCursor::~IDBCursor): Deleted.
+        (WebCore::IDBCursor::continueFunction): Deleted.
+        (WebCore::IDBCursor::isModernCursor): Deleted.
+        (WebCore::IDBCursor::hasPendingActivity): Deleted.
+        * Modules/indexeddb/IDBCursorWithValue.cpp:
+        (WebCore::IDBCursorWithValue::create):
+        (WebCore::IDBCursorWithValue::IDBCursorWithValue):
+        (WebCore::IDBCursorWithValue::~IDBCursorWithValue):
+        * Modules/indexeddb/IDBCursorWithValue.h:
+        (WebCore::IDBCursorWithValue::~IDBCursorWithValue): Deleted.
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::create):
+        (WebCore::IDBDatabase::IDBDatabase):
+        (WebCore::IDBDatabase::~IDBDatabase):
+        (WebCore::IDBDatabase::hasPendingActivity):
+        (WebCore::IDBDatabase::name):
+        (WebCore::IDBDatabase::version):
+        (WebCore::IDBDatabase::objectStoreNames):
+        (WebCore::IDBDatabase::createObjectStore):
+        (WebCore::IDBDatabase::transaction):
+        (WebCore::IDBDatabase::deleteObjectStore):
+        (WebCore::IDBDatabase::close):
+        (WebCore::IDBDatabase::maybeCloseInServer):
+        (WebCore::IDBDatabase::activeDOMObjectName):
+        (WebCore::IDBDatabase::canSuspendForDocumentSuspension):
+        (WebCore::IDBDatabase::stop):
+        (WebCore::IDBDatabase::startVersionChangeTransaction):
+        (WebCore::IDBDatabase::didStartTransaction):
+        (WebCore::IDBDatabase::willCommitTransaction):
+        (WebCore::IDBDatabase::didCommitTransaction):
+        (WebCore::IDBDatabase::willAbortTransaction):
+        (WebCore::IDBDatabase::didAbortTransaction):
+        (WebCore::IDBDatabase::didCommitOrAbortTransaction):
+        (WebCore::IDBDatabase::fireVersionChangeEvent):
+        (WebCore::IDBDatabase::dispatchEvent):
+        (WebCore::IDBDatabase::didCreateIndexInfo):
+        (WebCore::IDBDatabase::didDeleteIndexInfo):
+        * Modules/indexeddb/IDBDatabase.h:
+        (WebCore::IDBDatabase::info):
+        (WebCore::IDBDatabase::databaseConnectionIdentifier):
+        (WebCore::IDBDatabase::serverConnection):
+        (WebCore::IDBDatabase::isClosingOrClosed):
+        (WebCore::IDBDatabase::~IDBDatabase): Deleted.
+        * Modules/indexeddb/IDBFactory.cpp:
+        (WebCore::shouldThrowSecurityException):
+        (WebCore::IDBFactory::create):
+        (WebCore::IDBFactory::IDBFactory):
+        (WebCore::IDBFactory::getDatabaseNames):
+        (WebCore::IDBFactory::open):
+        (WebCore::IDBFactory::openInternal):
+        (WebCore::IDBFactory::deleteDatabase):
+        (WebCore::IDBFactory::cmp):
+        * Modules/indexeddb/IDBFactory.h:
+        (WebCore::IDBFactory::~IDBFactory): Deleted.
+        * Modules/indexeddb/IDBIndex.cpp:
+        (WebCore::IDBIndex::IDBIndex):
+        (WebCore::IDBIndex::~IDBIndex):
+        (WebCore::IDBIndex::activeDOMObjectName):
+        (WebCore::IDBIndex::canSuspendForDocumentSuspension):
+        (WebCore::IDBIndex::hasPendingActivity):
+        (WebCore::IDBIndex::name):
+        (WebCore::IDBIndex::objectStore):
+        (WebCore::IDBIndex::keyPathAny):
+        (WebCore::IDBIndex::keyPath):
+        (WebCore::IDBIndex::unique):
+        (WebCore::IDBIndex::multiEntry):
+        (WebCore::IDBIndex::openCursor):
+        (WebCore::IDBIndex::count):
+        (WebCore::IDBIndex::doCount):
+        (WebCore::IDBIndex::openKeyCursor):
+        (WebCore::IDBIndex::get):
+        (WebCore::IDBIndex::doGet):
+        (WebCore::IDBIndex::getKey):
+        (WebCore::IDBIndex::doGetKey):
+        (WebCore::IDBIndex::markAsDeleted):
+        (WebCore::IDBIndex::ref):
+        (WebCore::IDBIndex::deref):
+        * Modules/indexeddb/IDBIndex.h:
+        (WebCore::IDBIndex::openCursor):
+        (WebCore::IDBIndex::openKeyCursor):
+        (WebCore::IDBIndex::info):
+        (WebCore::IDBIndex::modernObjectStore):
+        (WebCore::IDBIndex::isDeleted):
+        (WebCore::IDBIndex::~IDBIndex): Deleted.
+        (WebCore::IDBIndex::isModern): Deleted.
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::create):
+        (WebCore::IDBObjectStore::IDBObjectStore):
+        (WebCore::IDBObjectStore::~IDBObjectStore):
+        (WebCore::IDBObjectStore::activeDOMObjectName):
+        (WebCore::IDBObjectStore::canSuspendForDocumentSuspension):
+        (WebCore::IDBObjectStore::hasPendingActivity):
+        (WebCore::IDBObjectStore::name):
+        (WebCore::IDBObjectStore::keyPathAny):
+        (WebCore::IDBObjectStore::keyPath):
+        (WebCore::IDBObjectStore::indexNames):
+        (WebCore::IDBObjectStore::transaction):
+        (WebCore::IDBObjectStore::autoIncrement):
+        (WebCore::IDBObjectStore::openCursor):
+        (WebCore::IDBObjectStore::get):
+        (WebCore::IDBObjectStore::add):
+        (WebCore::IDBObjectStore::put):
+        (WebCore::IDBObjectStore::putForCursorUpdate):
+        (WebCore::IDBObjectStore::putOrAdd):
+        (WebCore::IDBObjectStore::deleteFunction):
+        (WebCore::IDBObjectStore::doDelete):
+        (WebCore::IDBObjectStore::modernDelete):
+        (WebCore::IDBObjectStore::clear):
+        (WebCore::IDBObjectStore::createIndex):
+        (WebCore::IDBObjectStore::index):
+        (WebCore::IDBObjectStore::deleteIndex):
+        (WebCore::IDBObjectStore::count):
+        (WebCore::IDBObjectStore::doCount):
+        (WebCore::IDBObjectStore::markAsDeleted):
+        (WebCore::IDBObjectStore::rollbackInfoForVersionChangeAbort):
+        (WebCore::IDBObjectStore::visitReferencedIndexes):
+        * Modules/indexeddb/IDBObjectStore.h:
+        (WebCore::IDBObjectStore::isDeleted):
+        (WebCore::IDBObjectStore::info):
+        (WebCore::IDBObjectStore::modernTransaction):
+        (WebCore::IDBObjectStore::~IDBObjectStore): Deleted.
+        (WebCore::IDBObjectStore::isModern): Deleted.
+        * Modules/indexeddb/IDBOpenDBRequest.cpp:
+        (WebCore::IDBOpenDBRequest::createDeleteRequest):
+        (WebCore::IDBOpenDBRequest::createOpenRequest):
+        (WebCore::IDBOpenDBRequest::IDBOpenDBRequest):
+        (WebCore::IDBOpenDBRequest::~IDBOpenDBRequest):
+        (WebCore::IDBOpenDBRequest::onError):
+        (WebCore::IDBOpenDBRequest::versionChangeTransactionDidFinish):
+        (WebCore::IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit):
+        (WebCore::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
+        (WebCore::IDBOpenDBRequest::dispatchEvent):
+        (WebCore::IDBOpenDBRequest::onSuccess):
+        (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
+        (WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
+        (WebCore::IDBOpenDBRequest::requestCompleted):
+        (WebCore::IDBOpenDBRequest::requestBlocked):
+        * Modules/indexeddb/IDBOpenDBRequest.h:
+        (WebCore::IDBOpenDBRequest::databaseIdentifier):
+        (WebCore::IDBOpenDBRequest::version):
+        (WebCore::IDBOpenDBRequest::~IDBOpenDBRequest): Deleted.
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::create):
+        (WebCore::IDBRequest::createCount):
+        (WebCore::IDBRequest::createGet):
+        (WebCore::IDBRequest::IDBRequest):
+        (WebCore::IDBRequest::~IDBRequest):
+        (WebCore::IDBRequest::result):
+        (WebCore::IDBRequest::errorCode):
+        (WebCore::IDBRequest::error):
+        (WebCore::IDBRequest::source):
+        (WebCore::IDBRequest::setSource):
+        (WebCore::IDBRequest::setVersionChangeTransaction):
+        (WebCore::IDBRequest::transaction):
+        (WebCore::IDBRequest::readyState):
+        (WebCore::IDBRequest::sourceObjectStoreIdentifier):
+        (WebCore::IDBRequest::sourceIndexIdentifier):
+        (WebCore::IDBRequest::requestedIndexRecordType):
+        (WebCore::IDBRequest::eventTargetInterface):
+        (WebCore::IDBRequest::activeDOMObjectName):
+        (WebCore::IDBRequest::canSuspendForDocumentSuspension):
+        (WebCore::IDBRequest::hasPendingActivity):
+        (WebCore::IDBRequest::stop):
+        (WebCore::IDBRequest::enqueueEvent):
+        (WebCore::IDBRequest::dispatchEvent):
+        (WebCore::IDBRequest::uncaughtExceptionInEventHandler):
+        (WebCore::IDBRequest::setResult):
+        (WebCore::IDBRequest::setResultToStructuredClone):
+        (WebCore::IDBRequest::setResultToUndefined):
+        (WebCore::IDBRequest::resultCursor):
+        (WebCore::IDBRequest::willIterateCursor):
+        (WebCore::IDBRequest::didOpenOrIterateCursor):
+        (WebCore::IDBRequest::requestCompleted):
+        (WebCore::IDBRequest::onError):
+        (WebCore::IDBRequest::onSuccess):
+        * Modules/indexeddb/IDBRequest.h:
+        (WebCore::IDBRequest::resourceIdentifier):
+        (WebCore::IDBRequest::connection):
+        (WebCore::IDBRequest::modernResult):
+        (WebCore::IDBRequest::pendingCursor):
+        (WebCore::IDBRequest::requestType):
+        (WebCore::IDBRequest::isOpenDBRequest):
+        (WebCore::IDBRequest::~IDBRequest): Deleted.
+        * Modules/indexeddb/IDBRequestCompletionEvent.cpp:
+        (WebCore::IDBRequestCompletionEvent::IDBRequestCompletionEvent):
+        * Modules/indexeddb/IDBRequestCompletionEvent.h:
+        (WebCore::IDBRequestCompletionEvent::create):
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::create):
+        (WebCore::IDBTransaction::IDBTransaction):
+        (WebCore::IDBTransaction::~IDBTransaction):
+        (WebCore::IDBTransaction::mode):
+        (WebCore::IDBTransaction::db):
+        (WebCore::IDBTransaction::serverConnection):
+        (WebCore::IDBTransaction::error):
+        (WebCore::IDBTransaction::objectStore):
+        (WebCore::IDBTransaction::abortDueToFailedRequest):
+        (WebCore::IDBTransaction::transitionedToFinishing):
+        (WebCore::IDBTransaction::abort):
+        (WebCore::IDBTransaction::abortOnServerAndCancelRequests):
+        (WebCore::IDBTransaction::activeDOMObjectName):
+        (WebCore::IDBTransaction::canSuspendForDocumentSuspension):
+        (WebCore::IDBTransaction::hasPendingActivity):
+        (WebCore::IDBTransaction::stop):
+        (WebCore::IDBTransaction::isActive):
+        (WebCore::IDBTransaction::isFinishedOrFinishing):
+        (WebCore::IDBTransaction::addRequest):
+        (WebCore::IDBTransaction::removeRequest):
+        (WebCore::IDBTransaction::scheduleOperation):
+        (WebCore::IDBTransaction::scheduleOperationTimer):
+        (WebCore::IDBTransaction::operationTimerFired):
+        (WebCore::IDBTransaction::commit):
+        (WebCore::IDBTransaction::commitOnServer):
+        (WebCore::IDBTransaction::finishAbortOrCommit):
+        (WebCore::IDBTransaction::didStart):
+        (WebCore::IDBTransaction::notifyDidAbort):
+        (WebCore::IDBTransaction::didAbort):
+        (WebCore::IDBTransaction::didCommit):
+        (WebCore::IDBTransaction::fireOnComplete):
+        (WebCore::IDBTransaction::fireOnAbort):
+        (WebCore::IDBTransaction::enqueueEvent):
+        (WebCore::IDBTransaction::dispatchEvent):
+        (WebCore::IDBTransaction::createObjectStore):
+        (WebCore::IDBTransaction::createObjectStoreOnServer):
+        (WebCore::IDBTransaction::didCreateObjectStoreOnServer):
+        (WebCore::IDBTransaction::createIndex):
+        (WebCore::IDBTransaction::createIndexOnServer):
+        (WebCore::IDBTransaction::didCreateIndexOnServer):
+        (WebCore::IDBTransaction::requestOpenCursor):
+        (WebCore::IDBTransaction::doRequestOpenCursor):
+        (WebCore::IDBTransaction::openCursorOnServer):
+        (WebCore::IDBTransaction::didOpenCursorOnServer):
+        (WebCore::IDBTransaction::iterateCursor):
+        (WebCore::IDBTransaction::iterateCursorOnServer):
+        (WebCore::IDBTransaction::didIterateCursorOnServer):
+        (WebCore::IDBTransaction::requestGetRecord):
+        (WebCore::IDBTransaction::requestGetValue):
+        (WebCore::IDBTransaction::requestGetKey):
+        (WebCore::IDBTransaction::requestIndexRecord):
+        (WebCore::IDBTransaction::getRecordOnServer):
+        (WebCore::IDBTransaction::didGetRecordOnServer):
+        (WebCore::IDBTransaction::requestCount):
+        (WebCore::IDBTransaction::getCountOnServer):
+        (WebCore::IDBTransaction::didGetCountOnServer):
+        (WebCore::IDBTransaction::requestDeleteRecord):
+        (WebCore::IDBTransaction::deleteRecordOnServer):
+        (WebCore::IDBTransaction::didDeleteRecordOnServer):
+        (WebCore::IDBTransaction::requestClearObjectStore):
+        (WebCore::IDBTransaction::clearObjectStoreOnServer):
+        (WebCore::IDBTransaction::didClearObjectStoreOnServer):
+        (WebCore::IDBTransaction::requestPutOrAdd):
+        (WebCore::IDBTransaction::putOrAddOnServer):
+        (WebCore::IDBTransaction::didPutOrAddOnServer):
+        (WebCore::IDBTransaction::deleteObjectStore):
+        (WebCore::IDBTransaction::deleteObjectStoreOnServer):
+        (WebCore::IDBTransaction::didDeleteObjectStoreOnServer):
+        (WebCore::IDBTransaction::deleteIndex):
+        (WebCore::IDBTransaction::deleteIndexOnServer):
+        (WebCore::IDBTransaction::didDeleteIndexOnServer):
+        (WebCore::IDBTransaction::operationDidComplete):
+        (WebCore::IDBTransaction::establishOnServer):
+        (WebCore::IDBTransaction::activate):
+        (WebCore::IDBTransaction::deactivate):
+        * Modules/indexeddb/IDBTransaction.h:
+        (WebCore::IDBTransaction::info):
+        (WebCore::IDBTransaction::database):
+        (WebCore::IDBTransaction::originalDatabaseInfo):
+        (WebCore::IDBTransaction::isVersionChange):
+        (WebCore::IDBTransaction::isReadOnly):
+        (WebCore::IDBTransaction::isFinished):
+        (WebCore::TransactionActivator::TransactionActivator):
+        (WebCore::TransactionActivator::~TransactionActivator):
+        (WebCore::IDBTransaction::~IDBTransaction): Deleted.
+        * Modules/indexeddb/IDBVersionChangeEvent.cpp:
+        (WebCore::IDBVersionChangeEvent::IDBVersionChangeEvent):
+        (WebCore::IDBVersionChangeEvent::newVersion):
+        (WebCore::IDBVersionChangeEvent::eventInterface):
+        (WebCore::IDBVersionChangeEvent::create): Deleted.
+        * Modules/indexeddb/IDBVersionChangeEvent.h:
+        (isType):
+        * Modules/indexeddb/client/IDBAnyImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBAnyImpl.h: Removed.
+        * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+        * Modules/indexeddb/client/IDBConnectionToServer.h:
+        * Modules/indexeddb/client/IDBCursorImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBCursorImpl.h: Removed.
+        * Modules/indexeddb/client/IDBCursorWithValueImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBCursorWithValueImpl.h: Removed.
+        * Modules/indexeddb/client/IDBDatabaseImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBDatabaseImpl.h: Removed.
+        * Modules/indexeddb/client/IDBFactoryImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBFactoryImpl.h: Removed.
+        * Modules/indexeddb/client/IDBIndexImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBIndexImpl.h: Removed.
+        * Modules/indexeddb/client/IDBObjectStoreImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBObjectStoreImpl.h: Removed.
+        * Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBOpenDBRequestImpl.h: Removed.
+        * Modules/indexeddb/client/IDBRequestImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBRequestImpl.h: Removed.
+        * Modules/indexeddb/client/IDBTransactionImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBTransactionImpl.h: Removed.
+        * Modules/indexeddb/client/IDBVersionChangeEventImpl.cpp: Removed.
+        * Modules/indexeddb/client/IDBVersionChangeEventImpl.h: Removed.
+        * Modules/indexeddb/client/TransactionOperation.cpp:
+        * Modules/indexeddb/client/TransactionOperation.h:
+        * Modules/indexeddb/shared/IDBCursorInfo.cpp:
+        (WebCore::IDBCursorInfo::objectStoreCursor):
+        (WebCore::IDBCursorInfo::indexCursor):
+        (WebCore::IDBCursorInfo::IDBCursorInfo):
+        * Modules/indexeddb/shared/IDBCursorInfo.h:
+        * Modules/indexeddb/shared/IDBRequestData.cpp:
+        (WebCore::IDBRequestData::IDBRequestData):
+        * Modules/indexeddb/shared/IDBRequestData.h:
+        * Modules/indexeddb/shared/IDBResourceIdentifier.cpp:
+        (WebCore::IDBResourceIdentifier::IDBResourceIdentifier):
+        * Modules/indexeddb/shared/IDBResourceIdentifier.h:
+        * Modules/indexeddb/shared/IDBTransactionInfo.cpp:
+        * Modules/indexeddb/shared/InProcessIDBServer.cpp:
+        * Modules/indexeddb/shared/InProcessIDBServer.h:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSIDBCursorCustom.cpp:
+        (WebCore::JSIDBCursor::visitAdditionalChildren):
+        * bindings/js/JSIDBCursorWithValueCustom.cpp:
+        * bindings/js/JSIDBIndexCustom.cpp:
+        (WebCore::JSIDBIndex::visitAdditionalChildren):
+        * bindings/js/JSIDBObjectStoreCustom.cpp:
+        (WebCore::JSIDBObjectStore::visitAdditionalChildren):
+        * inspector/InspectorIndexedDBAgent.cpp:
+
 2016-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [RTL Scrollbars] Position:sticky can be positioned under vertical RTL scrollbar
index f5bc6a8..87d626e 100644 (file)
@@ -31,7 +31,7 @@
 #include "DOMWindow.h"
 #include "DatabaseProvider.h"
 #include "Document.h"
-#include "IDBFactoryImpl.h"
+#include "IDBFactory.h"
 #include "Page.h"
 #include "SecurityOrigin.h"
 
@@ -112,7 +112,7 @@ IDBFactory* DOMWindowIndexedDatabase::indexedDB()
         return nullptr;
 
     if (!m_idbFactory)
-        m_idbFactory = IDBClient::IDBFactory::create(page->idbConnection());
+        m_idbFactory = IDBFactory::create(page->idbConnection());
 
     return m_idbFactory.get();
 }
index 4b286b6..8fabd23 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "DOMStringList.h"
+#include "IDBCursorWithValue.h"
+#include "IDBDatabase.h"
+#include "IDBFactory.h"
+#include "IDBIndex.h"
+#include "IDBObjectStore.h"
+#include "IDBTransaction.h"
+
 namespace WebCore {
 
-IDBAny::IDBAny()
+IDBAny::IDBAny(IDBAny::Type type)
+    : m_type(type)
+{
+}
+
+IDBAny::IDBAny(Ref<IDBDatabase>&& database)
+    : m_type(IDBAny::Type::IDBDatabase)
+    , m_database(WTFMove(database))
+{
+}
+
+IDBAny::IDBAny(Ref<IDBObjectStore>&& objectStore)
+    : m_type(IDBAny::Type::IDBObjectStore)
+    , m_objectStore(WTFMove(objectStore))
+{
+}
+
+IDBAny::IDBAny(Ref<IDBIndex>&& index)
+    : m_type(IDBAny::Type::IDBIndex)
+    , m_index(WTFMove(index))
+{
+}
+
+IDBAny::IDBAny(Ref<IDBCursor>&& cursor)
+{
+    if (cursor->isKeyCursor()) {
+        m_type = IDBAny::Type::IDBCursor;
+        m_cursor = WTFMove(cursor);
+    } else {
+        m_type = IDBAny::Type::IDBCursorWithValue;
+        m_cursorWithValue = static_cast<IDBCursorWithValue*>(&cursor.get());
+    }
+}
+
+IDBAny::IDBAny(const IDBKeyPath& keyPath)
+    : m_type(IDBAny::Type::KeyPath)
+    , m_idbKeyPath(keyPath)
+{
+}
+
+IDBAny::IDBAny(const Deprecated::ScriptValue& value)
+    : m_type(IDBAny::Type::ScriptValue)
+    , m_scriptValue(value)
+{
+}
+
+IDBAny::~IDBAny()
+{
+}
+
+RefPtr<IDBDatabase> IDBAny::idbDatabase()
+{
+    ASSERT(m_type == IDBAny::Type::IDBDatabase);
+    return m_database.get();
+}
+
+RefPtr<DOMStringList> IDBAny::domStringList()
+{
+    return nullptr;
+}
+
+RefPtr<IDBCursor> IDBAny::idbCursor()
+{
+    ASSERT(m_type == IDBAny::Type::IDBCursor || m_type == IDBAny::Type::IDBCursorWithValue);
+    return m_cursor ? m_cursor.get() : m_cursorWithValue.get();
+}
+
+RefPtr<IDBCursorWithValue> IDBAny::idbCursorWithValue()
+{
+    ASSERT(m_type == IDBAny::Type::IDBCursorWithValue);
+    return m_cursorWithValue.get();
+}
+
+RefPtr<IDBFactory> IDBAny::idbFactory()
+{
+    return nullptr;
+}
+
+RefPtr<IDBIndex> IDBAny::idbIndex()
+{
+    ASSERT(m_type == IDBAny::Type::IDBIndex);
+    return m_index.get();
+}
+
+RefPtr<IDBObjectStore> IDBAny::idbObjectStore()
+{
+    ASSERT(m_type == IDBAny::Type::IDBObjectStore);
+    return m_objectStore.get();
+}
+
+RefPtr<IDBTransaction> IDBAny::idbTransaction()
+{
+    return nullptr;
+}
+
+const Deprecated::ScriptValue& IDBAny::scriptValue()
+{
+    return m_scriptValue;
+}
+
+int64_t IDBAny::integer()
+{
+    return m_integer;
+}
+
+const String& IDBAny::string()
+{
+    return m_string;
+}
+
+const IDBKeyPath& IDBAny::keyPath()
 {
+    return m_idbKeyPath;
 }
 
 } // namespace WebCore
index 5b8bdb9..9f1c795 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBAny_h
-#define IDBAny_h
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
@@ -32,8 +31,6 @@
 #include "ScriptWrappable.h"
 #include <bindings/ScriptValue.h>
 #include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -43,13 +40,47 @@ class IDBCursorWithValue;
 class IDBDatabase;
 class IDBFactory;
 class IDBIndex;
-class IDBKeyPath;
 class IDBObjectStore;
 class IDBTransaction;
 
 class IDBAny : public ScriptWrappable, public RefCounted<IDBAny> {
 public:
-    virtual ~IDBAny() { }
+    static RefPtr<IDBAny> create(Ref<IDBDatabase>&& database)
+    {
+        return adoptRef(new IDBAny(WTFMove(database)));
+    }
+
+    static Ref<IDBAny> create(Ref<IDBObjectStore>&& objectStore)
+    {
+        return adoptRef(*new IDBAny(WTFMove(objectStore)));
+    }
+
+    static Ref<IDBAny> create(Ref<IDBIndex>&& index)
+    {
+        return adoptRef(*new IDBAny(WTFMove(index)));
+    }
+
+    static RefPtr<IDBAny> create(Ref<IDBCursor>&& cursor)
+    {
+        return adoptRef(new IDBAny(WTFMove(cursor)));
+    }
+
+    static RefPtr<IDBAny> create(const IDBKeyPath& keyPath)
+    {
+        return adoptRef(new IDBAny(keyPath));
+    }
+
+    static RefPtr<IDBAny> create(const Deprecated::ScriptValue& value)
+    {
+        return adoptRef(new IDBAny(value));
+    }
+
+    static RefPtr<IDBAny> createUndefined()
+    {
+        return adoptRef(new IDBAny(IDBAny::Type::Undefined));
+    }
+
+    virtual ~IDBAny();
 
     enum class Type {
         Undefined = 0,
@@ -68,30 +99,42 @@ public:
         KeyPath,
     };
 
-    // FIXME: This is a temporary hack to allow casts in WebInspector code while Modern IDB and Legacy IDB live side-by-side.
-    // It should be removed when the legacy implementation is removed as part of https://bugs.webkit.org/show_bug.cgi?id=149117
-    virtual bool isLegacy() const { return false; }
-
-    virtual Type type() const = 0;
-    virtual RefPtr<DOMStringList> domStringList() = 0;
-    virtual RefPtr<IDBCursor> idbCursor() = 0;
-    virtual RefPtr<IDBCursorWithValue> idbCursorWithValue() = 0;
-    virtual RefPtr<IDBDatabase> idbDatabase() = 0;
-    virtual RefPtr<IDBFactory> idbFactory() = 0;
-    virtual RefPtr<IDBIndex> idbIndex() = 0;
-    virtual RefPtr<IDBObjectStore> idbObjectStore() = 0;
-    virtual RefPtr<IDBTransaction> idbTransaction() = 0;
-    virtual const Deprecated::ScriptValue& scriptValue() = 0;
-    virtual int64_t integer() = 0;
-    virtual const String& string() = 0;
-    virtual const IDBKeyPath& keyPath() = 0;
-
-protected:
-    IDBAny();
+    Type type() const { return m_type; }
+    RefPtr<DOMStringList> domStringList();
+    RefPtr<IDBCursor> idbCursor();
+    RefPtr<IDBCursorWithValue> idbCursorWithValue();
+    RefPtr<IDBDatabase> idbDatabase();
+    RefPtr<IDBFactory> idbFactory();
+    RefPtr<IDBIndex> idbIndex();
+    RefPtr<IDBObjectStore> idbObjectStore();
+    RefPtr<IDBTransaction> idbTransaction();
+    const Deprecated::ScriptValue& scriptValue();
+    int64_t integer();
+    const String& string();
+    const IDBKeyPath& keyPath();
+
+private:
+    explicit IDBAny(IDBAny::Type);
+    explicit IDBAny(Ref<IDBDatabase>&&);
+    explicit IDBAny(Ref<IDBObjectStore>&&);
+    explicit IDBAny(Ref<IDBIndex>&&);
+    explicit IDBAny(Ref<IDBCursor>&&);
+    explicit IDBAny(const IDBKeyPath&);
+    explicit IDBAny(const Deprecated::ScriptValue&);
+
+    IDBAny::Type m_type { IDBAny::Type::Undefined };
+    RefPtr<IDBDatabase> m_database;
+    RefPtr<IDBObjectStore> m_objectStore;
+    RefPtr<IDBIndex> m_index;
+    RefPtr<IDBCursor> m_cursor;
+    RefPtr<IDBCursorWithValue> m_cursorWithValue;
+
+    const IDBKeyPath m_idbKeyPath;
+    const Deprecated::ScriptValue m_scriptValue;
+    const String m_string;
+    const int64_t m_integer { 0 };
 };
 
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
-
-#endif // IDBAny_h
index 03661e2..c7b3b3c 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "DOMRequestState.h"
 #include "ExceptionCode.h"
+#include "IDBBindingUtilities.h"
+#include "IDBDatabaseException.h"
+#include "IDBGetResult.h"
+#include "IDBObjectStore.h"
+#include "IDBRequest.h"
+#include "IDBTransaction.h"
+#include "Logging.h"
+#include "ScriptExecutionContext.h"
 #include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
-IDBCursor::IDBCursor()
-{
-}
-
 const AtomicString& IDBCursor::directionNext()
 {
     static NeverDestroyed<AtomicString> next("next", AtomicString::ConstructFromLiteral);
@@ -97,6 +102,348 @@ const AtomicString& IDBCursor::directionToString(IndexedDB::CursorDirection dire
     }
 }
 
+Ref<IDBCursor> IDBCursor::create(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
+{
+    return adoptRef(*new IDBCursor(transaction, index, info));
+}
+
+IDBCursor::IDBCursor(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
+    : ActiveDOMObject(transaction.scriptExecutionContext())
+    , m_info(info)
+    , m_source(IDBAny::create(objectStore).leakRef())
+    , m_objectStore(&objectStore)
+{
+    suspendIfNeeded();
+}
+
+IDBCursor::IDBCursor(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
+    : ActiveDOMObject(transaction.scriptExecutionContext())
+    , m_info(info)
+    , m_source(IDBAny::create(index).leakRef())
+    , m_index(&index)
+{
+    suspendIfNeeded();
+}
+
+IDBCursor::~IDBCursor()
+{
+}
+
+bool IDBCursor::sourcesDeleted() const
+{
+    if (m_objectStore)
+        return m_objectStore->isDeleted();
+
+    ASSERT(m_index);
+    return m_index->isDeleted() || m_index->modernObjectStore().isDeleted();
+}
+
+IDBObjectStore& IDBCursor::effectiveObjectStore() const
+{
+    if (m_objectStore)
+        return *m_objectStore;
+
+    ASSERT(m_index);
+    return m_index->modernObjectStore();
+}
+
+IDBTransaction& IDBCursor::transaction() const
+{
+    return effectiveObjectStore().modernTransaction();
+}
+
+const String& IDBCursor::direction() const
+{
+    return IDBCursor::directionToString(m_info.cursorDirection());
+}
+
+const Deprecated::ScriptValue& IDBCursor::key() const
+{
+    return m_deprecatedCurrentKey;
+}
+
+const Deprecated::ScriptValue& IDBCursor::primaryKey() const
+{
+    return m_deprecatedCurrentPrimaryKey;
+}
+
+const Deprecated::ScriptValue& IDBCursor::value() const
+{
+    return m_deprecatedCurrentValue;
+}
+
+IDBAny* IDBCursor::source()
+{
+    return &m_source.get();
+}
+
+RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::ScriptValue& value, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBCursor::update");
+
+    if (sourcesDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor's source or effective object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!transaction().isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    if (transaction().isReadOnly()) {
+        ec.code = IDBDatabaseException::ReadOnlyError;
+        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The record may not be updated inside a read-only transaction.");
+        return nullptr;
+    }
+
+    if (!m_gotValue) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor is being iterated or has iterated past its end.");
+        return nullptr;
+    }
+
+    if (isKeyCursor()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor.");
+        return nullptr;
+    }
+
+    auto& objectStore = effectiveObjectStore();
+    auto& keyPath = objectStore.info().keyPath();
+    const bool usesInLineKeys = !keyPath.isNull();
+    if (usesInLineKeys) {
+        RefPtr<IDBKey> keyPathKey = maybeCreateIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath);
+        IDBKeyData keyPathKeyData(keyPathKey.get());
+        if (!keyPathKey || keyPathKeyData != m_currentPrimaryKeyData) {
+            ec.code = IDBDatabaseException::DataError;
+            ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.");
+            return nullptr;
+        }
+    }
+
+    auto request = effectiveObjectStore().putForCursorUpdate(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec);
+    if (ec.code)
+        return nullptr;
+
+    ASSERT(request);
+    request->setSource(*this);
+    ++m_outstandingRequestCount;
+
+    return request;
+}
+
+void IDBCursor::advance(unsigned long count, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBCursor::advance");
+
+    if (!m_request) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        return;
+    }
+    
+    if (!count) {
+        ec.code = TypeError;
+        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': A count argument with value 0 (zero) was supplied, must be greater than 0.");
+        return;
+    }
+
+    if (sourcesDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': The cursor's source or effective object store has been deleted.");
+        return;
+    }
+
+    if (!transaction().isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': The transaction is inactive or finished.");
+        return;
+    }
+
+    if (!m_gotValue) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': The cursor is being iterated or has iterated past its end.");
+        return;
+    }
+
+    m_gotValue = false;
+
+    uncheckedIterateCursor(IDBKeyData(), count);
+}
+
+void IDBCursor::continueFunction(ScriptExecutionContext&, ExceptionCodeWithMessage& ec)
+{
+    continueFunction(IDBKeyData(), ec);
+}
+
+void IDBCursor::continueFunction(ScriptExecutionContext& context, const Deprecated::ScriptValue& keyValue, ExceptionCodeWithMessage& ec)
+{
+    DOMRequestState requestState(&context);
+    RefPtr<IDBKey> key;
+    if (!keyValue.jsValue().isUndefined())
+        key = scriptValueToIDBKey(&requestState, keyValue);
+
+    continueFunction(key.get(), ec);
+}
+
+void IDBCursor::continueFunction(const IDBKeyData& key, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBCursor::continueFunction (to key %s)", key.loggingString().utf8().data());
+
+    if (!m_request) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        return;
+    }
+
+    if (sourcesDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The cursor's source or effective object store has been deleted.");
+        return;
+    }
+
+    if (!transaction().isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The transaction is inactive or finished.");
+        return;
+    }
+
+    if (!m_gotValue) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end.");
+        return;
+    }
+
+    if (!key.isNull() && !key.isValid()) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is not a valid key.");
+        return;
+    }
+
+    if (m_info.isDirectionForward()) {
+        if (!key.isNull() && key.compare(m_currentKeyData) <= 0) {
+            ec.code = IDBDatabaseException::DataError;
+            ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is less than or equal to this cursor's position.");
+            return;
+        }
+    } else if (!key.isNull() && key.compare(m_currentKeyData) >= 0) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is greater than or equal to this cursor's position.");
+        return;
+    }
+
+    m_gotValue = false;
+
+    uncheckedIterateCursor(key, 0);
+}
+
+void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned long count)
+{
+    ++m_outstandingRequestCount;
+
+    m_request->willIterateCursor(*this);
+    transaction().iterateCursor(*this, key, count);
+}
+
+RefPtr<WebCore::IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBCursor::deleteFunction");
+
+    if (sourcesDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor's source or effective object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!transaction().isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    if (transaction().isReadOnly()) {
+        ec.code = IDBDatabaseException::ReadOnlyError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The record may not be deleted inside a read-only transaction.");
+        return nullptr;
+    }
+
+    if (!m_gotValue) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor is being iterated or has iterated past its end.");
+        return nullptr;
+    }
+
+    if (isKeyCursor()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor is a key cursor.");
+        return nullptr;
+    }
+
+    auto request = effectiveObjectStore().modernDelete(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec);
+    if (ec.code)
+        return nullptr;
+
+    ASSERT(request);
+    request->setSource(*this);
+    ++m_outstandingRequestCount;
+
+    return request;
+}
+
+void IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult)
+{
+    LOG(IndexedDB, "IDBCursor::setGetResult - current key %s", getResult.keyData().loggingString().substring(0, 100).utf8().data());
+
+    auto* context = request.scriptExecutionContext();
+    if (!context)
+        return;
+
+    if (!getResult.isDefined()) {
+        m_deprecatedCurrentKey = { };
+        m_currentKeyData = { };
+        m_deprecatedCurrentPrimaryKey = { };
+        m_currentPrimaryKeyData = { };
+        m_deprecatedCurrentValue = { };
+
+        m_gotValue = false;
+        return;
+    }
+
+    m_deprecatedCurrentKey = idbKeyDataToScriptValue(context, getResult.keyData());
+    m_currentKeyData = getResult.keyData();
+    m_deprecatedCurrentPrimaryKey = idbKeyDataToScriptValue(context, getResult.primaryKeyData());
+    m_currentPrimaryKeyData = getResult.primaryKeyData();
+
+    if (isKeyCursor())
+        m_deprecatedCurrentValue = { };
+    else
+        m_deprecatedCurrentValue = deserializeIDBValueData(*context, getResult.valueBuffer());
+
+    m_gotValue = true;
+}
+
+const char* IDBCursor::activeDOMObjectName() const
+{
+    return "IDBCursor";
+}
+
+bool IDBCursor::canSuspendForDocumentSuspension() const
+{
+    return false;
+}
+
+bool IDBCursor::hasPendingActivity() const
+{
+    return m_outstandingRequestCount;
+}
+
+void IDBCursor::decrementOutstandingRequestCount()
+{
+    ASSERT(m_outstandingRequestCount);
+    --m_outstandingRequestCount;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
index 24d3a93..84f8b97 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBCursor_h
-#define IDBCursor_h
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "IDBKey.h"
-#include "IDBTransaction.h"
-#include "IndexedDB.h"
-#include "ScriptWrappable.h"
-#include <bindings/ScriptValue.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "ActiveDOMObject.h"
+#include "ExceptionCode.h"
+#include "IDBAny.h"
+#include "IDBCursorInfo.h"
 
 namespace WebCore {
 
-class DOMRequestState;
 class IDBAny;
-class IDBCallbacks;
-class IDBRequest;
-class ScriptExecutionContext;
+class IDBGetResult;
+class IDBIndex;
+class IDBObjectStore;
+class IDBTransaction;
 
-struct ExceptionCodeWithMessage;
-
-class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor> {
+class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor>, public ActiveDOMObject {
 public:
+    static Ref<IDBCursor> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
+
     static const AtomicString& directionNext();
     static const AtomicString& directionNextUnique();
     static const AtomicString& directionPrev();
@@ -55,39 +51,73 @@ public:
 
     static IndexedDB::CursorDirection stringToDirection(const String& modeString, ExceptionCode&);
     static const AtomicString& directionToString(IndexedDB::CursorDirection mode);
-
-    virtual ~IDBCursor() { }
+    
+    virtual ~IDBCursor();
 
     // Implement the IDL
-    virtual const String& direction() const = 0;
-    virtual const Deprecated::ScriptValue& key() const = 0;
-    virtual const Deprecated::ScriptValue& primaryKey() const = 0;
-    virtual const Deprecated::ScriptValue& value() const = 0;
-    virtual IDBAny* source() = 0;
+    const String& direction() const;
+    const Deprecated::ScriptValue& key() const;
+    const Deprecated::ScriptValue& primaryKey() const;
+    const Deprecated::ScriptValue& value() const;
+    IDBAny* source();
+
+    RefPtr<WebCore::IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCodeWithMessage&);
+    void advance(unsigned long, ExceptionCodeWithMessage&);
+    void continueFunction(ScriptExecutionContext&, ExceptionCodeWithMessage&);
+    void continueFunction(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&);
+    RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext&, ExceptionCodeWithMessage&);
 
-    virtual RefPtr<IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCodeWithMessage&) = 0;
-    virtual void advance(unsigned long, ExceptionCodeWithMessage&) = 0;
+    void continueFunction(const IDBKeyData&, ExceptionCodeWithMessage&);
 
-    // FIXME: We should not need that method (taking a ScriptExecutionContext pointer and not a reference)
-    // but InspectorIndexedDBAgent wants to call it with a null context. 
-    virtual void continueFunction(ScriptExecutionContext*, ExceptionCodeWithMessage&) = 0;
-    // FIXME: Try to modify the code generator so this overload is unneeded.
-    void continueFunction(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec) { continueFunction(&context, ec); }
-    virtual void continueFunction(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext&, ExceptionCodeWithMessage&) = 0;
+    const IDBCursorInfo& info() const { return m_info; }
 
-    virtual bool isKeyCursor() const = 0;
+    void setRequest(IDBRequest& request) { m_request = &request; }
+    void clearRequest() { m_request = nullptr; }
+    IDBRequest* request() { return m_request; }
 
-    virtual bool isModernCursor() const { return false; }
+    void setGetResult(IDBRequest&, const IDBGetResult&);
 
-    virtual bool hasPendingActivity() const { return false; }
+    virtual bool isKeyCursor() const { return true; }
+
+    void decrementOutstandingRequestCount();
+
+    // ActiveDOMObject.
+    const char* activeDOMObjectName() const;
+    bool canSuspendForDocumentSuspension() const;
+    bool hasPendingActivity() const;
 
 protected:
-    IDBCursor();
+    IDBCursor(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
+    IDBCursor(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
+
+private:
+    // Cursors are created with an outstanding iteration request.
+    unsigned m_outstandingRequestCount { 1 };
+
+    IDBCursorInfo m_info;
+    Ref<IDBAny> m_source;
+    IDBObjectStore* m_objectStore { nullptr };
+    IDBIndex* m_index { nullptr };
+    IDBRequest* m_request;
+
+    bool sourcesDeleted() const;
+    IDBObjectStore& effectiveObjectStore() const;
+    IDBTransaction& transaction() const;
+
+    void uncheckedIterateCursor(const IDBKeyData&, unsigned long count);
+
+    bool m_gotValue { false };
+
+    IDBKeyData m_currentKeyData;
+    IDBKeyData m_currentPrimaryKeyData;
+
+    // FIXME: When ditching Legacy IDB and combining this implementation with the abstract IDBCursor,
+    // these Deprecated::ScriptValue members should be JSValues instead.
+    Deprecated::ScriptValue m_deprecatedCurrentKey;
+    Deprecated::ScriptValue m_deprecatedCurrentPrimaryKey;
+    Deprecated::ScriptValue m_deprecatedCurrentValue;
 };
 
 } // namespace WebCore
 
-#endif
-
-#endif // IDBCursor_h
+#endif // ENABLE(INDEXED_DATABASE)
index 5ce4738..14a6cb4 100644 (file)
 
 namespace WebCore {
 
-IDBCursorWithValue::IDBCursorWithValue()
+Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
+{
+    return adoptRef(*new IDBCursorWithValue(transaction, objectStore, info));
+}
+
+Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
+{
+    return adoptRef(*new IDBCursorWithValue(transaction, index, info));
+}
+
+IDBCursorWithValue::IDBCursorWithValue(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
+    : IDBCursor(transaction, objectStore, info)
+{
+}
+
+IDBCursorWithValue::IDBCursorWithValue(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
+    : IDBCursor(transaction, index, info)
+{
+}
+
+IDBCursorWithValue::~IDBCursorWithValue()
 {
 }
 
index 5f99090..f100ded 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBCursorWithValue_h
-#define IDBCursorWithValue_h
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
@@ -34,14 +33,18 @@ namespace WebCore {
 
 class IDBCursorWithValue : public IDBCursor {
 public:
-    virtual ~IDBCursorWithValue() { }
+    static Ref<IDBCursorWithValue> create(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
+    static Ref<IDBCursorWithValue> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
 
-protected:
-    IDBCursorWithValue();
+    virtual ~IDBCursorWithValue();
+
+    bool isKeyCursor() const final { return false; }
+
+private:
+    IDBCursorWithValue(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
+    IDBCursorWithValue(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
 };
 
 } // namespace WebCore
 
-#endif
-
-#endif // LegacyCursorWithValue_h
+#endif // ENABLE(INDEXED_DATABASE)
index 2d6479f..a29df01 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "DOMStringList.h"
+#include "EventQueue.h"
+#include "IDBConnectionToServer.h"
+#include "IDBDatabaseException.h"
+#include "IDBOpenDBRequest.h"
+#include "IDBResultData.h"
+#include "IDBTransaction.h"
+#include "IDBVersionChangeEvent.h"
+#include "Logging.h"
+#include "ScriptExecutionContext.h"
+
 namespace WebCore {
 
-IDBDatabase::IDBDatabase(ScriptExecutionContext* context)
-    : ActiveDOMObject(context)
+Ref<IDBDatabase> IDBDatabase::create(ScriptExecutionContext& context, IDBClient::IDBConnectionToServer& connection, const IDBResultData& resultData)
+{
+    return adoptRef(*new IDBDatabase(context, connection, resultData));
+}
+
+IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBClient::IDBConnectionToServer& connection, const IDBResultData& resultData)
+    : WebCore::ActiveDOMObject(&context)
+    , m_serverConnection(connection)
+    , m_info(resultData.databaseInfo())
+    , m_databaseConnectionIdentifier(resultData.databaseConnectionIdentifier())
+{
+    LOG(IndexedDB, "IDBDatabase::IDBDatabase - Creating database %s with version %" PRIu64 " connection %" PRIu64, m_info.name().utf8().data(), m_info.version(), m_databaseConnectionIdentifier);
+    suspendIfNeeded();
+    relaxAdoptionRequirement();
+    m_serverConnection->registerDatabaseConnection(*this);
+}
+
+IDBDatabase::~IDBDatabase()
+{
+    m_serverConnection->unregisterDatabaseConnection(*this);
+}
+
+bool IDBDatabase::hasPendingActivity() const
+{
+    return !m_closedInServer;
+}
+
+const String IDBDatabase::name() const
+{
+    return m_info.name();
+}
+
+uint64_t IDBDatabase::version() const
+{
+    return m_info.version();
+}
+
+RefPtr<DOMStringList> IDBDatabase::objectStoreNames() const
+{
+    RefPtr<DOMStringList> objectStoreNames = DOMStringList::create();
+    for (auto& name : m_info.objectStoreNames())
+        objectStoreNames->append(name);
+    objectStoreNames->sort();
+    return objectStoreNames;
+}
+
+RefPtr<WebCore::IDBObjectStore> IDBDatabase::createObjectStore(const String&, const Dictionary&, ExceptionCodeWithMessage&)
+{
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
+RefPtr<WebCore::IDBObjectStore> IDBDatabase::createObjectStore(const String& name, const IDBKeyPath& keyPath, bool autoIncrement, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBDatabase::createObjectStore");
+
+    ASSERT(!m_versionChangeTransaction || m_versionChangeTransaction->isVersionChange());
+
+    if (!m_versionChangeTransaction) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'createObjectStore' on 'IDBDatabase': The database is not running a version change transaction.");
+        return nullptr;
+    }
+
+    if (!m_versionChangeTransaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        return nullptr;
+    }
+
+    if (m_info.hasObjectStore(name)) {
+        ec.code = IDBDatabaseException::ConstraintError;
+        ec.message = ASCIILiteral("Failed to execute 'createObjectStore' on 'IDBDatabase': An object store with the specified name already exists.");
+        return nullptr;
+    }
+
+    if (!keyPath.isNull() && !keyPath.isValid()) {
+        ec.code = IDBDatabaseException::SyntaxError;
+        ec.message = ASCIILiteral("Failed to execute 'createObjectStore' on 'IDBDatabase': The keyPath option is not a valid key path.");
+        return nullptr;
+    }
+
+    if (autoIncrement && !keyPath.isNull()) {
+        if ((keyPath.type() == IndexedDB::KeyPathType::String && keyPath.string().isEmpty()) || keyPath.type() == IndexedDB::KeyPathType::Array) {
+            ec.code = IDBDatabaseException::InvalidAccessError;
+            ec.message = ASCIILiteral("Failed to execute 'createObjectStore' on 'IDBDatabase': The autoIncrement option was set but the keyPath option was empty or an array.");
+            return nullptr;
+        }
+    }
+
+    // Install the new ObjectStore into the connection's metadata.
+    IDBObjectStoreInfo info = m_info.createNewObjectStore(name, keyPath, autoIncrement);
+
+    // Create the actual IDBObjectStore from the transaction, which also schedules the operation server side.
+    Ref<IDBObjectStore> objectStore = m_versionChangeTransaction->createObjectStore(info);
+    return adoptRef(&objectStore.leakRef());
+}
+
+RefPtr<WebCore::IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext*, const Vector<String>& objectStores, const String& modeString, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBDatabase::transaction");
+
+    if (m_closePending) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.");
+        return nullptr;
+    }
+
+    if (objectStores.isEmpty()) {
+        ec.code = IDBDatabaseException::InvalidAccessError;
+        ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty.");
+        return nullptr;
+    }
+
+    IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, ec.code);
+    if (ec.code) {
+        ec.message = makeString(ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('"), modeString, ASCIILiteral("') is not one of 'readonly' or 'readwrite'."));
+        return nullptr;
+    }
+
+    if (mode != IndexedDB::TransactionMode::ReadOnly && mode != IndexedDB::TransactionMode::ReadWrite) {
+        ec.code = TypeError;
+        return nullptr;
+    }
+
+    if (m_versionChangeTransaction && !m_versionChangeTransaction->isFinishedOrFinishing()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.");
+        return nullptr;
+    }
+
+    for (auto& objectStoreName : objectStores) {
+        if (m_info.hasObjectStore(objectStoreName))
+            continue;
+        ec.code = IDBDatabaseException::NotFoundError;
+        ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.");
+        return nullptr;
+    }
+
+    auto info = IDBTransactionInfo::clientTransaction(m_serverConnection.get(), objectStores, mode);
+    auto transaction = IDBTransaction::create(*this, info);
+
+    LOG(IndexedDB, "IDBDatabase::transaction - Added active transaction %s", info.identifier().loggingString().utf8().data());
+
+    m_activeTransactions.set(info.identifier(), &transaction.get());
+
+    return adoptRef(&transaction.leakRef());
+}
+
+RefPtr<WebCore::IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* context, const String& objectStore, const String& mode, ExceptionCodeWithMessage& ec)
+{
+    Vector<String> objectStores(1);
+    objectStores[0] = objectStore;
+    return transaction(context, objectStores, mode, ec);
+}
+
+void IDBDatabase::deleteObjectStore(const String& objectStoreName, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBDatabase::deleteObjectStore");
+
+    if (!m_versionChangeTransaction) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'deleteObjectStore' on 'IDBDatabase': The database is not running a version change transaction.");
+        return;
+    }
+
+    if (!m_versionChangeTransaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        return;
+    }
+
+    if (!m_info.hasObjectStore(objectStoreName)) {
+        ec.code = IDBDatabaseException::NotFoundError;
+        ec.message = ASCIILiteral("Failed to execute 'deleteObjectStore' on 'IDBDatabase': The specified object store was not found.");
+        return;
+    }
+
+    m_info.deleteObjectStore(objectStoreName);
+    m_versionChangeTransaction->deleteObjectStore(objectStoreName);
+}
+
+void IDBDatabase::close()
+{
+    LOG(IndexedDB, "IDBDatabase::close - %" PRIu64, m_databaseConnectionIdentifier);
+
+    m_closePending = true;
+    maybeCloseInServer();
+}
+
+void IDBDatabase::maybeCloseInServer()
+{
+    LOG(IndexedDB, "IDBDatabase::maybeCloseInServer - %" PRIu64, m_databaseConnectionIdentifier);
+
+    if (m_closedInServer)
+        return;
+
+    // 3.3.9 Database closing steps
+    // Wait for all transactions created using this connection to complete.
+    // Once they are complete, this connection is closed.
+    if (!m_activeTransactions.isEmpty())
+        return;
+
+    m_closedInServer = true;
+    m_serverConnection->databaseConnectionClosed(*this);
+}
+
+const char* IDBDatabase::activeDOMObjectName() const
+{
+    return "IDBDatabase";
+}
+
+bool IDBDatabase::canSuspendForDocumentSuspension() const
+{
+    // FIXME: This value will sometimes be false when database operations are actually in progress.
+    // Such database operations do not yet exist.
+    return true;
+}
+
+void IDBDatabase::stop()
+{
+    LOG(IndexedDB, "IDBDatabase::stop - %" PRIu64, m_databaseConnectionIdentifier);
+
+    Vector<IDBResourceIdentifier> transactionIdentifiers;
+    transactionIdentifiers.reserveInitialCapacity(m_activeTransactions.size());
+
+    for (auto& id : m_activeTransactions.keys())
+        transactionIdentifiers.uncheckedAppend(id);
+
+    for (auto& id : transactionIdentifiers) {
+        IDBTransaction* transaction = m_activeTransactions.get(id);
+        if (transaction)
+            transaction->stop();
+    }
+
+    close();
+}
+
+Ref<IDBTransaction> IDBDatabase::startVersionChangeTransaction(const IDBTransactionInfo& info, IDBOpenDBRequest& request)
+{
+    LOG(IndexedDB, "IDBDatabase::startVersionChangeTransaction %s", info.identifier().loggingString().utf8().data());
+
+    ASSERT(!m_versionChangeTransaction);
+    ASSERT(info.mode() == IndexedDB::TransactionMode::VersionChange);
+    ASSERT(!m_closePending);
+    ASSERT(scriptExecutionContext());
+
+    Ref<IDBTransaction> transaction = IDBTransaction::create(*this, info, request);
+    m_versionChangeTransaction = &transaction.get();
+
+    m_activeTransactions.set(transaction->info().identifier(), &transaction.get());
+
+    return transaction;
+}
+
+void IDBDatabase::didStartTransaction(IDBTransaction& transaction)
+{
+    LOG(IndexedDB, "IDBDatabase::didStartTransaction %s", transaction.info().identifier().loggingString().utf8().data());
+    ASSERT(!m_versionChangeTransaction);
+
+    // It is possible for the client to have aborted a transaction before the server replies back that it has started.
+    if (m_abortingTransactions.contains(transaction.info().identifier()))
+        return;
+
+    m_activeTransactions.set(transaction.info().identifier(), &transaction);
+}
+
+void IDBDatabase::willCommitTransaction(IDBTransaction& transaction)
+{
+    LOG(IndexedDB, "IDBDatabase::willCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data());
+
+    auto refTransaction = m_activeTransactions.take(transaction.info().identifier());
+    ASSERT(refTransaction);
+    m_committingTransactions.set(transaction.info().identifier(), WTFMove(refTransaction));
+}
+
+void IDBDatabase::didCommitTransaction(IDBTransaction& transaction)
+{
+    LOG(IndexedDB, "IDBDatabase::didCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data());
+
+    if (m_versionChangeTransaction == &transaction)
+        m_info.setVersion(transaction.info().newVersion());
+
+    didCommitOrAbortTransaction(transaction);
+}
+
+void IDBDatabase::willAbortTransaction(IDBTransaction& transaction)
+{
+    LOG(IndexedDB, "IDBDatabase::willAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
+
+    auto refTransaction = m_activeTransactions.take(transaction.info().identifier());
+    if (!refTransaction)
+        refTransaction = m_committingTransactions.take(transaction.info().identifier());
+
+    ASSERT(refTransaction);
+    m_abortingTransactions.set(transaction.info().identifier(), WTFMove(refTransaction));
+
+    if (transaction.isVersionChange()) {
+        ASSERT(transaction.originalDatabaseInfo());
+        m_info = *transaction.originalDatabaseInfo();
+        m_closePending = true;
+    }
+}
+
+void IDBDatabase::didAbortTransaction(IDBTransaction& transaction)
+{
+    LOG(IndexedDB, "IDBDatabase::didAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
+
+    if (transaction.isVersionChange()) {
+        ASSERT(transaction.originalDatabaseInfo());
+        ASSERT(m_info.version() == transaction.originalDatabaseInfo()->version());
+        m_closePending = true;
+        maybeCloseInServer();
+    }
+
+    didCommitOrAbortTransaction(transaction);
+}
+
+void IDBDatabase::didCommitOrAbortTransaction(IDBTransaction& transaction)
+{
+    LOG(IndexedDB, "IDBDatabase::didCommitOrAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
+
+    if (m_versionChangeTransaction == &transaction)
+        m_versionChangeTransaction = nullptr;
+
+#ifndef NDBEBUG
+    unsigned count = 0;
+    if (m_activeTransactions.contains(transaction.info().identifier()))
+        ++count;
+    if (m_committingTransactions.contains(transaction.info().identifier()))
+        ++count;
+    if (m_abortingTransactions.contains(transaction.info().identifier()))
+        ++count;
+
+    ASSERT(count == 1);
+#endif
+
+    m_activeTransactions.remove(transaction.info().identifier());
+    m_committingTransactions.remove(transaction.info().identifier());
+    m_abortingTransactions.remove(transaction.info().identifier());
+
+    if (m_closePending)
+        maybeCloseInServer();
+}
+
+void IDBDatabase::fireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion)
+{
+    uint64_t currentVersion = m_info.version();
+    LOG(IndexedDB, "IDBDatabase::fireVersionChangeEvent - current version %" PRIu64 ", requested version %" PRIu64 ", connection %" PRIu64, currentVersion, requestedVersion, m_databaseConnectionIdentifier);
+
+    if (!scriptExecutionContext() || m_closePending) {
+        serverConnection().didFireVersionChangeEvent(m_databaseConnectionIdentifier, requestIdentifier);
+        return;
+    }
+
+    Ref<Event> event = IDBVersionChangeEvent::create(requestIdentifier, currentVersion, requestedVersion, eventNames().versionchangeEvent);
+    event->setTarget(this);
+    scriptExecutionContext()->eventQueue().enqueueEvent(WTFMove(event));
+}
+
+bool IDBDatabase::dispatchEvent(Event& event)
+{
+    LOG(IndexedDB, "IDBDatabase::dispatchEvent (%" PRIu64 ")", m_databaseConnectionIdentifier);
+
+    bool result = EventTargetWithInlineData::dispatchEvent(event);
+
+    if (event.isVersionChangeEvent() && event.type() == eventNames().versionchangeEvent)
+        serverConnection().didFireVersionChangeEvent(m_databaseConnectionIdentifier, downcast<IDBVersionChangeEvent>(event).requestIdentifier());
+
+    return result;
+}
+
+void IDBDatabase::didCreateIndexInfo(const IDBIndexInfo& info)
+{
+    auto* objectStore = m_info.infoForExistingObjectStore(info.objectStoreIdentifier());
+    ASSERT(objectStore);
+    objectStore->addExistingIndex(info);
+}
+
+void IDBDatabase::didDeleteIndexInfo(const IDBIndexInfo& info)
 {
+    auto* objectStore = m_info.infoForExistingObjectStore(info.objectStoreIdentifier());
+    ASSERT(objectStore);
+    objectStore->deleteIndex(info.name());
 }
 
 } // namespace WebCore
index f8476d8..ed0a6ec 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBDatabase_h
-#define IDBDatabase_h
+#pragma once
+
+#if ENABLE(INDEXED_DATABASE)
 
-#include "ActiveDOMObject.h"
-#include "DOMStringList.h"
 #include "Dictionary.h"
-#include "Event.h"
 #include "EventTarget.h"
-#include "IDBObjectStore.h"
-#include "IDBTransaction.h"
-#include "IndexedDB.h"
-#include "ScriptWrappable.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-#if ENABLE(INDEXED_DATABASE)
+#include "ExceptionCode.h"
+#include "IDBConnectionToServer.h"
+#include "IDBDatabase.h"
+#include "IDBDatabaseInfo.h"
 
 namespace WebCore {
 
-class ScriptExecutionContext;
-
-struct ExceptionCodeWithMessage;
+class DOMStringList;
+class IDBObjectStore;
+class IDBOpenDBRequest;
+class IDBResultData;
+class IDBTransaction;
+class IDBTransactionInfo;
 
 class IDBDatabase : public RefCounted<IDBDatabase>, public EventTargetWithInlineData, public ActiveDOMObject {
 public:
-    virtual ~IDBDatabase() { }
+    static Ref<IDBDatabase> create(ScriptExecutionContext&, IDBClient::IDBConnectionToServer&, const IDBResultData&);
+
+    virtual ~IDBDatabase();
 
-    // Implement the IDL
-    virtual const String name() const = 0;
-    virtual uint64_t version() const = 0;
-    virtual RefPtr<DOMStringList> objectStoreNames() const = 0;
+    // IDBDatabase IDL
+    const String name() const;
+    uint64_t version() const;
+    RefPtr<DOMStringList> objectStoreNames() const;
 
-    virtual RefPtr<IDBObjectStore> createObjectStore(const String& name, const Dictionary&, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBObjectStore> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const Vector<String>&, const String& mode, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const String&, const String& mode, ExceptionCodeWithMessage&) = 0;
-    virtual void deleteObjectStore(const String& name, ExceptionCodeWithMessage&) = 0;
-    virtual void close() = 0;
+    RefPtr<IDBObjectStore> createObjectStore(const String& name, const Dictionary&, ExceptionCodeWithMessage&);
+    RefPtr<IDBObjectStore> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, ExceptionCodeWithMessage&);
+    RefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const Vector<String>&, const String& mode, ExceptionCodeWithMessage&);
+    RefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const String&, const String& mode, ExceptionCodeWithMessage&);
+    void deleteObjectStore(const String& name, ExceptionCodeWithMessage&);
+    void close();
+
+    // EventTarget
+    EventTargetInterface eventTargetInterface() const final { return IDBDatabaseEventTargetInterfaceType; }
+    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
+    void refEventTarget() final { RefCounted<IDBDatabase>::ref(); }
+    void derefEventTarget() final { RefCounted<IDBDatabase>::deref(); }
 
     using RefCounted<IDBDatabase>::ref;
     using RefCounted<IDBDatabase>::deref;
 
-protected:
-    IDBDatabase(ScriptExecutionContext*);
+    const char* activeDOMObjectName() const final;
+    bool canSuspendForDocumentSuspension() const final;
+    void stop() final;
+
+    const IDBDatabaseInfo& info() const { return m_info; }
+    uint64_t databaseConnectionIdentifier() const { return m_databaseConnectionIdentifier; }
+
+    Ref<IDBTransaction> startVersionChangeTransaction(const IDBTransactionInfo&, IDBOpenDBRequest&);
+    void didStartTransaction(IDBTransaction&);
+
+    void willCommitTransaction(IDBTransaction&);
+    void didCommitTransaction(IDBTransaction&);
+    void willAbortTransaction(IDBTransaction&);
+    void didAbortTransaction(IDBTransaction&);
+
+    void fireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
+
+    IDBClient::IDBConnectionToServer& serverConnection() { return m_serverConnection.get(); }
+
+    void didCreateIndexInfo(const IDBIndexInfo&);
+    void didDeleteIndexInfo(const IDBIndexInfo&);
+
+    bool isClosingOrClosed() const { return m_closePending || m_closedInServer; }
+
+    bool dispatchEvent(Event&) final;
+
+    bool hasPendingActivity() const final;
+
+private:
+    IDBDatabase(ScriptExecutionContext&, IDBClient::IDBConnectionToServer&, const IDBResultData&);
+
+    void didCommitOrAbortTransaction(IDBTransaction&);
+
+    void maybeCloseInServer();
+
+    Ref<IDBClient::IDBConnectionToServer> m_serverConnection;
+    IDBDatabaseInfo m_info;
+    uint64_t m_databaseConnectionIdentifier { 0 };
+
+    bool m_closePending { false };
+    bool m_closedInServer { false };
+
+    RefPtr<IDBTransaction> m_versionChangeTransaction;
+    HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_activeTransactions;
+    HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_committingTransactions;
+    HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_abortingTransactions;
 };
 
 } // namespace WebCore
 
-#endif
-
-#endif // IDBDatabase_h
+#endif // ENABLE(INDEXED_DATABASE)
index 7a9f995..368ec0a 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "DOMRequestState.h"
+#include "Document.h"
+#include "ExceptionCode.h"
+#include "IDBBindingUtilities.h"
+#include "IDBDatabaseIdentifier.h"
+#include "IDBOpenDBRequest.h"
+#include "Logging.h"
+#include "Page.h"
+#include "SchemeRegistry.h"
+#include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
+
 namespace WebCore {
 
-IDBFactory::IDBFactory()
+static bool shouldThrowSecurityException(ScriptExecutionContext& context)
+{
+    ASSERT(is<Document>(context) || context.isWorkerGlobalScope());
+    if (is<Document>(context)) {
+        Document& document = downcast<Document>(context);
+        if (!document.frame())
+            return true;
+        if (!document.page())
+            return true;
+    }
+
+    if (!context.securityOrigin()->canAccessDatabase(context.topOrigin()))
+        return true;
+
+    return false;
+}
+
+Ref<IDBFactory> IDBFactory::create(IDBClient::IDBConnectionToServer& connection)
+{
+    return adoptRef(*new IDBFactory(connection));
+}
+
+IDBFactory::IDBFactory(IDBClient::IDBConnectionToServer& connection)
+    : m_connectionToServer(connection)
+{
+}
+
+RefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext&, ExceptionCode&)
+{
+    return nullptr;
+}
+
+RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, ExceptionCode& ec)
 {
+    LOG(IndexedDB, "IDBFactory::open");
+    
+    return openInternal(context, name, 0, ec).release();
+}
+
+RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCode& ec)
+{
+    LOG(IndexedDB, "IDBFactory::open");
+    
+    if (!version) {
+        ec = TypeError;
+        return nullptr;
+    }
+
+    return openInternal(context, name, version, ec).release();
+}
+
+RefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCode& ec)
+{
+    if (name.isNull()) {
+        ec = TypeError;
+        return nullptr;
+    }
+
+    if (shouldThrowSecurityException(context)) {
+        ec = SECURITY_ERR;
+        return nullptr;
+    }
+
+    ASSERT(context.securityOrigin());
+    ASSERT(context.topOrigin());
+    IDBDatabaseIdentifier databaseIdentifier(name, *context.securityOrigin(), *context.topOrigin());
+    if (!databaseIdentifier.isValid()) {
+        ec = TypeError;
+        return nullptr;
+    }
+
+    auto request = IDBOpenDBRequest::createOpenRequest(m_connectionToServer.get(), context, databaseIdentifier, version);
+    m_connectionToServer->openDatabase(request.get());
+
+    return adoptRef(&request.leakRef());
+}
+
+RefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext& context, const String& name, ExceptionCode& ec)
+{
+    LOG(IndexedDB, "IDBFactory::deleteDatabase - %s", name.utf8().data());
+
+    if (name.isNull()) {
+        ec = TypeError;
+        return nullptr;
+    }
+    
+    if (shouldThrowSecurityException(context)) {
+        ec = SECURITY_ERR;
+        return nullptr;
+    }
+
+    ASSERT(context.securityOrigin());
+    ASSERT(context.topOrigin());
+    IDBDatabaseIdentifier databaseIdentifier(name, *context.securityOrigin(), *context.topOrigin());
+    if (!databaseIdentifier.isValid()) {
+        ec = TypeError;
+        return nullptr;
+    }
+
+    auto request = IDBOpenDBRequest::createDeleteRequest(m_connectionToServer.get(), context, databaseIdentifier);
+    m_connectionToServer->deleteDatabase(request.get());
+
+    return adoptRef(&request.leakRef());
+}
+
+short IDBFactory::cmp(ScriptExecutionContext& context, const Deprecated::ScriptValue& firstValue, const Deprecated::ScriptValue& secondValue, ExceptionCodeWithMessage& ec)
+{
+    DOMRequestState requestState(&context);
+    RefPtr<IDBKey> first = scriptValueToIDBKey(&requestState, firstValue);
+    RefPtr<IDBKey> second = scriptValueToIDBKey(&requestState, secondValue);
+
+    ASSERT(first);
+    ASSERT(second);
+
+    if (!first->isValid() || !second->isValid()) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'cmp' on 'IDBFactory': The parameter is not a valid key.");
+        return 0;
+    }
+
+    return static_cast<short>(first->compare(second.get()));
 }
 
 } // namespace WebCore
index 44a5cc2..f5a1e78 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBFactory_h
-#define IDBFactory_h
-
-#include "IDBOpenDBRequest.h"
-#include "ScriptWrappable.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
-namespace WebCore {
-
-class IDBKey;
-class IDBKeyRange;
-class ScriptExecutionContext;
-
-struct ExceptionCodeWithMessage;
+#include "IDBConnectionToServer.h"
+#include "IDBFactory.h"
+#include "IDBOpenDBRequest.h"
 
-typedef int ExceptionCode;
+namespace WebCore {
 
 class IDBFactory : public RefCounted<IDBFactory> {
 public:
-    virtual ~IDBFactory() { }
+    static Ref<IDBFactory> create(IDBClient::IDBConnectionToServer&);
 
     // FIXME: getDatabaseNames is no longer a web-facing API, and should be removed from IDBFactory.
     // The Web Inspector currently uses this to enumerate the list of databases, but is more complicated as a result.
     // We should provide a simpler API to the Web Inspector then remove getDatabaseNames.
-    virtual RefPtr<IDBRequest> getDatabaseNames(ScriptExecutionContext&, ExceptionCode&) = 0;
+    RefPtr<IDBRequest> getDatabaseNames(ScriptExecutionContext&, ExceptionCode&);
 
-    virtual RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, ExceptionCode&) = 0;
-    virtual RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCode&) = 0;
-    virtual RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const String& name, ExceptionCode&) = 0;
+    RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, ExceptionCode&);
+    RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCode&);
+    RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const String& name, ExceptionCode&);
 
-    virtual short cmp(ScriptExecutionContext&, const Deprecated::ScriptValue& first, const Deprecated::ScriptValue& second, ExceptionCodeWithMessage&) = 0;
+    short cmp(ScriptExecutionContext&, const Deprecated::ScriptValue& first, const Deprecated::ScriptValue& second, ExceptionCodeWithMessage&);
 
-protected:
-    IDBFactory();
+private:
+    IDBFactory(IDBClient::IDBConnectionToServer&);
+    
+    RefPtr<IDBOpenDBRequest> openInternal(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCode&);
+    
+    Ref<IDBClient::IDBConnectionToServer> m_connectionToServer;
 };
 
 } // namespace WebCore
 
-#endif
-
-#endif // IDBFactory_h
+#endif // ENABLE(INDEXED_DATABASE)
index a2b4e2b..c647317 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "DOMRequestState.h"
+#include "IDBAny.h"
+#include "IDBBindingUtilities.h"
+#include "IDBCursor.h"
+#include "IDBDatabaseException.h"
+#include "IDBKeyRangeData.h"
+#include "IDBObjectStore.h"
+#include "IDBRequest.h"
+#include "IDBTransaction.h"
+#include "Logging.h"
+
 namespace WebCore {
 
-IDBIndex::IDBIndex()
+IDBIndex::IDBIndex(ScriptExecutionContext& context, const IDBIndexInfo& info, IDBObjectStore& objectStore)
+    : ActiveDOMObject(&context)
+    , m_info(info)
+    , m_objectStore(objectStore)
+{
+    suspendIfNeeded();
+}
+
+IDBIndex::~IDBIndex()
+{
+}
+
+const char* IDBIndex::activeDOMObjectName() const
+{
+    return "IDBIndex";
+}
+
+bool IDBIndex::canSuspendForDocumentSuspension() const
+{
+    return false;
+}
+
+bool IDBIndex::hasPendingActivity() const
+{
+    return !m_objectStore.modernTransaction().isFinished();
+}
+
+const String& IDBIndex::name() const
+{
+    return m_info.name();
+}
+
+RefPtr<IDBObjectStore> IDBIndex::objectStore()
+{
+    return &m_objectStore;
+}
+
+RefPtr<IDBAny> IDBIndex::keyPathAny() const
+{
+    return IDBAny::create(m_info.keyPath());
+}
+
+const IDBKeyPath& IDBIndex::keyPath() const
+{
+    return m_info.keyPath();
+}
+
+bool IDBIndex::unique() const
+{
+    return m_info.unique();
+}
+
+bool IDBIndex::multiEntry() const
+{
+    return m_info.multiEntry();
+}
+
+RefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext& context, IDBKeyRange* range, const String& directionString, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::openCursor");
+
+    if (m_deleted || m_objectStore.isDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The index or its object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!m_objectStore.modernTransaction().isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec.code);
+    if (ec.code) {
+        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.");
+        return nullptr;
+    }
+
+    IDBKeyRangeData rangeData = range;
+    if (rangeData.lowerKey.isNull())
+        rangeData.lowerKey = IDBKeyData::minimum();
+    if (rangeData.upperKey.isNull())
+        rangeData.upperKey = IDBKeyData::maximum();
+
+    auto info = IDBCursorInfo::indexCursor(m_objectStore.modernTransaction(), m_objectStore.info().identifier(), m_info.identifier(), rangeData, direction, IndexedDB::CursorType::KeyAndValue);
+    return m_objectStore.modernTransaction().requestOpenCursor(context, *this, info);
+}
+
+RefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::openCursor");
+    RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec.code);
+    if (ec.code) {
+        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The parameter is not a valid key.");
+        return nullptr;
+    }
+
+    return openCursor(context, keyRange.get(), direction, ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::count");
+
+    return doCount(context, IDBKeyRangeData::allKeys(), ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext& context, IDBKeyRange* range, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::count");
+
+    return doCount(context, range ? IDBKeyRangeData(range) : IDBKeyRangeData::allKeys(), ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::count");
+
+    DOMRequestState requestState(&context);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    if (!idbKey || idbKey->type() == KeyType::Invalid) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key.");
+        return nullptr;
+    }
+
+    return doCount(context, IDBKeyRangeData(idbKey.get()), ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::doCount(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
+{
+    if (m_deleted || m_objectStore.isDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The index or its object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!range.isValid()) {
+        ec.code = IDBDatabaseException::DataError;
+        return nullptr;
+    }
+
+    auto& transaction = m_objectStore.modernTransaction();
+    if (!transaction.isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    return transaction.requestCount(context, *this, range);
+}
+
+RefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext& context, IDBKeyRange* range, const String& directionString, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::openKeyCursor");
+
+    if (m_deleted || m_objectStore.isDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The index or its object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!m_objectStore.modernTransaction().isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec.code);
+    if (ec.code) {
+        ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.");
+        return nullptr;
+    }
+
+    auto info = IDBCursorInfo::indexCursor(m_objectStore.modernTransaction(), m_objectStore.info().identifier(), m_info.identifier(), range, direction, IndexedDB::CursorType::KeyOnly);
+    return m_objectStore.modernTransaction().requestOpenCursor(context, *this, info);
+}
+
+RefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::openKeyCursor");
+    RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec.code);
+    if (ec.code) {
+        ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The parameter is not a valid key.");
+        return nullptr;
+    }
+    return openKeyCursor(context, keyRange.get(), direction, ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext& context, IDBKeyRange* range, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::get");
+
+    return doGet(context, IDBKeyRangeData(range), ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::get");
+
+    DOMRequestState requestState(&context);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    if (!idbKey || idbKey->type() == KeyType::Invalid) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The parameter is not a valid key.");
+        return nullptr;
+    }
+
+    return doGet(context, IDBKeyRangeData(idbKey.get()), ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::doGet(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
+{
+    if (m_deleted || m_objectStore.isDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The index or its object store has been deleted.");
+        return nullptr;
+    }
+
+    if (range.isNull) {
+        ec.code = IDBDatabaseException::DataError;
+        return nullptr;
+    }
+
+    auto& transaction = m_objectStore.modernTransaction();
+    if (!transaction.isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    return transaction.requestGetValue(context, *this, range);
+}
+
+RefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext& context, IDBKeyRange* range, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::getKey");
+
+    return doGetKey(context, IDBKeyRangeData(range), ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBIndex::getKey");
+
+    DOMRequestState requestState(&context);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    if (!idbKey || idbKey->type() == KeyType::Invalid) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The parameter is not a valid key.");
+        return nullptr;
+    }
+
+    return doGetKey(context, IDBKeyRangeData(idbKey.get()), ec);
+}
+
+RefPtr<IDBRequest> IDBIndex::doGetKey(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
+{
+    if (m_deleted || m_objectStore.isDeleted()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The index or its object store has been deleted.");
+        return nullptr;
+    }
+
+    if (range.isNull) {
+        ec.code = IDBDatabaseException::DataError;
+        return nullptr;
+    }
+
+    auto& transaction = m_objectStore.modernTransaction();
+    if (!transaction.isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    return transaction.requestGetKey(context, *this, range);
+}
+
+void IDBIndex::markAsDeleted()
+{
+    ASSERT(!m_deleted);
+    m_deleted = true;
+}
+
+void IDBIndex::ref()
+{
+    m_objectStore.ref();
+}
+
+void IDBIndex::deref()
 {
+    m_objectStore.deref();
 }
 
 } // namespace WebCore
index 8510d4c..448d78f 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBIndex_h
-#define IDBIndex_h
+#pragma once
 
-#include "IDBCursor.h"
-#include "IDBDatabase.h"
-#include "IDBKeyPath.h"
-#include "IDBKeyRange.h"
-#include "IDBObjectStore.h"
-#include "IDBRequest.h"
-#include "ScriptWrappable.h"
-#include <wtf/Forward.h>
-#include <wtf/text/WTFString.h>
+#include "IDBIndex.h"
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "ActiveDOMObject.h"
+#include "ExceptionCode.h"
+#include "IDBCursor.h"
+#include "IDBIndexInfo.h"
+#include "IDBRequest.h"
+#include <bindings/ScriptValue.h>
+
 namespace WebCore {
 
+class IDBAny;
+class IDBKeyRange;
 class IDBObjectStore;
+struct IDBKeyRangeData;
 
-class IDBIndex {
+class IDBIndex : public ActiveDOMObject {
 public:
-    virtual ~IDBIndex() { }
+    IDBIndex(ScriptExecutionContext&, const IDBIndexInfo&, IDBObjectStore&);
+
+    virtual ~IDBIndex();
 
     // Implement the IDL
-    virtual const String& name() const = 0;
-    virtual RefPtr<IDBObjectStore> objectStore() = 0;
-    virtual RefPtr<IDBAny> keyPathAny() const = 0;
-    virtual const IDBKeyPath& keyPath() const = 0;
-    virtual bool unique() const = 0;
-    virtual bool multiEntry() const = 0;
-
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&) = 0;
-
-    virtual RefPtr<IDBRequest> count(ScriptExecutionContext&, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> count(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> count(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-
-    virtual RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext&, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&) = 0;
-
-    virtual RefPtr<IDBRequest> get(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> get(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-
-    virtual RefPtr<IDBRequest> getKey(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> getKey(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-
-    virtual bool isModern() const { return false; }
-
-    // We use our own ref/deref function because Legacy IDB and Modern IDB have very different
-    // lifetime management of their indexes.
-    // This will go away once Legacy IDB is dropped.
-    virtual void ref() = 0;
-    virtual void deref() = 0;
-
-protected:
-    IDBIndex();
+    const String& name() const;
+    RefPtr<IDBObjectStore> objectStore();
+    RefPtr<IDBAny> keyPathAny() const;
+    const IDBKeyPath& keyPath() const;
+    bool unique() const;
+    bool multiEntry() const;
+
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec) { return openCursor(context, static_cast<IDBKeyRange*>(nullptr), ec); }
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) { return openCursor(context, keyRange, IDBCursor::directionNext(), ec); }
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec) { return openCursor(context, key, IDBCursor::directionNext(), ec); }
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&);
+
+    RefPtr<IDBRequest> count(ScriptExecutionContext&, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> count(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> count(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&);
+
+    RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec) { return openKeyCursor(context, static_cast<IDBKeyRange*>(nullptr), ec); }
+    RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) { return openKeyCursor(context, keyRange, IDBCursor::directionNext(), ec); }
+    RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec) { return openKeyCursor(context, key, IDBCursor::directionNext(), ec); }
+    RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&);
+
+    RefPtr<IDBRequest> get(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> get(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> getKey(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> getKey(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&);
+
+    const IDBIndexInfo& info() const { return m_info; }
+
+    IDBObjectStore& modernObjectStore() { return m_objectStore; }
+
+    void markAsDeleted();
+    bool isDeleted() const { return m_deleted; }
+
+    void ref();
+    void deref();
+
+private:
+    RefPtr<IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> doGet(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> doGetKey(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
+
+    // ActiveDOMObject
+    const char* activeDOMObjectName() const;
+    bool canSuspendForDocumentSuspension() const;
+    bool hasPendingActivity() const;
+
+    IDBIndexInfo m_info;
+
+    bool m_deleted { false };
+
+    // IDBIndex objects are always owned by their referencing IDBObjectStore.
+    // Indexes will never outlive ObjectStores so its okay to keep a raw C++ reference here.
+    IDBObjectStore& m_objectStore;
 };
 
 } // namespace WebCore
 
-#endif
-
-#endif // IDBIndex_h
+#endif // ENABLE(INDEXED_DATABASE)
index 4a06415..5b0039e 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "DOMRequestState.h"
+#include "DOMStringList.h"
+#include "IDBBindingUtilities.h"
+#include "IDBCursor.h"
+#include "IDBDatabase.h"
+#include "IDBDatabaseException.h"
+#include "IDBError.h"
+#include "IDBIndex.h"
+#include "IDBKey.h"
+#include "IDBKeyRangeData.h"
+#include "IDBRequest.h"
+#include "IDBTransaction.h"
+#include "IndexedDB.h"
+#include "Logging.h"
+#include "SerializedScriptValue.h"
+#include <wtf/Locker.h>
+
 namespace WebCore {
 
-IDBObjectStore::IDBObjectStore()
+Ref<IDBObjectStore> IDBObjectStore::create(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
+{
+    return adoptRef(*new IDBObjectStore(context, info, transaction));
+}
+
+IDBObjectStore::IDBObjectStore(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
+    : ActiveDOMObject(&context)
+    , m_info(info)
+    , m_originalInfo(info)
+    , m_transaction(transaction)
+{
+    suspendIfNeeded();
+}
+
+IDBObjectStore::~IDBObjectStore()
+{
+}
+
+const char* IDBObjectStore::activeDOMObjectName() const
+{
+    return "IDBObjectStore";
+}
+
+bool IDBObjectStore::canSuspendForDocumentSuspension() const
+{
+    return false;
+}
+
+bool IDBObjectStore::hasPendingActivity() const
+{
+    return !m_transaction->isFinished();
+}
+
+const String IDBObjectStore::name() const
+{
+    return m_info.name();
+}
+
+RefPtr<WebCore::IDBAny> IDBObjectStore::keyPathAny() const
+{
+    return IDBAny::create(m_info.keyPath());
+}
+
+const IDBKeyPath IDBObjectStore::keyPath() const
+{
+    return m_info.keyPath();
+}
+
+RefPtr<DOMStringList> IDBObjectStore::indexNames() const
+{
+    RefPtr<DOMStringList> indexNames = DOMStringList::create();
+    for (auto& name : m_info.indexNames())
+        indexNames->append(name);
+    indexNames->sort();
+
+    return indexNames;
+}
+
+RefPtr<WebCore::IDBTransaction> IDBObjectStore::transaction()
+{
+    return &m_transaction.get();
+}
+
+bool IDBObjectStore::autoIncrement() const
+{
+    return m_info.autoIncrement();
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
+{
+    return openCursor(context, static_cast<IDBKeyRange*>(nullptr), ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
+{
+    return openCursor(context, keyRange, IDBCursor::directionNext(), ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
+{
+    return openCursor(context, key, IDBCursor::directionNext(), ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, IDBKeyRange* range, const String& directionString, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::openCursor");
+
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec.code);
+    if (ec.code)
+        return nullptr;
+
+    auto info = IDBCursorInfo::objectStoreCursor(m_transaction.get(), m_info.identifier(), range, direction);
+    Ref<IDBRequest> request = m_transaction->requestOpenCursor(context, *this, info);
+    return WTFMove(request);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec)
+{
+    RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec.code);
+    if (ec.code) {
+        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The parameter is not a valid key.");
+        return 0;
+    }
+
+    return openCursor(context, keyRange.get(), direction, ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::get(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::get");
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted.");
+        return nullptr;
+    }
+
+    DOMRequestState requestState(&context);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    if (!idbKey || idbKey->type() == KeyType::Invalid) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The parameter is not a valid key.");
+        return nullptr;
+    }
+
+    Ref<IDBRequest> request = m_transaction->requestGetRecord(context, *this, idbKey.get());
+    return WTFMove(request);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::get(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::get");
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        return nullptr;
+    }
+
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted.");
+        return nullptr;
+    }
+
+    IDBKeyRangeData keyRangeData(keyRange);
+    if (!keyRangeData.isValid()) {
+        ec.code = IDBDatabaseException::DataError;
+        return nullptr;
+    }
+
+    Ref<IDBRequest> request = m_transaction->requestGetRecord(context, *this, keyRangeData);
+    return WTFMove(request);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& state, JSC::JSValue value, ExceptionCodeWithMessage& ec)
+{
+    return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, InlineKeyCheck::Perform, ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& execState, JSC::JSValue value, JSC::JSValue key, ExceptionCodeWithMessage& ec)
+{
+    RefPtr<IDBKey> idbKey;
+    if (!key.isUndefined())
+        idbKey = scriptValueToIDBKey(execState, key);
+    return putOrAdd(execState, value, idbKey, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, InlineKeyCheck::Perform, ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& execState, JSC::JSValue value, JSC::JSValue key, ExceptionCodeWithMessage& ec)
+{
+    RefPtr<IDBKey> idbKey;
+    if (!key.isUndefined())
+        idbKey = scriptValueToIDBKey(execState, key);
+    return putOrAdd(execState, value, idbKey, IndexedDB::ObjectStoreOverwriteMode::Overwrite, InlineKeyCheck::Perform, ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& state, JSC::JSValue value, ExceptionCodeWithMessage& ec)
+{
+    return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::Overwrite, InlineKeyCheck::Perform, ec);
+}
+
+RefPtr<IDBRequest> IDBObjectStore::putForCursorUpdate(JSC::ExecState& state, JSC::JSValue value, JSC::JSValue key, ExceptionCodeWithMessage& ec)
+{
+    return putOrAdd(state, value, scriptValueToIDBKey(state, key), IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor, InlineKeyCheck::DoNotPerform, ec);
+}
+
+RefPtr<IDBRequest> IDBObjectStore::putOrAdd(JSC::ExecState& state, JSC::JSValue value, RefPtr<IDBKey> key, IndexedDB::ObjectStoreOverwriteMode overwriteMode, InlineKeyCheck inlineKeyCheck, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::putOrAdd");
+
+    // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
+    // the exception for an object store being deleted.
+    // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies.
+    // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit.
+    // Until this is sorted out, we'll agree with the test and the majority share browsers.
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    if (m_transaction->isReadOnly()) {
+        ec.code = IDBDatabaseException::ReadOnlyError;
+        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The transaction is read-only.");
+        return nullptr;
+    }
+
+    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(&state, value, nullptr, nullptr);
+    if (state.hadException()) {
+        // Clear the DOM exception from the serializer so we can give a more targeted exception.
+        state.clearException();
+
+        ec.code = IDBDatabaseException::DataCloneError;
+        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: An object could not be cloned.");
+        return nullptr;
+    }
+
+    if (serializedValue->hasBlobURLs()) {
+        // FIXME: Add Blob/File/FileList support
+        ec.code = IDBDatabaseException::DataCloneError;
+        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: BlobURLs are not yet supported.");
+        return nullptr;
+    }
+
+    if (key && !key->isValid()) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The parameter is not a valid key.");
+        return nullptr;
+    }
+
+    bool usesInlineKeys = !m_info.keyPath().isNull();
+    bool usesKeyGenerator = autoIncrement();
+    if (usesInlineKeys && inlineKeyCheck == InlineKeyCheck::Perform) {
+        if (key) {
+            ec.code = IDBDatabaseException::DataError;
+            ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The object store uses in-line keys and the key parameter was provided.");
+            return nullptr;
+        }
+
+        RefPtr<IDBKey> keyPathKey = maybeCreateIDBKeyFromScriptValueAndKeyPath(state, value, m_info.keyPath());
+        if (keyPathKey && !keyPathKey->isValid()) {
+            ec.code = IDBDatabaseException::DataError;
+            ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: Evaluating the object store's key path yielded a value that is not a valid key.");
+            return nullptr;
+        }
+
+        if (!keyPathKey) {
+            if (usesKeyGenerator) {
+                if (!canInjectIDBKeyIntoScriptValue(state, value, m_info.keyPath())) {
+                    ec.code = IDBDatabaseException::DataError;
+                    return nullptr;
+                }
+            } else {
+                ec.code = IDBDatabaseException::DataError;
+                ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value.");
+                return nullptr;
+            }
+        }
+
+        if (keyPathKey) {
+            ASSERT(!key);
+            key = keyPathKey;
+        }
+    } else if (!usesKeyGenerator && !key) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The object store uses out-of-line keys and has no key generator and the key parameter was not provided.");
+        return nullptr;
+    }
+
+    auto context = scriptExecutionContextFromExecState(&state);
+    if (!context) {
+        ec.code = IDBDatabaseException::UnknownError;
+        return nullptr;
+    }
+
+    Ref<IDBRequest> request = m_transaction->requestPutOrAdd(*context, *this, key.get(), *serializedValue, overwriteMode);
+    return adoptRef(request.leakRef());
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
+{
+    return doDelete(context, keyRange, ec);
+}
+
+RefPtr<IDBRequest> IDBObjectStore::doDelete(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::deleteFunction");
+
+    // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
+    // the exception for an object store being deleted.
+    // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies.
+    // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit.
+    // Until this is sorted out, we'll agree with the test and the majority share browsers.
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    if (m_transaction->isReadOnly()) {
+        ec.code = IDBDatabaseException::ReadOnlyError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The transaction is read-only.");
+        return nullptr;
+    }
+
+    IDBKeyRangeData keyRangeData(keyRange);
+    if (!keyRangeData.isValid()) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range.");
+        return nullptr;
+    }
+
+    Ref<IDBRequest> request = m_transaction->requestDeleteRecord(context, *this, keyRangeData);
+    return WTFMove(request);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
+{
+    return modernDelete(context, key.jsValue(), ec);
+}
+
+RefPtr<IDBRequest> IDBObjectStore::modernDelete(ScriptExecutionContext& context, JSC::JSValue key, ExceptionCodeWithMessage& ec)
+{
+    DOMRequestState requestState(&context);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    if (!idbKey || idbKey->type() == KeyType::Invalid) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key.");
+        return nullptr;
+    }
+
+    return doDelete(context, &IDBKeyRange::create(idbKey.get()).get(), ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::clear(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::clear");
+
+    // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
+    // the exception for an object store being deleted.
+    // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies.
+    // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit.
+    // Until this is sorted out, we'll agree with the test and the majority share browsers.
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'clear' on 'IDBObjectStore': The object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'clear' on 'IDBObjectStore': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    if (m_transaction->isReadOnly()) {
+        ec.code = IDBDatabaseException::ReadOnlyError;
+        ec.message = ASCIILiteral("Failed to execute 'clear' on 'IDBObjectStore': The transaction is read-only.");
+        return nullptr;
+    }
+
+    Ref<IDBRequest> request = m_transaction->requestClearObjectStore(context, *this);
+    return adoptRef(request.leakRef());
+}
+
+RefPtr<WebCore::IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext&, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::createIndex %s", name.utf8().data());
+
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!m_transaction->isVersionChange()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The database is not running a version change transaction.");
+        return nullptr;
+    }
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        return nullptr;
+    }
+
+    if (!keyPath.isValid()) {
+        ec.code = IDBDatabaseException::SyntaxError;
+        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The keyPath argument contains an invalid key path.");
+        return nullptr;
+    }
+
+    if (name.isNull()) {
+        ec.code = TypeError;
+        return nullptr;
+    }
+
+    if (m_info.hasIndex(name)) {
+        ec.code = IDBDatabaseException::ConstraintError;
+        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': An index with the specified name already exists.");
+        return nullptr;
+    }
+
+    if (keyPath.type() == IndexedDB::KeyPathType::Array && multiEntry) {
+        ec.code = IDBDatabaseException::InvalidAccessError;
+        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The keyPath argument was an array and the multiEntry option is true.");
+        return nullptr;
+    }
+
+    // Install the new Index into the ObjectStore's info.
+    IDBIndexInfo info = m_info.createNewIndex(name, keyPath, unique, multiEntry);
+    m_transaction->database().didCreateIndexInfo(info);
+
+    // Create the actual IDBObjectStore from the transaction, which also schedules the operation server side.
+    auto index = m_transaction->createIndex(*this, info);
+    RefPtr<IDBIndex> refIndex = index.get();
+
+    Locker<Lock> locker(m_referencedIndexLock);
+    m_referencedIndexes.set(name, WTFMove(index));
+
+    return WTFMove(refIndex);
+}
+
+RefPtr<WebCore::IDBIndex> IDBObjectStore::index(const String& indexName, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::index");
+
+    if (!scriptExecutionContext())
+        return nullptr;
+
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'index' on 'IDBObjectStore': The object store has been deleted.");
+        return nullptr;
+    }
+
+    if (m_transaction->isFinishedOrFinishing()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'index' on 'IDBObjectStore': The transaction is finished.");
+        return nullptr;
+    }
+
+    Locker<Lock> locker(m_referencedIndexLock);
+    auto iterator = m_referencedIndexes.find(indexName);
+    if (iterator != m_referencedIndexes.end())
+        return iterator->value.get();
+
+    auto* info = m_info.infoForExistingIndex(indexName);
+    if (!info) {
+        ec.code = IDBDatabaseException::NotFoundError;
+        ec.message = ASCIILiteral("Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.");
+        return nullptr;
+    }
+
+    auto index = std::make_unique<IDBIndex>(*scriptExecutionContext(), *info, *this);
+    RefPtr<IDBIndex> refIndex = index.get();
+    m_referencedIndexes.set(indexName, WTFMove(index));
+
+    return refIndex;
+}
+
+void IDBObjectStore::deleteIndex(const String& name, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::deleteIndex %s", name.utf8().data());
+
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The object store has been deleted.");
+        return;
+    }
+
+    if (!m_transaction->isVersionChange()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The database is not running a version change transaction.");
+        return;
+    }
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The transaction is inactive or finished.");
+        return;
+    }
+
+    if (!m_info.hasIndex(name)) {
+        ec.code = IDBDatabaseException::NotFoundError;
+        ec.message = ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The specified index was not found.");
+        return;
+    }
+
+    auto* info = m_info.infoForExistingIndex(name);
+    ASSERT(info);
+    m_transaction->database().didDeleteIndexInfo(*info);
+
+    m_info.deleteIndex(name);
+
+    {
+        Locker<Lock> locker(m_referencedIndexLock);
+        if (auto index = m_referencedIndexes.take(name)) {
+            index->markAsDeleted();
+            m_deletedIndexes.add(WTFMove(index));
+        }
+
+    }
+
+    m_transaction->deleteIndex(m_info.identifier(), name);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::count");
+
+    return doCount(context, IDBKeyRangeData::allKeys(), ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::count");
+
+    DOMRequestState requestState(&context);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    if (!idbKey || idbKey->type() == KeyType::Invalid) {
+        ec.code = IDBDatabaseException::DataError;
+        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key.");
+        return nullptr;
+    }
+
+    return doCount(context, IDBKeyRangeData(idbKey.get()), ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext& context, IDBKeyRange* range, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBObjectStore::count");
+
+    return doCount(context, range ? IDBKeyRangeData(range) : IDBKeyRangeData::allKeys(), ec);
+}
+
+RefPtr<WebCore::IDBRequest> IDBObjectStore::doCount(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
+{
+    // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
+    // the exception for an object store being deleted.
+    // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies.
+    // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit.
+    // Until this is sorted out, we'll agree with the test and the majority share browsers.
+    if (m_deleted) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBObjectStore': The object store has been deleted.");
+        return nullptr;
+    }
+
+    if (!m_transaction->isActive()) {
+        ec.code = IDBDatabaseException::TransactionInactiveError;
+        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBObjectStore': The transaction is inactive or finished.");
+        return nullptr;
+    }
+
+    if (!range.isValid()) {
+        ec.code = IDBDatabaseException::DataError;
+        return nullptr;
+    }
+
+    return m_transaction->requestCount(context, *this, range);
+}
+
+void IDBObjectStore::markAsDeleted()
+{
+    m_deleted = true;
+}
+
+void IDBObjectStore::rollbackInfoForVersionChangeAbort()
+{
+    m_info = m_originalInfo;
+}
+
+void IDBObjectStore::visitReferencedIndexes(JSC::SlotVisitor& visitor) const
 {
+    Locker<Lock> locker(m_referencedIndexLock);
+    for (auto& index : m_referencedIndexes.values())
+        visitor.addOpaqueRoot(index.get());
 }
 
 } // namespace WebCore
index 03ded42..1b7cd80 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBObjectStore_h
-#define IDBObjectStore_h
-
-#include "Dictionary.h"
-#include "ExceptionCode.h"
-#include "ScriptWrappable.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
-namespace Deprecated {
-class ScriptValue;
-}
-
-namespace JSC {
-class ExecState;
-class JSValue;
-}
+#include "ActiveDOMObject.h"
+#include "IDBIndex.h"
+#include "IDBObjectStore.h"
+#include "IDBObjectStoreInfo.h"
+#include "IndexedDB.h"
 
 namespace WebCore {
 
 class DOMStringList;
 class IDBAny;
 class IDBIndex;
-class IDBKeyPath;
+class IDBKey;
 class IDBKeyRange;
 class IDBRequest;
 class IDBTransaction;
-class ScriptExecutionContext;
+struct IDBKeyRangeData;
 
-class IDBObjectStore : public RefCounted<IDBObjectStore> {
+class IDBObjectStore : public RefCounted<IDBObjectStore>, public ActiveDOMObject {
 public:
-    virtual ~IDBObjectStore() { }
+    static Ref<IDBObjectStore> create(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&);
+
+    ~IDBObjectStore();
 
     // Implement the IDBObjectStore IDL
-    virtual const String name() const = 0;
-    virtual RefPtr<IDBAny> keyPathAny() const = 0;
-    virtual const IDBKeyPath keyPath() const = 0;
-    virtual RefPtr<DOMStringList> indexNames() const = 0;
-    virtual RefPtr<IDBTransaction> transaction() = 0;
-    virtual bool autoIncrement() const = 0;
-
-    virtual RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&) = 0;
-
-    virtual RefPtr<IDBRequest> get(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> get(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> clear(ScriptExecutionContext&, ExceptionCodeWithMessage&) = 0;
-
-    virtual RefPtr<IDBIndex> createIndex(ScriptExecutionContext&, const String& name, const IDBKeyPath&, bool unique, bool multiEntry, ExceptionCodeWithMessage&) = 0;
-
-    virtual RefPtr<IDBIndex> index(const String& name, ExceptionCodeWithMessage&) = 0;
-    virtual void deleteIndex(const String& name, ExceptionCodeWithMessage&) = 0;
-
-    virtual RefPtr<IDBRequest> count(ScriptExecutionContext&, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> count(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) = 0;
-    virtual RefPtr<IDBRequest> count(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) = 0;
-
-    virtual bool isModern() const { return false; }
-
-protected:
-    IDBObjectStore();
+    const String name() const;
+    RefPtr<IDBAny> keyPathAny() const;
+    const IDBKeyPath keyPath() const;
+    RefPtr<DOMStringList> indexNames() const;
+    RefPtr<IDBTransaction> transaction();
+    bool autoIncrement() const;
+
+    RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> get(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> get(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> clear(ScriptExecutionContext&, ExceptionCodeWithMessage&);
+    RefPtr<IDBIndex> createIndex(ScriptExecutionContext&, const String& name, const IDBKeyPath&, bool unique, bool multiEntry, ExceptionCodeWithMessage&);
+    RefPtr<IDBIndex> index(const String& name, ExceptionCodeWithMessage&);
+    void deleteIndex(const String& name, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> count(ScriptExecutionContext&, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> count(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> count(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&);
+
+    RefPtr<IDBRequest> putForCursorUpdate(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> modernDelete(ScriptExecutionContext&, JSC::JSValue key, ExceptionCodeWithMessage&);
+
+    void markAsDeleted();
+    bool isDeleted() const { return m_deleted; }
+
+    const IDBObjectStoreInfo& info() const { return m_info; }
+
+    // FIXME: After removing LegacyIDB and folding abstract/implementation classes together,
+    // this will no longer be necessary.
+    IDBTransaction& modernTransaction() { return m_transaction.get(); }
+
+    void rollbackInfoForVersionChangeAbort();
+
+    void visitReferencedIndexes(JSC::SlotVisitor&) const;
+
+private:
+    IDBObjectStore(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&);
+
+    enum class InlineKeyCheck {
+        Perform,
+        DoNotPerform,
+    };
+
+    RefPtr<IDBRequest> putOrAdd(JSC::ExecState&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, InlineKeyCheck, ExceptionCodeWithMessage&);
+    RefPtr<WebCore::IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
+    RefPtr<IDBRequest> doDelete(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
+
+    // ActiveDOMObject
+    const char* activeDOMObjectName() const;
+    bool canSuspendForDocumentSuspension() const;
+    bool hasPendingActivity() const;
+
+    IDBObjectStoreInfo m_info;
+    IDBObjectStoreInfo m_originalInfo;
+    Ref<IDBTransaction> m_transaction;
+
+    bool m_deleted { false };
+
+    mutable Lock m_referencedIndexLock;
+    HashMap<String, std::unique_ptr<IDBIndex>> m_referencedIndexes;
+    HashSet<std::unique_ptr<IDBIndex>> m_deletedIndexes;
 };
 
 } // namespace WebCore
 
-#endif
-
-#endif // IDBObjectStore_h
+#endif // ENABLE(INDEXED_DATABASE)
index 82ce179..674c419 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "IDBDatabase.h"
+#include "IDBError.h"
+#include "IDBRequestCompletionEvent.h"
+#include "IDBResultData.h"
+#include "IDBTransaction.h"
+#include "IDBVersionChangeEvent.h"
+#include "Logging.h"
+
 namespace WebCore {
 
-IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context)
-    : IDBRequest(context)
+Ref<IDBOpenDBRequest> IDBOpenDBRequest::createDeleteRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier)
+{
+    ASSERT(databaseIdentifier.isValid());
+    return adoptRef(*new IDBOpenDBRequest(connection, context, databaseIdentifier, 0, IndexedDB::RequestType::Delete));
+}
+
+Ref<IDBOpenDBRequest> IDBOpenDBRequest::createOpenRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
+{
+    ASSERT(databaseIdentifier.isValid());
+    return adoptRef(*new IDBOpenDBRequest(connection, context, databaseIdentifier, version, IndexedDB::RequestType::Open));
+}
+    
+IDBOpenDBRequest::IDBOpenDBRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType)
+    : IDBRequest(connection, context)
+    , m_databaseIdentifier(databaseIdentifier)
+    , m_version(version)
+{
+    m_requestType = requestType;
+}
+
+IDBOpenDBRequest::~IDBOpenDBRequest()
+{
+}
+
+void IDBOpenDBRequest::onError(const IDBResultData& data)
+{
+    m_domError = DOMError::create(data.error().name());
+    enqueueEvent(IDBRequestCompletionEvent::create(eventNames().errorEvent, true, true, *this));
+}
+
+void IDBOpenDBRequest::versionChangeTransactionDidFinish()
+{
+    // 3.3.7 "versionchange" transaction steps
+    // When the transaction is finished, after firing complete/abort on the transaction, immediately set request's transaction property to null.
+    m_shouldExposeTransactionToDOM = false;
+}
+
+void IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit()
+{
+    LOG(IndexedDB, "IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit()");
+
+    ASSERT(hasPendingActivity());
+    ASSERT(m_result);
+    ASSERT(m_result->type() == IDBAny::Type::IDBDatabase);
+    m_transaction->addRequest(*this);
+
+    auto event = IDBRequestCompletionEvent::create(eventNames().successEvent, false, false, *this);
+    m_openDatabaseSuccessEvent = &event.get();
+
+    enqueueEvent(WTFMove(event));
+}
+
+void IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion()
+{
+    LOG(IndexedDB, "IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion()");
+
+    ASSERT(hasPendingActivity());
+
+    IDBError idbError(IDBDatabaseException::AbortError);
+    m_domError = DOMError::create(idbError.name());
+    m_result = IDBAny::createUndefined();
+
+    m_transaction->addRequest(*this);
+    enqueueEvent(IDBRequestCompletionEvent::create(eventNames().errorEvent, true, true, *this));
+}
+
+bool IDBOpenDBRequest::dispatchEvent(Event& event)
+{
+    bool result = IDBRequest::dispatchEvent(event);
+
+    if (m_transaction && m_transaction->isVersionChange() && (event.type() == eventNames().errorEvent || event.type() == eventNames().successEvent))
+        m_transaction->database().serverConnection().didFinishHandlingVersionChangeTransaction(*m_transaction);
+
+    return result;
+}
+
+void IDBOpenDBRequest::onSuccess(const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBOpenDBRequest::onSuccess()");
+
+    if (!scriptExecutionContext())
+        return;
+
+    Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connection(), resultData);
+    m_result = IDBAny::create(WTFMove(database));
+    m_readyState = IDBRequestReadyState::Done;
+
+    enqueueEvent(IDBRequestCompletionEvent::create(eventNames().successEvent, false, false, *this));
+}
+
+void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
+{
+    Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connection(), resultData);
+    Ref<IDBTransaction> transaction = database->startVersionChangeTransaction(resultData.transactionInfo(), *this);
+
+    ASSERT(transaction->info().mode() == IndexedDB::TransactionMode::VersionChange);
+    ASSERT(transaction->originalDatabaseInfo());
+
+    uint64_t oldVersion = transaction->originalDatabaseInfo()->version();
+    uint64_t newVersion = transaction->info().newVersion();
+
+    LOG(IndexedDB, "IDBOpenDBRequest::onUpgradeNeeded() - current version is %" PRIu64 ", new is %" PRIu64, oldVersion, newVersion);
+
+    m_result = IDBAny::create(WTFMove(database));
+    m_readyState = IDBRequestReadyState::Done;
+    m_transaction = adoptRef(&transaction.leakRef());
+    m_transaction->addRequest(*this);
+
+    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, newVersion, eventNames().upgradeneededEvent));
+}
+
+void IDBOpenDBRequest::onDeleteDatabaseSuccess(const IDBResultData& resultData)
+{
+    uint64_t oldVersion = resultData.databaseInfo().version();
+
+    LOG(IndexedDB, "IDBOpenDBRequest::onDeleteDatabaseSuccess() - current version is %" PRIu64, oldVersion);
+
+    m_readyState = IDBRequestReadyState::Done;
+    m_result = IDBAny::createUndefined();
+
+    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, 0, eventNames().successEvent));
+}
+
+void IDBOpenDBRequest::requestCompleted(const IDBResultData& data)
+{
+    LOG(IndexedDB, "IDBOpenDBRequest::requestCompleted");
+
+    // If an Open request was completed after the page has navigated, leaving this request
+    // with a stopped script execution context, we need to message back to the server so it
+    // doesn't hang waiting on a database connection or transaction that will never exist.
+    if (m_contextStopped) {
+        switch (data.type()) {
+        case IDBResultType::OpenDatabaseSuccess:
+            connection().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), IDBResourceIdentifier::emptyValue());
+            break;
+        case IDBResultType::OpenDatabaseUpgradeNeeded:
+            connection().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier());
+            break;
+        default:
+            break;
+        }
+
+        return;
+    }
+
+    switch (data.type()) {
+    case IDBResultType::Error:
+        onError(data);
+        break;
+    case IDBResultType::OpenDatabaseSuccess:
+        onSuccess(data);
+        break;
+    case IDBResultType::OpenDatabaseUpgradeNeeded:
+        onUpgradeNeeded(data);
+        break;
+    case IDBResultType::DeleteDatabaseSuccess:
+        onDeleteDatabaseSuccess(data);
+        break;
+    default:
+        RELEASE_ASSERT_NOT_REACHED();
+    }
+}
+
+void IDBOpenDBRequest::requestBlocked(uint64_t oldVersion, uint64_t newVersion)
 {
+    LOG(IndexedDB, "IDBOpenDBRequest::requestBlocked");
+    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, newVersion, eventNames().blockedEvent));
 }
 
 } // namespace WebCore
index 00addc0..1dcd7d6 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBOpenDBRequest_h
-#define IDBOpenDBRequest_h
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "DOMError.h"
+#include "IDBDatabaseIdentifier.h"
 #include "IDBRequest.h"
-#include "IndexedDB.h"
 
 namespace WebCore {
 
+class Event;
+class IDBDatabaseIdentifier;
+class IDBResultData;
+class ScriptExecutionContext;
+
+namespace IDBClient {
+class IDBConnectionToServer;
+}
+
 class IDBOpenDBRequest : public IDBRequest {
 public:
-    virtual ~IDBOpenDBRequest() { }
+    static Ref<IDBOpenDBRequest> createDeleteRequest(IDBClient::IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&);
+    static Ref<IDBOpenDBRequest> createOpenRequest(IDBClient::IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version);
+
+    ~IDBOpenDBRequest() final;
+    
+    const IDBDatabaseIdentifier& databaseIdentifier() const { return m_databaseIdentifier; }
+    uint64_t version() const { return m_version; }
+
+    void requestCompleted(const IDBResultData&);
+    void requestBlocked(uint64_t oldVersion, uint64_t newVersion);
+
+    void versionChangeTransactionDidFinish();
+    void fireSuccessAfterVersionChangeCommit();
+    void fireErrorAfterVersionChangeCompletion();
 
-protected:
-    IDBOpenDBRequest(ScriptExecutionContext&);
+    bool dispatchEvent(Event&) final;
+
+private:
+    IDBOpenDBRequest(IDBClient::IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType);
+
+    void onError(const IDBResultData&);
+    void onSuccess(const IDBResultData&);
+    void onUpgradeNeeded(const IDBResultData&);
+    void onDeleteDatabaseSuccess(const IDBResultData&);
+
+    bool isOpenDBRequest() const override { return true; }
+
+    IDBDatabaseIdentifier m_databaseIdentifier;
+    uint64_t m_version { 0 };
 };
 
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
-
-#endif // IDBOpenDBRequest_h
index 012f369..fe6950b 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "DOMError.h"
+#include "DOMRequestState.h"
+#include "Event.h"
+#include "EventQueue.h"
+#include "IDBBindingUtilities.h"
+#include "IDBCursor.h"
+#include "IDBDatabase.h"
+#include "IDBDatabaseException.h"
+#include "IDBEventDispatcher.h"
+#include "IDBKeyData.h"
+#include "IDBResultData.h"
+#include "Logging.h"
+#include "ScriptExecutionContext.h"
+#include "ThreadSafeDataBuffer.h"
+#include <wtf/NeverDestroyed.h>
+
 namespace WebCore {
 
-IDBRequest::IDBRequest(ScriptExecutionContext& context)
+Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction)
+{
+    return adoptRef(*new IDBRequest(context, objectStore, transaction));
+}
+
+Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
+{
+    return adoptRef(*new IDBRequest(context, cursor, transaction));
+}
+
+Ref<IDBRequest> IDBRequest::createCount(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction)
+{
+    return adoptRef(*new IDBRequest(context, index, transaction));
+}
+
+Ref<IDBRequest> IDBRequest::createGet(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType requestedRecordType, IDBTransaction& transaction)
+{
+    return adoptRef(*new IDBRequest(context, index, requestedRecordType, transaction));
+}
+
+IDBRequest::IDBRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context)
+    : ActiveDOMObject(&context)
+    , m_connection(connection)
+    , m_resourceIdentifier(connection)
+{
+    suspendIfNeeded();
+}
+
+IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction)
     : ActiveDOMObject(&context)
+    , m_transaction(&transaction)
+    , m_connection(transaction.serverConnection())
+    , m_resourceIdentifier(transaction.serverConnection())
+    , m_source(IDBAny::create(objectStore))
+{
+    suspendIfNeeded();
+}
+
+IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
+    : ActiveDOMObject(&context)
+    , m_transaction(&transaction)
+    , m_connection(transaction.serverConnection())
+    , m_resourceIdentifier(transaction.serverConnection())
+    , m_source(cursor.source())
+    , m_pendingCursor(&cursor)
+{
+    suspendIfNeeded();
+
+    cursor.setRequest(*this);
+}
+
+IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction)
+    : ActiveDOMObject(&context)
+    , m_transaction(&transaction)
+    , m_connection(transaction.serverConnection())
+    , m_resourceIdentifier(transaction.serverConnection())
+    , m_source(IDBAny::create(index))
+{
+    suspendIfNeeded();
+}
+
+IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType requestedRecordType, IDBTransaction& transaction)
+    : IDBRequest(context, index, transaction)
+{
+    m_requestedIndexRecordType = requestedRecordType;
+}
+
+IDBRequest::~IDBRequest()
+{
+    if (m_result) {
+        auto type = m_result->type();
+        if (type == IDBAny::Type::IDBCursor || type == IDBAny::Type::IDBCursorWithValue)
+            m_result->idbCursor()->clearRequest();
+    }
+}
+
+RefPtr<WebCore::IDBAny> IDBRequest::result(ExceptionCodeWithMessage& ec) const
+{
+    if (m_readyState == IDBRequestReadyState::Done)
+        return m_result;
+
+    ec.code = IDBDatabaseException::InvalidStateError;
+    ec.message = ASCIILiteral("Failed to read the 'result' property from 'IDBRequest': The request has not finished.");
+    return nullptr;
+}
+
+unsigned short IDBRequest::errorCode(ExceptionCode&) const
 {
+    return 0;
+}
+
+RefPtr<DOMError> IDBRequest::error(ExceptionCodeWithMessage& ec) const
+{
+    if (m_readyState == IDBRequestReadyState::Done)
+        return m_domError;
+
+    ec.code = IDBDatabaseException::InvalidStateError;
+    ec.message = ASCIILiteral("Failed to read the 'error' property from 'IDBRequest': The request has not finished.");
+    return nullptr;
+}
+
+RefPtr<WebCore::IDBAny> IDBRequest::source() const
+{
+    return m_source;
+}
+
+void IDBRequest::setSource(IDBCursor& cursor)
+{
+    ASSERT(!m_cursorRequestNotifier);
+
+    m_source = IDBAny::create(cursor);
+    m_cursorRequestNotifier = std::make_unique<ScopeGuard>([this]() {
+        ASSERT(m_source->type() == IDBAny::Type::IDBCursor || m_source->type() == IDBAny::Type::IDBCursorWithValue);
+        m_source->idbCursor()->decrementOutstandingRequestCount();
+    });
+}
+
+void IDBRequest::setVersionChangeTransaction(IDBTransaction& transaction)
+{
+    ASSERT(!m_transaction);
+    ASSERT(transaction.isVersionChange());
+    ASSERT(!transaction.isFinishedOrFinishing());
+
+    m_transaction = &transaction;
+}
+
+RefPtr<WebCore::IDBTransaction> IDBRequest::transaction() const
+{
+    return m_shouldExposeTransactionToDOM ? m_transaction : nullptr;
+}
+
+const String& IDBRequest::readyState() const
+{
+    static WTF::NeverDestroyed<String> pendingString("pending");
+    static WTF::NeverDestroyed<String> doneString("done");
+
+    switch (m_readyState) {
+    case IDBRequestReadyState::Pending:
+        return pendingString;
+    case IDBRequestReadyState::Done:
+        return doneString;
+    default:
+        RELEASE_ASSERT_NOT_REACHED();
+    }
+}
+
+uint64_t IDBRequest::sourceObjectStoreIdentifier() const
+{
+    if (!m_source)
+        return 0;
+
+    if (m_source->type() == IDBAny::Type::IDBObjectStore) {
+        auto* objectStore = m_source->idbObjectStore().get();
+        if (!objectStore)
+            return 0;
+        return objectStore->info().identifier();
+    }
+
+    if (m_source->type() == IDBAny::Type::IDBIndex) {
+        auto* index = m_source->idbIndex().get();
+        if (!index)
+            return 0;
+        return index->info().objectStoreIdentifier();
+    }
+
+    return 0;
+}
+
+uint64_t IDBRequest::sourceIndexIdentifier() const
+{
+    if (!m_source)
+        return 0;
+    if (m_source->type() != IDBAny::Type::IDBIndex)
+        return 0;
+    if (!m_source->idbIndex())
+        return 0;
+
+    return m_source->idbIndex()->info().identifier();
+}
+
+IndexedDB::IndexRecordType IDBRequest::requestedIndexRecordType() const
+{
+    ASSERT(m_source);
+    ASSERT(m_source->type() == IDBAny::Type::IDBIndex);
+
+    return m_requestedIndexRecordType;
+}
+
+EventTargetInterface IDBRequest::eventTargetInterface() const
+{
+    return IDBRequestEventTargetInterfaceType;
+}
+
+const char* IDBRequest::activeDOMObjectName() const
+{
+    return "IDBRequest";
+}
+
+bool IDBRequest::canSuspendForDocumentSuspension() const
+{
+    return false;
+}
+
+bool IDBRequest::hasPendingActivity() const
+{
+    return m_hasPendingActivity;
+}
+
+void IDBRequest::stop()
+{
+    ASSERT(!m_contextStopped);
+    m_contextStopped = true;
+}
+
+void IDBRequest::enqueueEvent(Ref<Event>&& event)
+{
+    if (!scriptExecutionContext() || m_contextStopped)
+        return;
+
+    event->setTarget(this);
+    scriptExecutionContext()->eventQueue().enqueueEvent(WTFMove(event));
+}
+
+bool IDBRequest::dispatchEvent(Event& event)
+{
+    LOG(IndexedDB, "IDBRequest::dispatchEvent - %s (%p)", event.type().string().utf8().data(), this);
+
+    ASSERT(m_hasPendingActivity);
+    ASSERT(!m_contextStopped);
+
+    if (event.type() != eventNames().blockedEvent)
+        m_readyState = IDBRequestReadyState::Done;
+
+    Vector<RefPtr<EventTarget>> targets;
+    targets.append(this);
+
+    if (&event == m_openDatabaseSuccessEvent)
+        m_openDatabaseSuccessEvent = nullptr;
+    else if (m_transaction && !m_transaction->isFinished()) {
+        targets.append(m_transaction);
+        targets.append(m_transaction->db());
+    }
+
+    m_hasPendingActivity = false;
+
+    m_cursorRequestNotifier = nullptr;
+
+    bool dontPreventDefault;
+    {
+        TransactionActivator activator(m_transaction.get());
+        dontPreventDefault = IDBEventDispatcher::dispatch(event, targets);
+    }
+
+    // IDBEventDispatcher::dispatch() might have set the pending activity flag back to true, suggesting the request will be reused.
+    // We might also re-use the request if this event was the upgradeneeded event for an IDBOpenDBRequest.
+    if (!m_hasPendingActivity)
+        m_hasPendingActivity = isOpenDBRequest() && (event.type() == eventNames().upgradeneededEvent || event.type() == eventNames().blockedEvent);
+
+    // The request should only remain in the transaction's request list if it represents a pending cursor operation, or this is an open request that was blocked.
+    if (m_transaction && !m_pendingCursor && event.type() != eventNames().blockedEvent)
+        m_transaction->removeRequest(*this);
+
+    if (dontPreventDefault && event.type() == eventNames().errorEvent && m_transaction && !m_transaction->isFinishedOrFinishing()) {
+        ASSERT(m_domError);
+        m_transaction->abortDueToFailedRequest(*m_domError);
+    }
+
+    return dontPreventDefault;
+}
+
+void IDBRequest::uncaughtExceptionInEventHandler()
+{
+    LOG(IndexedDB, "IDBRequest::uncaughtExceptionInEventHandler");
+
+    if (m_transaction && m_idbError.code() != IDBDatabaseException::AbortError)
+        m_transaction->abortDueToFailedRequest(DOMError::create(IDBDatabaseException::getErrorName(IDBDatabaseException::AbortError)));
+}
+
+void IDBRequest::setResult(const IDBKeyData* keyData)
+{
+    if (!keyData) {
+        m_result = nullptr;
+        return;
+    }
+
+    Deprecated::ScriptValue value = idbKeyDataToScriptValue(scriptExecutionContext(), *keyData);
+    m_result = IDBAny::create(WTFMove(value));
+}
+
+void IDBRequest::setResult(uint64_t number)
+{
+    ASSERT(scriptExecutionContext());
+    m_result = IDBAny::create(Deprecated::ScriptValue(scriptExecutionContext()->vm(), JSC::JSValue(number)));
+}
+
+void IDBRequest::setResultToStructuredClone(const ThreadSafeDataBuffer& valueData)
+{
+    LOG(IndexedDB, "IDBRequest::setResultToStructuredClone");
+
+    auto context = scriptExecutionContext();
+    if (!context)
+        return;
+
+    Deprecated::ScriptValue value = deserializeIDBValueData(*context, valueData);
+    m_result = IDBAny::create(WTFMove(value));
+}
+
+void IDBRequest::setResultToUndefined()
+{
+    m_result = IDBAny::createUndefined();
+}
+
+IDBCursor* IDBRequest::resultCursor()
+{
+    if (!m_result)
+        return nullptr;
+    if (m_result->type() == IDBAny::Type::IDBCursor || m_result->type() == IDBAny::Type::IDBCursorWithValue)
+        return m_result->idbCursor().get();
+    return nullptr;
+}
+
+void IDBRequest::willIterateCursor(IDBCursor& cursor)
+{
+    ASSERT(m_readyState == IDBRequestReadyState::Done);
+    ASSERT(scriptExecutionContext());
+    ASSERT(m_transaction);
+    ASSERT(!m_pendingCursor);
+    ASSERT(&cursor == resultCursor());
+    ASSERT(!m_cursorRequestNotifier);
+
+    m_pendingCursor = &cursor;
+    m_hasPendingActivity = true;
+    m_result = nullptr;
+    m_readyState = IDBRequestReadyState::Pending;
+    m_domError = nullptr;
+    m_idbError = { };
+
+    m_cursorRequestNotifier = std::make_unique<ScopeGuard>([this]() {
+        m_pendingCursor->decrementOutstandingRequestCount();
+    });
+}
+
+void IDBRequest::didOpenOrIterateCursor(const IDBResultData& resultData)
+{
+    ASSERT(m_pendingCursor);
+    m_result = nullptr;
+
+    if (resultData.type() == IDBResultType::IterateCursorSuccess || resultData.type() == IDBResultType::OpenCursorSuccess) {
+        m_pendingCursor->setGetResult(*this, resultData.getResult());
+        if (resultData.getResult().isDefined())
+            m_result = IDBAny::create(*m_pendingCursor);
+    }
+
+    m_cursorRequestNotifier = nullptr;
+    m_pendingCursor = nullptr;
+
+    requestCompleted(resultData);
+}
+
+void IDBRequest::requestCompleted(const IDBResultData& resultData)
+{
+    m_readyState = IDBRequestReadyState::Done;
+
+    m_idbError = resultData.error();
+    if (!m_idbError.isNull())
+        onError();
+    else
+        onSuccess();
+}
+
+void IDBRequest::onError()
+{
+    LOG(IndexedDB, "IDBRequest::onError");
+
+    ASSERT(!m_idbError.isNull());
+    m_domError = DOMError::create(m_idbError.name());
+    enqueueEvent(Event::create(eventNames().errorEvent, true, true));
+}
+
+void IDBRequest::onSuccess()
+{
+    LOG(IndexedDB, "IDBRequest::onSuccess");
+
+    enqueueEvent(Event::create(eventNames().successEvent, false, false));
 }
 
 } // namespace WebCore
index 5afbf61..e19023b 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBRequest_h
-#define IDBRequest_h
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
 #include "ActiveDOMObject.h"
-#include "DOMError.h"
-#include "DOMStringList.h"
-#include "Event.h"
-#include "EventListener.h"
 #include "EventTarget.h"
 #include "IDBAny.h"
-#include "IDBCursor.h"
-#include "ScriptWrappable.h"
+#include "IDBResourceIdentifier.h"
+#include "IDBTransaction.h"
+#include "ScopeGuard.h"
+#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
-class IDBTransaction;
+class Event;
+class IDBAny;
+class IDBCursor;
+class IDBIndex;
+class IDBKeyData;
+class IDBObjectStore;
+class IDBResultData;
+class ThreadSafeDataBuffer;
 
-struct ExceptionCodeWithMessage;
+namespace IDBClient {
+class IDBConnectionToServer;
+}
 
-typedef int ExceptionCode;
+namespace IndexedDB {
+enum class IndexRecordType;
+}
 
 // Defined in the IDL
 enum class IDBRequestReadyState {
     Pending = 1,
     Done = 2,
-    DeprecatedEarlyDeath = 3, // FIXME: https://bugs.webkit.org/show_bug.cgi?id=149117 - Remove this when removing LegacyIDB
 };
 
-class IDBRequest : public EventTargetWithInlineData, public ActiveDOMObject {
+class IDBRequest : public EventTargetWithInlineData, public ActiveDOMObject, public RefCounted<IDBRequest> {
 public:
-    virtual ~IDBRequest() { }
+    static Ref<IDBRequest> create(ScriptExecutionContext&, IDBObjectStore&, IDBTransaction&);
+    static Ref<IDBRequest> create(ScriptExecutionContext&, IDBCursor&, IDBTransaction&);
+    static Ref<IDBRequest> createCount(ScriptExecutionContext&, IDBIndex&, IDBTransaction&);
+    static Ref<IDBRequest> createGet(ScriptExecutionContext&, IDBIndex&, IndexedDB::IndexRecordType, IDBTransaction&);
 
-    virtual RefPtr<IDBAny> result(ExceptionCodeWithMessage&) const = 0;
-    virtual unsigned short errorCode(ExceptionCode&) const = 0;
-    virtual RefPtr<DOMError> error(ExceptionCodeWithMessage&) const = 0;
-    virtual RefPtr<IDBAny> source() const = 0;
-    virtual RefPtr<IDBTransaction> transaction() const = 0;
+    const IDBResourceIdentifier& resourceIdentifier() const { return m_resourceIdentifier; }
 
-    virtual const String& readyState() const = 0;
+    virtual ~IDBRequest();
+
+    RefPtr<IDBAny> result(ExceptionCodeWithMessage&) const;
+    unsigned short errorCode(ExceptionCode&) const;
+    RefPtr<DOMError> error(ExceptionCodeWithMessage&) const;
+    RefPtr<IDBAny> source() const;
+    RefPtr<IDBTransaction> transaction() const;
+    const String& readyState() const;
+
+    uint64_t sourceObjectStoreIdentifier() const;
+    uint64_t sourceIndexIdentifier() const;
+    IndexedDB::IndexRecordType requestedIndexRecordType() const;
+
+    // EventTarget
+    EventTargetInterface eventTargetInterface() const override;
+    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
+
+    using RefCounted<IDBRequest>::ref;
+    using RefCounted<IDBRequest>::deref;
+
+    void enqueueEvent(Ref<Event>&&);
+    bool dispatchEvent(Event&) override;
+
+    IDBClient::IDBConnectionToServer& connection() { return m_connection; }
+
+    void requestCompleted(const IDBResultData&);
+
+    void setResult(const IDBKeyData*);
+    void setResult(uint64_t);
+    void setResultToStructuredClone(const ThreadSafeDataBuffer&);
+    void setResultToUndefined();
+
+    IDBAny* modernResult() { return m_result.get(); }
+
+    void willIterateCursor(IDBCursor&);
+    void didOpenOrIterateCursor(const IDBResultData&);
+
+    const IDBCursor* pendingCursor() const { return m_pendingCursor.get(); }
+
+    void setSource(IDBCursor&);
+    void setVersionChangeTransaction(IDBTransaction&);
+
+    IndexedDB::RequestType requestType() const { return m_requestType; }
+
+    // ActiveDOMObject.
+    const char* activeDOMObjectName() const final;
+    bool canSuspendForDocumentSuspension() const final;
+    bool hasPendingActivity() const final;
+    void stop() final;
 
 protected:
-    IDBRequest(ScriptExecutionContext&);
+    IDBRequest(IDBClient::IDBConnectionToServer&, ScriptExecutionContext&);
+    IDBRequest(ScriptExecutionContext&, IDBObjectStore&, IDBTransaction&);
+    IDBRequest(ScriptExecutionContext&, IDBCursor&, IDBTransaction&);
+    IDBRequest(ScriptExecutionContext&, IDBIndex&, IDBTransaction&);
+    IDBRequest(ScriptExecutionContext&, IDBIndex&, IndexedDB::IndexRecordType, IDBTransaction&);
+
+    // EventTarget.
+    void refEventTarget() final { RefCounted<IDBRequest>::ref(); }
+    void derefEventTarget() final { RefCounted<IDBRequest>::deref(); }
+    void uncaughtExceptionInEventHandler() final;
+
+    virtual bool isOpenDBRequest() const { return false; }
+
+    IDBRequestReadyState m_readyState { IDBRequestReadyState::Pending };
+    RefPtr<IDBAny> m_result;
+    RefPtr<IDBTransaction> m_transaction;
+    bool m_shouldExposeTransactionToDOM { true };
+    RefPtr<DOMError> m_domError;
+    IDBError m_idbError;
+    IndexedDB::RequestType m_requestType = { IndexedDB::RequestType::Other };
+    bool m_contextStopped { false };
+
+    Event* m_openDatabaseSuccessEvent { nullptr };
+
+private:
+    void onError();
+    void onSuccess();
+
+    IDBCursor* resultCursor();
+
+    IDBClient::IDBConnectionToServer& m_connection;
+    IDBResourceIdentifier m_resourceIdentifier;
+    RefPtr<IDBAny> m_source;
+    bool m_hasPendingActivity { true };
+    IndexedDB::IndexRecordType m_requestedIndexRecordType;
+
+    RefPtr<IDBCursor> m_pendingCursor;
+
+    std::unique_ptr<ScopeGuard> m_cursorRequestNotifier;
 };
 
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
-
-#endif // LegacyRequest_h
index 0bec6e3..100a41e 100644 (file)
@@ -30,7 +30,7 @@
 
 namespace WebCore {
 
-IDBRequestCompletionEvent::IDBRequestCompletionEvent(const AtomicString& type, bool canBubble, bool cancelable, IDBClient::IDBRequest& request)
+IDBRequestCompletionEvent::IDBRequestCompletionEvent(const AtomicString& type, bool canBubble, bool cancelable, IDBRequest& request)
     : Event(type, canBubble, cancelable)
     , m_request(request)
 {
index 0d40e24..7fa9943 100644 (file)
 #if ENABLE(INDEXED_DATABASE)
 
 #include "Event.h"
-#include "IDBRequestImpl.h"
+#include "IDBRequest.h"
 
 namespace WebCore {
 
 class IDBRequestCompletionEvent : public Event {
 public:
-    static Ref<Event> create(const AtomicString& type, bool canBubble, bool cancelable, IDBClient::IDBRequest& request)
+    static Ref<Event> create(const AtomicString& type, bool canBubble, bool cancelable, IDBRequest& request)
     {
         return adoptRef(*new IDBRequestCompletionEvent(type, canBubble, cancelable, request));
     }
 
 private:
-    IDBRequestCompletionEvent(const AtomicString& type, bool canBubble, bool cancelable, IDBClient::IDBRequest&);
+    IDBRequestCompletionEvent(const AtomicString& type, bool canBubble, bool cancelable, IDBRequest&);
 
-    Ref<IDBClient::IDBRequest> m_request;
+    Ref<IDBRequest> m_request;
 };
 
 
index 259fbf0..4ebd624 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "ExceptionCode.h"
+#include "DOMError.h"
+#include "Event.h"
+#include "EventQueue.h"
+#include "IDBCursorWithValue.h"
+#include "IDBDatabase.h"
+#include "IDBDatabaseException.h"
+#include "IDBError.h"
+#include "IDBEventDispatcher.h"
+#include "IDBKeyData.h"
+#include "IDBKeyRangeData.h"
+#include "IDBObjectStore.h"
+#include "IDBOpenDBRequest.h"
+#include "IDBRequest.h"
+#include "IDBResultData.h"
+#include "JSDOMWindowBase.h"
+#include "Logging.h"
+#include "ScriptExecutionContext.h"
+#include "TransactionOperation.h"
 #include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
-IDBTransaction::IDBTransaction(ScriptExecutionContext* context)
-    : ActiveDOMObject(context)
-{
-}
-
 const AtomicString& IDBTransaction::modeReadOnly()
 {
     static NeverDestroyed<AtomicString> readonly("readonly", AtomicString::ConstructFromLiteral);
@@ -97,6 +109,858 @@ const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode
     return IDBTransaction::modeReadOnly();
 }
 
+Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info)
+{
+    return adoptRef(*new IDBTransaction(database, info, nullptr));
+}
+
+Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info, IDBOpenDBRequest& request)
+{
+    return adoptRef(*new IDBTransaction(database, info, &request));
+}
+
+IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& info, IDBOpenDBRequest* request)
+    : WebCore::ActiveDOMObject(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();
+}
+
+IDBTransaction::~IDBTransaction()
+{
+}
+
+const String& IDBTransaction::mode() const
+{
+    switch (m_info.mode()) {
+    case IndexedDB::TransactionMode::ReadOnly:
+        return IDBTransaction::modeReadOnly();
+    case IndexedDB::TransactionMode::ReadWrite:
+        return IDBTransaction::modeReadWrite();
+    case IndexedDB::TransactionMode::VersionChange:
+        return IDBTransaction::modeVersionChange();
+    }
+
+    RELEASE_ASSERT_NOT_REACHED();
+}
+
+WebCore::IDBDatabase* IDBTransaction::db()
+{
+    return &m_database.get();
+}
+
+IDBClient::IDBConnectionToServer& IDBTransaction::serverConnection()
+{
+    return m_database->serverConnection();
+}
+
+RefPtr<DOMError> IDBTransaction::error() const
+{
+    return m_domError;
+}
+
+RefPtr<WebCore::IDBObjectStore> IDBTransaction::objectStore(const String& objectStoreName, ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBTransaction::objectStore");
+
+    if (!scriptExecutionContext())
+        return nullptr;
+
+    if (isFinishedOrFinishing()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'objectStore' on 'IDBTransaction': The transaction finished.");
+        return nullptr;
+    }
+
+    auto iterator = m_referencedObjectStores.find(objectStoreName);
+    if (iterator != m_referencedObjectStores.end())
+        return iterator->value;
+
+    bool found = false;
+    for (auto& objectStore : m_info.objectStores()) {
+        if (objectStore == objectStoreName) {
+            found = true;
+            break;
+        }
+    }
+
+    auto* info = m_database->info().infoForExistingObjectStore(objectStoreName);
+    if (!info) {
+        ec.code = IDBDatabaseException::NotFoundError;
+        ec.message = ASCIILiteral("Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.");
+        return nullptr;
+    }
+
+    // Version change transactions are scoped to every object store in the database.
+    if (!info || (!found && !isVersionChange())) {
+        ec.code = IDBDatabaseException::NotFoundError;
+        ec.message = ASCIILiteral("Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.");
+        return nullptr;
+    }
+
+    auto objectStore = IDBObjectStore::create(*scriptExecutionContext(), *info, *this);
+    m_referencedObjectStores.set(objectStoreName, &objectStore.get());
+
+    return adoptRef(&objectStore.leakRef());
+}
+
+
+void IDBTransaction::abortDueToFailedRequest(DOMError& error)
+{
+    LOG(IndexedDB, "IDBTransaction::abortDueToFailedRequest");
+    if (isFinishedOrFinishing())
+        return;
+
+    m_domError = &error;
+    ExceptionCodeWithMessage ec;
+    abort(ec);
+}
+
+void IDBTransaction::transitionedToFinishing(IndexedDB::TransactionState state)
+{
+    ASSERT(!isFinishedOrFinishing());
+    m_state = state;
+    ASSERT(isFinishedOrFinishing());
+    m_referencedObjectStores.clear();
+}
+
+void IDBTransaction::abort(ExceptionCodeWithMessage& ec)
+{
+    LOG(IndexedDB, "IDBTransaction::abort");
+
+    if (isFinishedOrFinishing()) {
+        ec.code = IDBDatabaseException::InvalidStateError;
+        ec.message = ASCIILiteral("Failed to execute 'abort' on 'IDBTransaction': The transaction is inactive or finished.");
+        return;
+    }
+
+    m_database->willAbortTransaction(*this);
+
+    if (isVersionChange()) {
+        for (auto& objectStore : m_referencedObjectStores.values())
+            objectStore->rollbackInfoForVersionChangeAbort();
+    }
+
+    transitionedToFinishing(IndexedDB::TransactionState::Aborting);
+    
+    m_abortQueue.swap(m_transactionOperationQueue);
+
+    auto operation = IDBClient::createTransactionOperation(*this, nullptr, &IDBTransaction::abortOnServerAndCancelRequests);
+    scheduleOperation(WTFMove(operation));
+}
+
+void IDBTransaction::abortOnServerAndCancelRequests(IDBClient::TransactionOperation& operation)
+{
+    LOG(IndexedDB, "IDBTransaction::abortOnServerAndCancelRequests");
+
+    ASSERT(m_transactionOperationQueue.isEmpty());
+
+    serverConnection().abortTransaction(*this);
+
+    ASSERT(m_transactionOperationMap.contains(operation.identifier()));
+    m_transactionOperationMap.remove(operation.identifier());
+
+    IDBError error(IDBDatabaseException::AbortError);
+    for (auto& operation : m_abortQueue)
+        operation->completed(IDBResultData::error(operation->identifier(), error));
+
+    // Since we're aborting, it should be impossible to have queued any further operations.
+    ASSERT(m_transactionOperationQueue.isEmpty());
+}
+
+const char* IDBTransaction::activeDOMObjectName() const
+{
+    return "IDBTransaction";
+}
+
+bool IDBTransaction::canSuspendForDocumentSuspension() const
+{
+    return false;
+}
+
+bool IDBTransaction::hasPendingActivity() const
+{
+    return !m_contextStopped && m_state != IndexedDB::TransactionState::Finished;
+}
+
+void IDBTransaction::stop()
+{
+    LOG(IndexedDB, "IDBTransaction::stop");
+
+    // IDBDatabase::stop() calls IDBTransaction::stop() for each of its active transactions.
+    // Since the order of calling ActiveDOMObject::stop() is random, we might already have been stopped.
+    if (m_contextStopped)
+        return;
+
+    m_contextStopped = true;
+
+    if (isFinishedOrFinishing())
+        return;
+
+    ExceptionCodeWithMessage ec;
+    abort(ec);
+}
+
+bool IDBTransaction::isActive() const
+{
+    return m_state == IndexedDB::TransactionState::Active;
+}
+
+bool IDBTransaction::isFinishedOrFinishing() const
+{
+    return m_state == IndexedDB::TransactionState::Committing
+        || m_state == IndexedDB::TransactionState::Aborting
+        || m_state == IndexedDB::TransactionState::Finished;
+}
+
+void IDBTransaction::addRequest(IDBRequest& request)
+{
+    m_openRequests.add(&request);
+}
+
+void IDBTransaction::removeRequest(IDBRequest& request)
+{
+    ASSERT(m_openRequests.contains(&request));
+    m_openRequests.remove(&request);
+}
+
+void IDBTransaction::scheduleOperation(RefPtr<IDBClient::TransactionOperation>&& operation)
+{
+    ASSERT(!m_transactionOperationMap.contains(operation->identifier()));
+
+    m_transactionOperationQueue.append(operation);
+    m_transactionOperationMap.set(operation->identifier(), WTFMove(operation));
+
+    scheduleOperationTimer();
+}
+
+void IDBTransaction::scheduleOperationTimer()
+{
+    if (!m_operationTimer.isActive())
+        m_operationTimer.startOneShot(0);
+}
+
+void IDBTransaction::operationTimerFired()
+{
+    LOG(IndexedDB, "IDBTransaction::operationTimerFired (%p)", this);
+
+    if (!m_startedOnServer)
+        return;
+
+    if (!m_transactionOperationQueue.isEmpty()) {
+        auto operation = m_transactionOperationQueue.takeFirst();
+        operation->perform();
+
+        return;
+    }
+
+    if (!m_transactionOperationMap.isEmpty() || !m_openRequests.isEmpty())
+        return;
+
+    if (!isFinishedOrFinishing())
+        commit();
+}
+
+void IDBTransaction::commit()
+{
+    LOG(IndexedDB, "IDBTransaction::commit");
+
+    ASSERT(!isFinishedOrFinishing());
+
+    transitionedToFinishing(IndexedDB::TransactionState::Committing);
+    m_database->willCommitTransaction(*this);
+
+    auto operation = IDBClient::createTransactionOperation(*this, nullptr, &IDBTransaction::commitOnServer);
+    scheduleOperation(WTFMove(operation));
+}
+
+void IDBTransaction::commitOnServer(IDBClient::TransactionOperation& operation)
+{
+    LOG(IndexedDB, "IDBTransaction::commitOnServer");
+    serverConnection().commitTransaction(*this);
+
+    ASSERT(m_transactionOperationMap.contains(operation.identifier()));
+    m_transactionOperationMap.remove(operation.identifier());
+}
+
+void IDBTransaction::finishAbortOrCommit()
+{
+    ASSERT(m_state != IndexedDB::TransactionState::Finished);
+    m_state = IndexedDB::TransactionState::Finished;
+}
+
+void IDBTransaction::didStart(const IDBError& error)
+{
+    LOG(IndexedDB, "IDBTransaction::didStart");
+
+    m_database->didStartTransaction(*this);
+
+    m_startedOnServer = true;
+
+    // It's possible the transaction failed to start on the server.
+    // That equates to an abort.
+    if (!error.isNull()) {
+        didAbort(error);
+        return;
+    }
+
+    scheduleOperationTimer();
+}
+
+void IDBTransaction::notifyDidAbort(const IDBError& error)
+{
+    m_database->didAbortTransaction(*this);
+    m_idbError = error;
+    fireOnAbort();
+
+    if (isVersionChange()) {
+        ASSERT(m_openDBRequest);
+        m_openDBRequest->fireErrorAfterVersionChangeCompletion();
+    }
+}
+
+void IDBTransaction::didAbort(const IDBError& error)
+{
+    LOG(IndexedDB, "IDBTransaction::didAbort");
+
+    if (m_state == IndexedDB::TransactionState::Finished)
+        return;
+
+    notifyDidAbort(error);
+
+    finishAbortOrCommit();
+}
+
+void IDBTransaction::didCommit(const IDBError& error)
+{
+    LOG(IndexedDB, "IDBTransaction::didCommit");
+
+    ASSERT(m_state == IndexedDB::TransactionState::Committing);
+
+    if (error.isNull()) {
+        m_database->didCommitTransaction(*this);
+        fireOnComplete();
+    } else {
+        m_database->willAbortTransaction(*this);
+        notifyDidAbort(error);
+    }
+
+    finishAbortOrCommit();
+}
+
+void IDBTransaction::fireOnComplete()
+{
+    LOG(IndexedDB, "IDBTransaction::fireOnComplete");
+    enqueueEvent(Event::create(eventNames().completeEvent, false, false));
+}
+
+void IDBTransaction::fireOnAbort()
+{
+    LOG(IndexedDB, "IDBTransaction::fireOnAbort");
+    enqueueEvent(Event::create(eventNames().abortEvent, true, false));
+}
+
+void IDBTransaction::enqueueEvent(Ref<Event>&& event)
+{
+    ASSERT(m_state != IndexedDB::TransactionState::Finished);
+
+    if (!scriptExecutionContext() || m_contextStopped)
+        return;
+
+    event->setTarget(this);
+    scriptExecutionContext()->eventQueue().enqueueEvent(WTFMove(event));
+}
+
+bool IDBTransaction::dispatchEvent(Event& event)
+{
+    LOG(IndexedDB, "IDBTransaction::dispatchEvent");
+
+    ASSERT(scriptExecutionContext());
+    ASSERT(!m_contextStopped);
+    ASSERT(event.target() == this);
+    ASSERT(event.type() == eventNames().completeEvent || event.type() == eventNames().abortEvent);
+
+    Vector<RefPtr<EventTarget>> targets;
+    targets.append(this);
+    targets.append(db());
+
+    bool result = IDBEventDispatcher::dispatch(event, targets);
+
+    if (isVersionChange()) {
+        ASSERT(m_openDBRequest);
+        m_openDBRequest->versionChangeTransactionDidFinish();
+
+        if (event.type() == eventNames().completeEvent) {
+            if (m_database->isClosingOrClosed())
+                m_openDBRequest->fireErrorAfterVersionChangeCompletion();
+            else
+                m_openDBRequest->fireSuccessAfterVersionChangeCommit();
+        }
+
+        m_openDBRequest = nullptr;
+    }
+
+    return result;
+}
+
+Ref<IDBObjectStore> IDBTransaction::createObjectStore(const IDBObjectStoreInfo& info)
+{
+    LOG(IndexedDB, "IDBTransaction::createObjectStore");
+    ASSERT(isVersionChange());
+    ASSERT(scriptExecutionContext());
+
+    Ref<IDBObjectStore> objectStore = IDBObjectStore::create(*scriptExecutionContext(), info, *this);
+    m_referencedObjectStores.set(info.name(), &objectStore.get());
+
+    auto operation = IDBClient::createTransactionOperation(*this, &IDBTransaction::didCreateObjectStoreOnServer, &IDBTransaction::createObjectStoreOnServer, info);
+    scheduleOperation(WTFMove(operation));
+
+    return objectStore;
+}
+
+void IDBTransaction::createObjectStoreOnServer(IDBClient::TransactionOperation& operation, const IDBObjectStoreInfo& info)
+{
+    LOG(IndexedDB, "IDBTransaction::createObjectStoreOnServer");
+
+    ASSERT(isVersionChange());
+
+    m_database->serverConnection().createObjectStore(operation, info);
+}
+
+void IDBTransaction::didCreateObjectStoreOnServer(const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didCreateObjectStoreOnServer");
+
+    ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::CreateObjectStoreSuccess || resultData.type() == IDBResultType::Error);
+}
+
+std::unique_ptr<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStore, const IDBIndexInfo& info)
+{
+    LOG(IndexedDB, "IDBTransaction::createIndex");
+    ASSERT(isVersionChange());
+
+    if (!scriptExecutionContext())
+        return nullptr;
+
+    auto operation = IDBClient::createTransactionOperation(*this, &IDBTransaction::didCreateIndexOnServer, &IDBTransaction::createIndexOnServer, info);
+    scheduleOperation(WTFMove(operation));
+
+    return std::make_unique<IDBIndex>(*scriptExecutionContext(), info, objectStore);
+}
+
+void IDBTransaction::createIndexOnServer(IDBClient::TransactionOperation& operation, const IDBIndexInfo& info)
+{
+    LOG(IndexedDB, "IDBTransaction::createIndexOnServer");
+
+    ASSERT(isVersionChange());
+
+    m_database->serverConnection().createIndex(operation, info);
+}
+
+void IDBTransaction::didCreateIndexOnServer(const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didCreateIndexOnServer");
+
+    if (resultData.type() == IDBResultType::CreateIndexSuccess)
+        return;
+
+    ASSERT(resultData.type() == IDBResultType::Error);
+
+    // This operation might have failed because the transaction is already aborting.
+    if (m_state == IndexedDB::TransactionState::Aborting)
+        return;
+
+    // Otherwise, failure to create an index forced abortion of the transaction.
+    abortDueToFailedRequest(DOMError::create(IDBDatabaseException::getErrorName(resultData.error().code())));
+}
+
+Ref<IDBRequest> IDBTransaction::requestOpenCursor(ScriptExecutionContext& context, IDBObjectStore& objectStore, const IDBCursorInfo& info)
+{
+    LOG(IndexedDB, "IDBTransaction::requestOpenCursor");
+
+    return doRequestOpenCursor(context, IDBCursorWithValue::create(*this, objectStore, info));
+}
+
+Ref<IDBRequest> IDBTransaction::requestOpenCursor(ScriptExecutionContext& context, IDBIndex& index, const IDBCursorInfo& info)
+{
+    LOG(IndexedDB, "IDBTransaction::requestOpenCursor");
+
+    if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
+        return doRequestOpenCursor(context, IDBCursor::create(*this, index, info));
+
+    return doRequestOpenCursor(context, IDBCursorWithValue::create(*this, index, info));
+}
+
+Ref<IDBRequest> IDBTransaction::doRequestOpenCursor(ScriptExecutionContext& context, Ref<IDBCursor>&& cursor)
+{
+    ASSERT(isActive());
+
+    Ref<IDBRequest> request = IDBRequest::create(context, cursor.get(), *this);
+    addRequest(request.get());
+
+    auto operation = IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didOpenCursorOnServer, &IDBTransaction::openCursorOnServer, cursor->info());
+    scheduleOperation(WTFMove(operation));
+
+    return request;
+}
+
+void IDBTransaction::openCursorOnServer(IDBClient::TransactionOperation& operation, const IDBCursorInfo& info)
+{
+    LOG(IndexedDB, "IDBTransaction::openCursorOnServer");
+
+    m_database->serverConnection().openCursor(operation, info);
+}
+
+void IDBTransaction::didOpenCursorOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didOpenCursorOnServer");
+
+    request.didOpenOrIterateCursor(resultData);
+}
+
+void IDBTransaction::iterateCursor(IDBCursor& cursor, const IDBKeyData& key, unsigned long count)
+{
+    LOG(IndexedDB, "IDBTransaction::iterateCursor");
+    ASSERT(isActive());
+    ASSERT(cursor.request());
+
+    addRequest(*cursor.request());
+
+    auto operation = IDBClient::createTransactionOperation(*this, *cursor.request(), &IDBTransaction::didIterateCursorOnServer, &IDBTransaction::iterateCursorOnServer, key, count);
+    scheduleOperation(WTFMove(operation));
+}
+
+void IDBTransaction::iterateCursorOnServer(IDBClient::TransactionOperation& operation, const IDBKeyData& key, const unsigned long& count)
+{
+    LOG(IndexedDB, "IDBTransaction::iterateCursorOnServer");
+
+    serverConnection().iterateCursor(operation, key, count);
+}
+
+void IDBTransaction::didIterateCursorOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didIterateCursorOnServer");
+
+    request.didOpenOrIterateCursor(resultData);
+}
+
+Ref<IDBRequest> IDBTransaction::requestGetRecord(ScriptExecutionContext& context, IDBObjectStore& objectStore, const IDBKeyRangeData& keyRangeData)
+{
+    LOG(IndexedDB, "IDBTransaction::requestGetRecord");
+    ASSERT(isActive());
+    ASSERT(!keyRangeData.isNull);
+
+    Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+    addRequest(request.get());
+
+    auto operation = IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetRecordOnServer, &IDBTransaction::getRecordOnServer, keyRangeData);
+    scheduleOperation(WTFMove(operation));
+
+    return request;
+}
+
+Ref<IDBRequest> IDBTransaction::requestGetValue(ScriptExecutionContext& context, IDBIndex& index, const IDBKeyRangeData& range)
+{
+    LOG(IndexedDB, "IDBTransaction::requestGetValue");
+    return requestIndexRecord(context, index, IndexedDB::IndexRecordType::Value, range);
+}
+
+Ref<IDBRequest> IDBTransaction::requestGetKey(ScriptExecutionContext& context, IDBIndex& index, const IDBKeyRangeData& range)
+{
+    LOG(IndexedDB, "IDBTransaction::requestGetValue");
+    return requestIndexRecord(context, index, IndexedDB::IndexRecordType::Key, range);
+}
+
+Ref<IDBRequest> IDBTransaction::requestIndexRecord(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType type, const IDBKeyRangeData&range)
+{
+    LOG(IndexedDB, "IDBTransaction::requestGetValue");
+    ASSERT(isActive());
+    ASSERT(!range.isNull);
+
+    Ref<IDBRequest> request = IDBRequest::createGet(context, index, type, *this);
+    addRequest(request.get());
+
+    auto operation = IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetRecordOnServer, &IDBTransaction::getRecordOnServer, range);
+    scheduleOperation(WTFMove(operation));
+
+    return request;
+}
+
+void IDBTransaction::getRecordOnServer(IDBClient::TransactionOperation& operation, const IDBKeyRangeData& keyRange)
+{
+    LOG(IndexedDB, "IDBTransaction::getRecordOnServer");
+
+    serverConnection().getRecord(operation, keyRange);
+}
+
+void IDBTransaction::didGetRecordOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didGetRecordOnServer");
+
+    if (resultData.type() == IDBResultType::Error) {
+        request.requestCompleted(resultData);
+        return;
+    }
+
+    ASSERT(resultData.type() == IDBResultType::GetRecordSuccess);
+
+    const IDBGetResult& result = resultData.getResult();
+
+    if (request.sourceIndexIdentifier() && request.requestedIndexRecordType() == IndexedDB::IndexRecordType::Key) {
+        if (!result.keyData().isNull())
+            request.setResult(&result.keyData());
+        else
+            request.setResultToUndefined();
+    } else {
+        if (resultData.getResult().valueBuffer().data())
+            request.setResultToStructuredClone(resultData.getResult().valueBuffer());
+        else
+            request.setResultToUndefined();
+    }
+
+    request.requestCompleted(resultData);
+}
+
+Ref<IDBRequest> IDBTransaction::requestCount(ScriptExecutionContext& context, IDBObjectStore& objectStore, const IDBKeyRangeData& range)
+{
+    LOG(IndexedDB, "IDBTransaction::requestCount (IDBObjectStore)");
+    ASSERT(isActive());
+    ASSERT(!range.isNull);
+
+    Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+    addRequest(request.get());
+
+    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetCountOnServer, &IDBTransaction::getCountOnServer, range));
+
+    return request;
+}
+
+Ref<IDBRequest> IDBTransaction::requestCount(ScriptExecutionContext& context, IDBIndex& index, const IDBKeyRangeData& range)
+{
+    LOG(IndexedDB, "IDBTransaction::requestCount (IDBIndex)");
+    ASSERT(isActive());
+    ASSERT(!range.isNull);
+
+    Ref<IDBRequest> request = IDBRequest::createCount(context, index, *this);
+    addRequest(request.get());
+
+    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetCountOnServer, &IDBTransaction::getCountOnServer, range));
+
+    return request;
+}
+
+void IDBTransaction::getCountOnServer(IDBClient::TransactionOperation& operation, const IDBKeyRangeData& keyRange)
+{
+    LOG(IndexedDB, "IDBTransaction::getCountOnServer");
+
+    serverConnection().getCount(operation, keyRange);
+}
+
+void IDBTransaction::didGetCountOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didGetCountOnServer");
+
+    request.setResult(resultData.resultInteger());
+    request.requestCompleted(resultData);
+}
+
+Ref<IDBRequest> IDBTransaction::requestDeleteRecord(ScriptExecutionContext& context, IDBObjectStore& objectStore, const IDBKeyRangeData& range)
+{
+    LOG(IndexedDB, "IDBTransaction::requestDeleteRecord");
+    ASSERT(isActive());
+    ASSERT(!range.isNull);
+
+    Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+    addRequest(request.get());
+
+    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didDeleteRecordOnServer, &IDBTransaction::deleteRecordOnServer, range));
+    return request;
+}
+
+void IDBTransaction::deleteRecordOnServer(IDBClient::TransactionOperation& operation, const IDBKeyRangeData& keyRange)
+{
+    LOG(IndexedDB, "IDBTransaction::deleteRecordOnServer");
+
+    serverConnection().deleteRecord(operation, keyRange);
+}
+
+void IDBTransaction::didDeleteRecordOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didDeleteRecordOnServer");
+
+    request.setResultToUndefined();
+    request.requestCompleted(resultData);
+}
+
+Ref<IDBRequest> IDBTransaction::requestClearObjectStore(ScriptExecutionContext& context, IDBObjectStore& objectStore)
+{
+    LOG(IndexedDB, "IDBTransaction::requestClearObjectStore");
+    ASSERT(isActive());
+
+    Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+    addRequest(request.get());
+
+    uint64_t objectStoreIdentifier = objectStore.info().identifier();
+    auto operation = IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didClearObjectStoreOnServer, &IDBTransaction::clearObjectStoreOnServer, objectStoreIdentifier);
+    scheduleOperation(WTFMove(operation));
+
+    return request;
+}
+
+void IDBTransaction::clearObjectStoreOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier)
+{
+    LOG(IndexedDB, "IDBTransaction::clearObjectStoreOnServer");
+
+    serverConnection().clearObjectStore(operation, objectStoreIdentifier);
+}
+
+void IDBTransaction::didClearObjectStoreOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didClearObjectStoreOnServer");
+
+    request.setResultToUndefined();
+    request.requestCompleted(resultData);
+}
+
+Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBKey* key, SerializedScriptValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
+{
+    LOG(IndexedDB, "IDBTransaction::requestPutOrAdd");
+    ASSERT(isActive());
+    ASSERT(!isReadOnly());
+    ASSERT(objectStore.info().autoIncrement() || key);
+
+    Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+    addRequest(request.get());
+
+    auto operation = IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didPutOrAddOnServer, &IDBTransaction::putOrAddOnServer, key, &value, overwriteMode);
+    scheduleOperation(WTFMove(operation));
+
+    return request;
+}
+
+void IDBTransaction::putOrAddOnServer(IDBClient::TransactionOperation& operation, RefPtr<IDBKey> key, RefPtr<SerializedScriptValue> value, const IndexedDB::ObjectStoreOverwriteMode& overwriteMode)
+{
+    LOG(IndexedDB, "IDBTransaction::putOrAddOnServer");
+
+    ASSERT(!isReadOnly());
+
+    serverConnection().putOrAdd(operation, key, value, overwriteMode);
+}
+
+void IDBTransaction::didPutOrAddOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didPutOrAddOnServer");
+
+    request.setResult(resultData.resultKey());
+    request.requestCompleted(resultData);
+}
+
+void IDBTransaction::deleteObjectStore(const String& objectStoreName)
+{
+    LOG(IndexedDB, "IDBTransaction::deleteObjectStore");
+
+    ASSERT(isVersionChange());
+
+    if (auto objectStore = m_referencedObjectStores.take(objectStoreName))
+        objectStore->markAsDeleted();
+
+    auto operation = IDBClient::createTransactionOperation(*this, &IDBTransaction::didDeleteObjectStoreOnServer, &IDBTransaction::deleteObjectStoreOnServer, objectStoreName);
+    scheduleOperation(WTFMove(operation));
+}
+
+void IDBTransaction::deleteObjectStoreOnServer(IDBClient::TransactionOperation& operation, const String& objectStoreName)
+{
+    LOG(IndexedDB, "IDBTransaction::deleteObjectStoreOnServer");
+    ASSERT(isVersionChange());
+
+    serverConnection().deleteObjectStore(operation, objectStoreName);
+}
+
+void IDBTransaction::didDeleteObjectStoreOnServer(const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didDeleteObjectStoreOnServer");
+    ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteObjectStoreSuccess || resultData.type() == IDBResultType::Error);
+}
+
+void IDBTransaction::deleteIndex(uint64_t objectStoreIdentifier, const String& indexName)
+{
+    LOG(IndexedDB, "IDBTransaction::deleteIndex");
+
+    ASSERT(isVersionChange());
+
+    auto operation = IDBClient::createTransactionOperation(*this, &IDBTransaction::didDeleteIndexOnServer, &IDBTransaction::deleteIndexOnServer, objectStoreIdentifier, indexName);
+    scheduleOperation(WTFMove(operation));
+}
+
+void IDBTransaction::deleteIndexOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const String& indexName)
+{
+    LOG(IndexedDB, "IDBTransaction::deleteIndexOnServer");
+    ASSERT(isVersionChange());
+
+    serverConnection().deleteIndex(operation, objectStoreIdentifier, indexName);
+}
+
+void IDBTransaction::didDeleteIndexOnServer(const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didDeleteIndexOnServer");
+    ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteIndexSuccess || resultData.type() == IDBResultType::Error);
+}
+
+void IDBTransaction::operationDidComplete(IDBClient::TransactionOperation& operation)
+{
+    ASSERT(m_transactionOperationMap.get(operation.identifier()) == &operation);
+    m_transactionOperationMap.remove(operation.identifier());
+
+    scheduleOperationTimer();
+}
+
+void IDBTransaction::establishOnServer()
+{
+    LOG(IndexedDB, "IDBTransaction::establishOnServer");
+
+    serverConnection().establishTransaction(*this);
+}
+
+void IDBTransaction::activate()
+{
+    if (isFinishedOrFinishing())
+        return;
+
+    m_state = IndexedDB::TransactionState::Active;
+}
+
+void IDBTransaction::deactivate()
+{
+    if (m_state == IndexedDB::TransactionState::Active)
+        m_state = IndexedDB::TransactionState::Inactive;
+
+    scheduleOperationTimer();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
index 9e9a0e8..e223103 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBTransaction_h
-#define IDBTransaction_h
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "ActiveDOMObject.h"
-#include "EventTarget.h"
+#include "IDBDatabaseInfo.h"
+#include "IDBError.h"
+#include "IDBIndex.h"
+#include "IDBObjectStore.h"
+#include "IDBTransaction.h"
+#include "IDBTransactionInfo.h"
 #include "IndexedDB.h"
-#include "ScriptWrappable.h"
-#include <wtf/HashSet.h>
-#include <wtf/RefCounted.h>
+#include "Timer.h"
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
 
 namespace WebCore {
 
-class DOMError;
 class IDBCursor;
+class IDBCursorInfo;
 class IDBDatabase;
-class IDBDatabaseError;
+class IDBIndex;
+class IDBIndexInfo;
+class IDBKeyData;
 class IDBObjectStore;
+class IDBObjectStoreInfo;
 class IDBOpenDBRequest;
+class IDBResultData;
+struct IDBKeyRangeData;
 
-struct ExceptionCodeWithMessage;
+namespace IDBClient {
+class TransactionOperation;
+}
 
 class IDBTransaction : public RefCounted<IDBTransaction>, public EventTargetWithInlineData, public ActiveDOMObject {
 public:
-    virtual ~IDBTransaction() { }
-
     static const AtomicString& modeReadOnly();
     static const AtomicString& modeReadWrite();
     static const AtomicString& modeVersionChange();
@@ -59,22 +67,184 @@ public:
     static IndexedDB::TransactionMode stringToMode(const String&, ExceptionCode&);
     static const AtomicString& modeToString(IndexedDB::TransactionMode);
 
-    // Implement the IDBTransaction IDL
-    virtual const String& mode() const = 0;
-    virtual IDBDatabase* db() = 0;
-    virtual RefPtr<DOMError> error() const = 0;
-    virtual RefPtr<IDBObjectStore> objectStore(const String& name, ExceptionCodeWithMessage&) = 0;
-    virtual void abort(ExceptionCodeWithMessage&) = 0;
+    static Ref<IDBTransaction> create(IDBDatabase&, const IDBTransactionInfo&);
+    static Ref<IDBTransaction> create(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest&);
+
+    ~IDBTransaction() final;
+
+    // IDBTransaction IDL
+    const String& mode() const;
+    WebCore::IDBDatabase* db();
+    RefPtr<DOMError> error() const;
+    RefPtr<WebCore::IDBObjectStore> objectStore(const String& name, ExceptionCodeWithMessage&);
+    void abort(ExceptionCodeWithMessage&);
+
+    EventTargetInterface eventTargetInterface() const final { return IDBTransactionEventTargetInterfaceType; }
+    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
+    void refEventTarget() final { RefCounted<IDBTransaction>::ref(); }
+    void derefEventTarget() final { RefCounted<IDBTransaction>::deref(); }
+    using EventTarget::dispatchEvent;
+    bool dispatchEvent(Event&) final;
 
     using RefCounted<IDBTransaction>::ref;
     using RefCounted<IDBTransaction>::deref;
 
-protected:
-    IDBTransaction(ScriptExecutionContext*);
+    const char* activeDOMObjectName() const final;
+    bool canSuspendForDocumentSuspension() const final;
+    bool hasPendingActivity() const final;
+    void stop() final;
+
+    const IDBTransactionInfo& info() const { return m_info; }
+    IDBDatabase& database() { return m_database.get(); }
+    const IDBDatabase& database() const { return m_database.get(); }
+    IDBDatabaseInfo* originalDatabaseInfo() const { return m_info.originalDatabaseInfo(); }
+
+    void didStart(const IDBError&);
+    void didAbort(const IDBError&);
+    void didCommit(const IDBError&);
+
+    bool isVersionChange() const { return m_info.mode() == IndexedDB::TransactionMode::VersionChange; }
+    bool isReadOnly() const { return m_info.mode() == IndexedDB::TransactionMode::ReadOnly; }
+    bool isActive() const;
+
+    Ref<IDBObjectStore> createObjectStore(const IDBObjectStoreInfo&);
+    std::unique_ptr<IDBIndex> createIndex(IDBObjectStore&, const IDBIndexInfo&);
+
+    Ref<IDBRequest> requestPutOrAdd(ScriptExecutionContext&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
+    Ref<IDBRequest> requestGetRecord(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
+    Ref<IDBRequest> requestDeleteRecord(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
+    Ref<IDBRequest> requestClearObjectStore(ScriptExecutionContext&, IDBObjectStore&);
+    Ref<IDBRequest> requestCount(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
+    Ref<IDBRequest> requestCount(ScriptExecutionContext&, IDBIndex&, const IDBKeyRangeData&);
+    Ref<IDBRequest> requestGetValue(ScriptExecutionContext&, IDBIndex&, const IDBKeyRangeData&);
+    Ref<IDBRequest> requestGetKey(ScriptExecutionContext&, IDBIndex&, const IDBKeyRangeData&);
+    Ref<IDBRequest> requestOpenCursor(ScriptExecutionContext&, IDBObjectStore&, const IDBCursorInfo&);
+    Ref<IDBRequest> requestOpenCursor(ScriptExecutionContext&, IDBIndex&, const IDBCursorInfo&);
+    void iterateCursor(IDBCursor&, const IDBKeyData&, unsigned long count);
+
+    void deleteObjectStore(const String& objectStoreName);
+    void deleteIndex(uint64_t objectStoreIdentifier, const String& indexName);
+
+    void addRequest(IDBRequest&);
+    void removeRequest(IDBRequest&);
+
+    void abortDueToFailedRequest(DOMError&);
+
+    IDBClient::IDBConnectionToServer& serverConnection();
+
+    void activate();
+    void deactivate();
+
+    void operationDidComplete(IDBClient::TransactionOperation&);
+
+    bool isFinishedOrFinishing() const;
+    bool isFinished() const { return m_state == IndexedDB::TransactionState::Finished; }
+
+private:
+    IDBTransaction(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest*);
+
+    void commit();
+
+    void notifyDidAbort(const IDBError&);
+    void finishAbortOrCommit();
+
+    void scheduleOperation(RefPtr<IDBClient::TransactionOperation>&&);
+    void operationTimerFired();
+
+    void fireOnComplete();
+    void fireOnAbort();
+    void enqueueEvent(Ref<Event>&&);
+
+    Ref<IDBRequest> requestIndexRecord(ScriptExecutionContext&, IDBIndex&, IndexedDB::IndexRecordType, const IDBKeyRangeData&);
+
+    void commitOnServer(IDBClient::TransactionOperation&);
+    void abortOnServerAndCancelRequests(IDBClient::TransactionOperation&);
+
+    void createObjectStoreOnServer(IDBClient::TransactionOperation&, const IDBObjectStoreInfo&);
+    void didCreateObjectStoreOnServer(const IDBResultData&);
+
+    void createIndexOnServer(IDBClient::TransactionOperation&, const IDBIndexInfo&);
+    void didCreateIndexOnServer(const IDBResultData&);
+
+    void clearObjectStoreOnServer(IDBClient::TransactionOperation&, const uint64_t& objectStoreIdentifier);
+    void didClearObjectStoreOnServer(IDBRequest&, const IDBResultData&);
+
+    void putOrAddOnServer(IDBClient::TransactionOperation&, RefPtr<IDBKey>, RefPtr<SerializedScriptValue>, const IndexedDB::ObjectStoreOverwriteMode&);
+    void didPutOrAddOnServer(IDBRequest&, const IDBResultData&);
+
+    void getRecordOnServer(IDBClient::TransactionOperation&, const IDBKeyRangeData&);
+    void didGetRecordOnServer(IDBRequest&, const IDBResultData&);
+
+    void getCountOnServer(IDBClient::TransactionOperation&, const IDBKeyRangeData&);
+    void didGetCountOnServer(IDBRequest&, const IDBResultData&);
+
+    void deleteRecordOnServer(IDBClient::TransactionOperation&, const IDBKeyRangeData&);
+    void didDeleteRecordOnServer(IDBRequest&, const IDBResultData&);
+
+    void deleteObjectStoreOnServer(IDBClient::TransactionOperation&, const String& objectStoreName);
+    void didDeleteObjectStoreOnServer(const IDBResultData&);
+
+    void deleteIndexOnServer(IDBClient::TransactionOperation&, const uint64_t& objectStoreIdentifier, const String& indexName);
+    void didDeleteIndexOnServer(const IDBResultData&);
+
+    Ref<IDBRequest> doRequestOpenCursor(ScriptExecutionContext&, Ref<IDBCursor>&&);
+    void openCursorOnServer(IDBClient::TransactionOperation&, const IDBCursorInfo&);
+    void didOpenCursorOnServer(IDBRequest&, const IDBResultData&);
+
+    void iterateCursorOnServer(IDBClient::TransactionOperation&, const IDBKeyData&, const unsigned long& count);
+    void didIterateCursorOnServer(IDBRequest&, const IDBResultData&);
+
+    void transitionedToFinishing(IndexedDB::TransactionState);
+
+    void establishOnServer();
+
+    void scheduleOperationTimer();
+
+    Ref<IDBDatabase> m_database;
+    IDBTransactionInfo m_info;
+
+    IndexedDB::TransactionState m_state { IndexedDB::TransactionState::Inactive };
+    bool m_startedOnServer { false };
+
+    IDBError m_idbError;
+    RefPtr<DOMError> m_domError;
+
+    Timer m_operationTimer;
+    std::unique_ptr<Timer> m_activationTimer;
+
+    RefPtr<IDBOpenDBRequest> m_openDBRequest;
+
+    Deque<RefPtr<IDBClient::TransactionOperation>> m_transactionOperationQueue;
+    Deque<RefPtr<IDBClient::TransactionOperation>> m_abortQueue;
+    HashMap<IDBResourceIdentifier, RefPtr<IDBClient::TransactionOperation>> m_transactionOperationMap;
+
+    HashMap<String, RefPtr<IDBObjectStore>> m_referencedObjectStores;
+
+    HashSet<RefPtr<IDBRequest>> m_openRequests;
+
+    bool m_contextStopped { false };
+};
+
+class TransactionActivator {
+    WTF_MAKE_NONCOPYABLE(TransactionActivator);
+public:
+    TransactionActivator(IDBTransaction* transaction)
+        : m_transaction(transaction)
+    {
+        if (m_transaction)
+            m_transaction->activate();
+    }
+
+    ~TransactionActivator()
+    {
+        if (m_transaction)
+            m_transaction->deactivate();
+    }
+
+private:
+    IDBTransaction* m_transaction;
 };
 
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
-
-#endif // IDBTransaction_h
index fe6b56e..33f0879 100644 (file)
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "EventNames.h"
-#include "IDBVersionChangeEventImpl.h"
-
 namespace WebCore {
 
-IDBVersionChangeEvent::IDBVersionChangeEvent(const AtomicString& name)
+IDBVersionChangeEvent::IDBVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion, const AtomicString& name)
     : Event(name, false /*canBubble*/, false /*cancelable*/)
+    , m_requestIdentifier(requestIdentifier)
+    , m_oldVersion(oldVersion)
+    , m_newVersion(newVersion)
+{
+}
+
+Optional<uint64_t> IDBVersionChangeEvent::newVersion() const
 {
+    if (!m_newVersion)
+        return Nullopt;
+    return m_newVersion;
 }
 
-Ref<IDBVersionChangeEvent> IDBVersionChangeEvent::create()
+EventInterface IDBVersionChangeEvent::eventInterface() const
 {
-    // FIXME: This is called only by document.createEvent. I don't see how it's valuable to create an event with
-    // read-only oldVersion attribute of 0 and newVersion of null; preserving that behavior for now.
-    return IDBClient::IDBVersionChangeEvent::create(0, 0, eventNames().versionchangeEvent);
+    return IDBVersionChangeEventInterfaceType;
 }
 
 } // namespace WebCore
index 5d1493c..63c572f 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IDBVersionChangeEvent_h
-#define IDBVersionChangeEvent_h
+#pragma once
 
 #if ENABLE(INDEXED_DATABASE)
 
 #include "Event.h"
+#include "IDBResourceIdentifier.h"
 #include <wtf/Optional.h>
 
 namespace WebCore {
 
-class IDBVersionChangeEvent : public Event {
+class IDBVersionChangeEvent final : public Event {
 public:
-    static Ref<IDBVersionChangeEvent> create();
+    static Ref<IDBVersionChangeEvent> create(uint64_t oldVersion, uint64_t newVersion, const AtomicString& eventType)
+    {
+        return adoptRef(*new IDBVersionChangeEvent(IDBResourceIdentifier::emptyValue(), oldVersion, newVersion, eventType));
+    }
 
-    virtual uint64_t oldVersion() const = 0;
-    virtual Optional<uint64_t> newVersion() const = 0;
+    static Ref<IDBVersionChangeEvent> create(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion, const AtomicString& eventType)
+    {
+        return adoptRef(*new IDBVersionChangeEvent(requestIdentifier, oldVersion, newVersion, eventType));
+    }
 
-protected:
-    explicit IDBVersionChangeEvent(const AtomicString& type);
+    const IDBResourceIdentifier& requestIdentifier() const { return m_requestIdentifier; }
+
+    bool isVersionChangeEvent() const final { return true; }
+
+    uint64_t oldVersion() const { return m_oldVersion; }
+    Optional<uint64_t> newVersion() const;
+
+private:
+    IDBVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion, const AtomicString& eventType);
+
+    EventInterface eventInterface() const;
+
+    IDBResourceIdentifier m_requestIdentifier;
+    uint64_t m_oldVersion;
+    uint64_t m_newVersion;
 };
 
 } // namespace WebCore
 
-#endif // ENABLE(INDEXED_DATABASE)
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::IDBVersionChangeEvent)
+    static bool isType(const WebCore::Event& event) { return event.isVersionChangeEvent(); }
+SPECIALIZE_TYPE_TRAITS_END()
 
-#endif // IDBVersionChangeEvent_h
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.cpp
deleted file mode 100644 (file)
index 86de014..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBAnyImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBAny.h"
-#include "IDBCursorImpl.h"
-#include "IDBFactory.h"
-#include "IDBIndex.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-IDBAny::IDBAny(IDBAny::Type type)
-    : m_type(type)
-{
-}
-
-IDBAny::IDBAny(Ref<IDBDatabase>&& database)
-    : m_type(IDBAny::Type::IDBDatabase)
-    , m_database(adoptRef(&database.leakRef()))
-{
-}
-
-IDBAny::IDBAny(Ref<IDBObjectStore>&& objectStore)
-    : m_type(IDBAny::Type::IDBObjectStore)
-    , m_objectStore(WTFMove(objectStore))
-{
-}
-
-IDBAny::IDBAny(Ref<IDBIndex>&& index)
-    : m_type(IDBAny::Type::IDBIndex)
-    , m_index(WTFMove(index))
-{
-}
-
-IDBAny::IDBAny(Ref<IDBCursor>&& cursor)
-{
-    if (cursor->isKeyCursor()) {
-        m_type = IDBAny::Type::IDBCursor;
-        m_cursor = WTFMove(cursor);
-    } else {
-        m_type = IDBAny::Type::IDBCursorWithValue;
-        m_cursorWithValue = WTFMove(cursor);
-    }
-}
-
-IDBAny::IDBAny(const IDBKeyPath& keyPath)
-    : m_type(IDBAny::Type::KeyPath)
-    , m_idbKeyPath(keyPath)
-{
-}
-
-IDBAny::IDBAny(const Deprecated::ScriptValue& value)
-    : m_type(IDBAny::Type::ScriptValue)
-    , m_scriptValue(value)
-{
-}
-
-IDBAny::~IDBAny()
-{
-}
-
-RefPtr<WebCore::IDBDatabase> IDBAny::idbDatabase()
-{
-    ASSERT(m_type == IDBAny::Type::IDBDatabase);
-    return m_database.get();
-}
-
-RefPtr<WebCore::DOMStringList> IDBAny::domStringList()
-{
-    return nullptr;
-}
-
-RefPtr<WebCore::IDBCursor> IDBAny::idbCursor()
-{
-    ASSERT(m_type == IDBAny::Type::IDBCursor || m_type == IDBAny::Type::IDBCursorWithValue);
-    return m_cursor.get();
-}
-
-RefPtr<WebCore::IDBCursorWithValue> IDBAny::idbCursorWithValue()
-{
-    ASSERT(m_type == IDBAny::Type::IDBCursorWithValue);
-    return m_cursorWithValue.get();
-}
-
-RefPtr<WebCore::IDBFactory> IDBAny::idbFactory()
-{
-    return nullptr;
-}
-
-RefPtr<WebCore::IDBIndex> IDBAny::idbIndex()
-{
-    ASSERT(m_type == IDBAny::Type::IDBIndex);
-    return m_index.get();
-}
-
-RefPtr<WebCore::IDBObjectStore> IDBAny::idbObjectStore()
-{
-    ASSERT(m_type == IDBAny::Type::IDBObjectStore);
-    return m_objectStore.get();
-}
-
-IDBObjectStore* IDBAny::modernIDBObjectStore()
-{
-    ASSERT(m_type == IDBAny::Type::IDBObjectStore);
-    return m_objectStore.get();
-}
-
-IDBIndex* IDBAny::modernIDBIndex()
-{
-    ASSERT(m_type == IDBAny::Type::IDBIndex);
-    return m_index.get();
-}
-
-IDBCursor* IDBAny::modernIDBCursor()
-{
-    ASSERT(m_type == IDBAny::Type::IDBCursor || m_type == IDBAny::Type::IDBCursorWithValue);
-    if (m_type == IDBAny::Type::IDBCursor)
-        return m_cursor.get();
-    return m_cursorWithValue.get();
-}
-
-RefPtr<WebCore::IDBTransaction> IDBAny::idbTransaction()
-{
-    return nullptr;
-}
-
-const Deprecated::ScriptValue& IDBAny::scriptValue()
-{
-    return m_scriptValue;
-}
-
-int64_t IDBAny::integer()
-{
-    return m_integer;
-}
-
-const String& IDBAny::string()
-{
-    return m_string;
-}
-
-const IDBKeyPath& IDBAny::keyPath()
-{
-    return m_idbKeyPath;
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.h
deleted file mode 100644 (file)
index cec39db..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBAnyImpl_h
-#define IDBAnyImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBAny.h"
-#include "IDBDatabaseImpl.h"
-#include "IDBIndexImpl.h"
-#include "IDBObjectStoreImpl.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-class IDBAny : public WebCore::IDBAny {
-public:
-    static RefPtr<IDBAny> create(Ref<IDBDatabase>&& database)
-    {
-        return adoptRef(new IDBAny(WTFMove(database)));
-    }
-
-    static Ref<IDBAny> create(Ref<IDBObjectStore>&& objectStore)
-    {
-        return adoptRef(*new IDBAny(WTFMove(objectStore)));
-    }
-
-    static Ref<IDBAny> create(Ref<IDBIndex>&& index)
-    {
-        return adoptRef(*new IDBAny(WTFMove(index)));
-    }
-
-    static RefPtr<IDBAny> create(Ref<IDBCursor>&& cursor)
-    {
-        return adoptRef(new IDBAny(WTFMove(cursor)));
-    }
-
-    static RefPtr<IDBAny> create(const IDBKeyPath& keyPath)
-    {
-        return adoptRef(new IDBAny(keyPath));
-    }
-
-    static RefPtr<IDBAny> create(const Deprecated::ScriptValue& value)
-    {
-        return adoptRef(new IDBAny(value));
-    }
-
-    static RefPtr<IDBAny> createUndefined()
-    {
-        return adoptRef(new IDBAny(IDBAny::Type::Undefined));
-    }
-
-    virtual ~IDBAny();
-
-    Type type() const final { return m_type; }
-    RefPtr<WebCore::DOMStringList> domStringList() final;
-    RefPtr<WebCore::IDBCursor> idbCursor() final;
-    RefPtr<WebCore::IDBCursorWithValue> idbCursorWithValue() final;
-    RefPtr<WebCore::IDBDatabase> idbDatabase() final;
-    RefPtr<WebCore::IDBFactory> idbFactory() final;
-    RefPtr<WebCore::IDBIndex> idbIndex() final;
-    RefPtr<WebCore::IDBObjectStore> idbObjectStore() final;
-    RefPtr<WebCore::IDBTransaction> idbTransaction() final;
-    const Deprecated::ScriptValue& scriptValue() final;
-    int64_t integer() final;
-    const String& string() final;
-    const IDBKeyPath& keyPath() final;
-
-    IDBObjectStore* modernIDBObjectStore();
-    IDBIndex* modernIDBIndex();
-    IDBCursor* modernIDBCursor();
-
-private:
-    explicit IDBAny(IDBAny::Type);
-    explicit IDBAny(Ref<IDBDatabase>&&);
-    explicit IDBAny(Ref<IDBObjectStore>&&);
-    explicit IDBAny(Ref<IDBIndex>&&);
-    explicit IDBAny(Ref<IDBCursor>&&);
-    explicit IDBAny(const IDBKeyPath&);
-    explicit IDBAny(const Deprecated::ScriptValue&);
-
-    IDBAny::Type m_type { IDBAny::Type::Undefined };
-    RefPtr<IDBDatabase> m_database;
-    RefPtr<IDBObjectStore> m_objectStore;
-    RefPtr<IDBIndex> m_index;
-    RefPtr<IDBCursor> m_cursor;
-    RefPtr<IDBCursor> m_cursorWithValue;
-
-    const IDBKeyPath m_idbKeyPath;
-    const Deprecated::ScriptValue m_scriptValue;
-    const String m_string;
-    const int64_t m_integer { 0 };
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBAnyImpl_h
index dd5859d..5bced3f 100644 (file)
@@ -28,8 +28,9 @@
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "IDBDatabase.h"
 #include "IDBKeyRangeData.h"
-#include "IDBOpenDBRequestImpl.h"
+#include "IDBOpenDBRequest.h"
 #include "IDBRequestData.h"
 #include "IDBResultData.h"
 #include "Logging.h"
index 9229bd5..21608be 100644 (file)
 namespace WebCore {
 
 class IDBCursorInfo;
+class IDBDatabase;
 class IDBError;
 class IDBObjectStoreInfo;
+class IDBOpenDBRequest;
 class IDBResultData;
+class IDBTransaction;
 
 namespace IDBClient {
 
-class IDBDatabase;
-class IDBOpenDBRequest;
-class IDBTransaction;
 class TransactionOperation;
 
 class IDBConnectionToServer : public RefCounted<IDBConnectionToServer> {
@@ -130,7 +130,7 @@ private:
 
     Ref<IDBConnectionToServerDelegate> m_delegate;
 
-    HashMap<IDBResourceIdentifier, RefPtr<IDBClient::IDBOpenDBRequest>> m_openDBRequestMap;
+    HashMap<IDBResourceIdentifier, RefPtr<IDBOpenDBRequest>> m_openDBRequestMap;
     HashMap<uint64_t, IDBDatabase*> m_databaseConnectionMap;
     HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_pendingTransactions;
     HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_committingTransactions;
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp
deleted file mode 100644 (file)
index 5c5e4d6..0000000
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBCursorImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "DOMRequestState.h"
-#include "ExceptionCode.h"
-#include "IDBBindingUtilities.h"
-#include "IDBDatabaseException.h"
-#include "IDBGetResult.h"
-#include "Logging.h"
-#include "ScriptExecutionContext.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-Ref<IDBCursor> IDBCursor::create(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
-{
-    return adoptRef(*new IDBCursor(transaction, index, info));
-}
-
-IDBCursor::IDBCursor(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
-    : ActiveDOMObject(transaction.scriptExecutionContext())
-    , m_info(info)
-    , m_source(IDBAny::create(objectStore).leakRef())
-    , m_objectStore(&objectStore)
-{
-    suspendIfNeeded();
-}
-
-IDBCursor::IDBCursor(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
-    : ActiveDOMObject(transaction.scriptExecutionContext())
-    , m_info(info)
-    , m_source(IDBAny::create(index).leakRef())
-    , m_index(&index)
-{
-    suspendIfNeeded();
-}
-
-IDBCursor::~IDBCursor()
-{
-}
-
-bool IDBCursor::sourcesDeleted() const
-{
-    if (m_objectStore)
-        return m_objectStore->isDeleted();
-
-    ASSERT(m_index);
-    return m_index->isDeleted() || m_index->modernObjectStore().isDeleted();
-}
-
-IDBObjectStore& IDBCursor::effectiveObjectStore() const
-{
-    if (m_objectStore)
-        return *m_objectStore;
-
-    ASSERT(m_index);
-    return m_index->modernObjectStore();
-}
-
-IDBTransaction& IDBCursor::transaction() const
-{
-    return effectiveObjectStore().modernTransaction();
-}
-
-const String& IDBCursor::direction() const
-{
-    return IDBCursor::directionToString(m_info.cursorDirection());
-}
-
-const Deprecated::ScriptValue& IDBCursor::key() const
-{
-    return m_deprecatedCurrentKey;
-}
-
-const Deprecated::ScriptValue& IDBCursor::primaryKey() const
-{
-    return m_deprecatedCurrentPrimaryKey;
-}
-
-const Deprecated::ScriptValue& IDBCursor::value() const
-{
-    return m_deprecatedCurrentValue;
-}
-
-IDBAny* IDBCursor::source()
-{
-    return &m_source.get();
-}
-
-RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::ScriptValue& value, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBCursor::update");
-
-    if (sourcesDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor's source or effective object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!transaction().isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    if (transaction().isReadOnly()) {
-        ec.code = IDBDatabaseException::ReadOnlyError;
-        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The record may not be updated inside a read-only transaction.");
-        return nullptr;
-    }
-
-    if (!m_gotValue) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor is being iterated or has iterated past its end.");
-        return nullptr;
-    }
-
-    if (isKeyCursor()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor.");
-        return nullptr;
-    }
-
-    auto& objectStore = effectiveObjectStore();
-    auto& keyPath = objectStore.info().keyPath();
-    const bool usesInLineKeys = !keyPath.isNull();
-    if (usesInLineKeys) {
-        RefPtr<IDBKey> keyPathKey = maybeCreateIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath);
-        IDBKeyData keyPathKeyData(keyPathKey.get());
-        if (!keyPathKey || keyPathKeyData != m_currentPrimaryKeyData) {
-            ec.code = IDBDatabaseException::DataError;
-            ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.");
-            return nullptr;
-        }
-    }
-
-    auto request = effectiveObjectStore().putForCursorUpdate(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec);
-    if (ec.code)
-        return nullptr;
-
-    ASSERT(request);
-    request->setSource(*this);
-    ++m_outstandingRequestCount;
-
-    return request;
-}
-
-void IDBCursor::advance(unsigned long count, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBCursor::advance");
-
-    if (!m_request) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        return;
-    }
-    
-    if (!count) {
-        ec.code = TypeError;
-        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': A count argument with value 0 (zero) was supplied, must be greater than 0.");
-        return;
-    }
-
-    if (sourcesDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': The cursor's source or effective object store has been deleted.");
-        return;
-    }
-
-    if (!transaction().isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': The transaction is inactive or finished.");
-        return;
-    }
-
-    if (!m_gotValue) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': The cursor is being iterated or has iterated past its end.");
-        return;
-    }
-
-    m_gotValue = false;
-
-    uncheckedIterateCursor(IDBKeyData(), count);
-}
-
-void IDBCursor::continueFunction(ScriptExecutionContext* context, ExceptionCodeWithMessage& ec)
-{
-    if (!context) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        return;
-    }
-
-    continueFunction(IDBKeyData(), ec);
-}
-
-void IDBCursor::continueFunction(ScriptExecutionContext& context, const Deprecated::ScriptValue& keyValue, ExceptionCodeWithMessage& ec)
-{
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> key;
-    if (!keyValue.jsValue().isUndefined())
-        key = scriptValueToIDBKey(&requestState, keyValue);
-
-    continueFunction(key.get(), ec);
-}
-
-void IDBCursor::continueFunction(const IDBKeyData& key, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBCursor::continueFunction (to key %s)", key.loggingString().utf8().data());
-
-    if (!m_request) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        return;
-    }
-
-    if (sourcesDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The cursor's source or effective object store has been deleted.");
-        return;
-    }
-
-    if (!transaction().isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The transaction is inactive or finished.");
-        return;
-    }
-
-    if (!m_gotValue) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end.");
-        return;
-    }
-
-    if (!key.isNull() && !key.isValid()) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is not a valid key.");
-        return;
-    }
-
-    if (m_info.isDirectionForward()) {
-        if (!key.isNull() && key.compare(m_currentKeyData) <= 0) {
-            ec.code = IDBDatabaseException::DataError;
-            ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is less than or equal to this cursor's position.");
-            return;
-        }
-    } else if (!key.isNull() && key.compare(m_currentKeyData) >= 0) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is greater than or equal to this cursor's position.");
-        return;
-    }
-
-    m_gotValue = false;
-
-    uncheckedIterateCursor(key, 0);
-}
-
-void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned long count)
-{
-    ++m_outstandingRequestCount;
-
-    m_request->willIterateCursor(*this);
-    transaction().iterateCursor(*this, key, count);
-}
-
-RefPtr<WebCore::IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBCursor::deleteFunction");
-
-    if (sourcesDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor's source or effective object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!transaction().isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    if (transaction().isReadOnly()) {
-        ec.code = IDBDatabaseException::ReadOnlyError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The record may not be deleted inside a read-only transaction.");
-        return nullptr;
-    }
-
-    if (!m_gotValue) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor is being iterated or has iterated past its end.");
-        return nullptr;
-    }
-
-    if (isKeyCursor()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor is a key cursor.");
-        return nullptr;
-    }
-
-    auto request = effectiveObjectStore().modernDelete(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec);
-    if (ec.code)
-        return nullptr;
-
-    ASSERT(request);
-    request->setSource(*this);
-    ++m_outstandingRequestCount;
-
-    return request;
-}
-
-void IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult)
-{
-    LOG(IndexedDB, "IDBCursor::setGetResult - current key %s", getResult.keyData().loggingString().substring(0, 100).utf8().data());
-
-    auto* context = request.scriptExecutionContext();
-    if (!context)
-        return;
-
-    if (!getResult.isDefined()) {
-        m_deprecatedCurrentKey = { };
-        m_currentKeyData = { };
-        m_deprecatedCurrentPrimaryKey = { };
-        m_currentPrimaryKeyData = { };
-        m_deprecatedCurrentValue = { };
-
-        m_gotValue = false;
-        return;
-    }
-
-    m_deprecatedCurrentKey = idbKeyDataToScriptValue(context, getResult.keyData());
-    m_currentKeyData = getResult.keyData();
-    m_deprecatedCurrentPrimaryKey = idbKeyDataToScriptValue(context, getResult.primaryKeyData());
-    m_currentPrimaryKeyData = getResult.primaryKeyData();
-
-    if (isKeyCursor())
-        m_deprecatedCurrentValue = { };
-    else
-        m_deprecatedCurrentValue = deserializeIDBValueData(*context, getResult.valueBuffer());
-
-    m_gotValue = true;
-}
-
-const char* IDBCursor::activeDOMObjectName() const
-{
-    return "IDBCursor";
-}
-
-bool IDBCursor::canSuspendForDocumentSuspension() const
-{
-    return false;
-}
-
-bool IDBCursor::hasPendingActivity() const
-{
-    return m_outstandingRequestCount;
-}
-
-void IDBCursor::decrementOutstandingRequestCount()
-{
-    ASSERT(m_outstandingRequestCount);
-    --m_outstandingRequestCount;
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h
deleted file mode 100644 (file)
index d35c915..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBCursorImpl_h
-#define IDBCursorImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBAnyImpl.h"
-#include "IDBCursorInfo.h"
-#include "IDBCursorWithValue.h"
-
-namespace WebCore {
-
-class IDBGetResult;
-
-namespace IDBClient {
-
-class IDBIndex;
-class IDBObjectStore;
-class IDBTransaction;
-
-class IDBCursor : public WebCore::IDBCursorWithValue, public ActiveDOMObject {
-public:
-    static Ref<IDBCursor> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
-
-    virtual ~IDBCursor();
-
-    // Implement the IDL
-    const String& direction() const final;
-    const Deprecated::ScriptValue& key() const final;
-    const Deprecated::ScriptValue& primaryKey() const final;
-    const Deprecated::ScriptValue& value() const final;
-    IDBAny* source() final;
-
-    RefPtr<WebCore::IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCodeWithMessage&) final;
-    void advance(unsigned long, ExceptionCodeWithMessage&) final;
-    void continueFunction(ScriptExecutionContext*, ExceptionCodeWithMessage&) final;
-    void continueFunction(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext&, ExceptionCodeWithMessage&) final;
-
-    void continueFunction(const IDBKeyData&, ExceptionCodeWithMessage&);
-
-    const IDBCursorInfo& info() const { return m_info; }
-
-    void setRequest(IDBRequest& request) { m_request = &request; }
-    void clearRequest() { m_request = nullptr; }
-    IDBRequest* request() { return m_request; }
-
-    void setGetResult(IDBRequest&, const IDBGetResult&);
-
-    bool isKeyCursor() const override { return true; }
-    bool isModernCursor() const final { return true; }
-
-    void decrementOutstandingRequestCount();
-
-protected:
-    IDBCursor(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
-    IDBCursor(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
-
-private:
-    // ActiveDOMObject.
-    const char* activeDOMObjectName() const final;
-    bool canSuspendForDocumentSuspension() const final;
-    bool hasPendingActivity() const final;
-
-    // Cursors are created with an outstanding iteration request.
-    unsigned m_outstandingRequestCount { 1 };
-
-    IDBCursorInfo m_info;
-    Ref<IDBAny> m_source;
-    IDBObjectStore* m_objectStore { nullptr };
-    IDBIndex* m_index { nullptr };
-    IDBRequest* m_request;
-
-    bool sourcesDeleted() const;
-    IDBObjectStore& effectiveObjectStore() const;
-    IDBTransaction& transaction() const;
-
-    void uncheckedIterateCursor(const IDBKeyData&, unsigned long count);
-
-    bool m_gotValue { false };
-
-    IDBKeyData m_currentKeyData;
-    IDBKeyData m_currentPrimaryKeyData;
-
-    // FIXME: When ditching Legacy IDB and combining this implementation with the abstract IDBCursor,
-    // these Deprecated::ScriptValue members should be JSValues instead.
-    Deprecated::ScriptValue m_deprecatedCurrentKey;
-    Deprecated::ScriptValue m_deprecatedCurrentPrimaryKey;
-    Deprecated::ScriptValue m_deprecatedCurrentValue;
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBCursorImpl_h
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBCursorWithValueImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBCursorWithValueImpl.cpp
deleted file mode 100644 (file)
index eeedb2b..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBCursorWithValueImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-namespace WebCore {
-namespace IDBClient {
-
-Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
-{
-    return adoptRef(*new IDBCursorWithValue(transaction, objectStore, info));
-}
-
-Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
-{
-    return adoptRef(*new IDBCursorWithValue(transaction, index, info));
-}
-
-IDBCursorWithValue::IDBCursorWithValue(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
-    : IDBCursor(transaction, objectStore, info)
-{
-}
-
-IDBCursorWithValue::IDBCursorWithValue(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
-    : IDBCursor(transaction, index, info)
-{
-}
-
-IDBCursorWithValue::~IDBCursorWithValue()
-{
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBCursorWithValueImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBCursorWithValueImpl.h
deleted file mode 100644 (file)
index bfb841e..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBCursorWithValueImpl_h
-#define IDBCursorWithValueImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBCursorImpl.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-class IDBCursorWithValue : public IDBCursor {
-public:
-    static Ref<IDBCursorWithValue> create(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
-    static Ref<IDBCursorWithValue> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
-
-    virtual ~IDBCursorWithValue();
-
-    bool isKeyCursor() const final { return false; }
-
-private:
-    IDBCursorWithValue(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
-    IDBCursorWithValue(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBCursorWithValueImpl_h
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp
deleted file mode 100644 (file)
index 5e944ed..0000000
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBDatabaseImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "EventQueue.h"
-#include "IDBConnectionToServer.h"
-#include "IDBDatabaseException.h"
-#include "IDBOpenDBRequestImpl.h"
-#include "IDBResultData.h"
-#include "IDBTransactionImpl.h"
-#include "IDBVersionChangeEventImpl.h"
-#include "Logging.h"
-#include "ScriptExecutionContext.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-Ref<IDBDatabase> IDBDatabase::create(ScriptExecutionContext& context, IDBConnectionToServer& connection, const IDBResultData& resultData)
-{
-    return adoptRef(*new IDBDatabase(context, connection, resultData));
-}
-
-IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBConnectionToServer& connection, const IDBResultData& resultData)
-    : WebCore::IDBDatabase(&context)
-    , m_serverConnection(connection)
-    , m_info(resultData.databaseInfo())
-    , m_databaseConnectionIdentifier(resultData.databaseConnectionIdentifier())
-{
-    LOG(IndexedDB, "IDBDatabase::IDBDatabase - Creating database %s with version %" PRIu64 " connection %" PRIu64, m_info.name().utf8().data(), m_info.version(), m_databaseConnectionIdentifier);
-    suspendIfNeeded();
-    relaxAdoptionRequirement();
-    m_serverConnection->registerDatabaseConnection(*this);
-}
-
-IDBDatabase::~IDBDatabase()
-{
-    m_serverConnection->unregisterDatabaseConnection(*this);
-}
-
-bool IDBDatabase::hasPendingActivity() const
-{
-    return !m_closedInServer;
-}
-
-const String IDBDatabase::name() const
-{
-    return m_info.name();
-}
-
-uint64_t IDBDatabase::version() const
-{
-    return m_info.version();
-}
-
-RefPtr<DOMStringList> IDBDatabase::objectStoreNames() const
-{
-    RefPtr<DOMStringList> objectStoreNames = DOMStringList::create();
-    for (auto& name : m_info.objectStoreNames())
-        objectStoreNames->append(name);
-    objectStoreNames->sort();
-    return objectStoreNames;
-}
-
-RefPtr<WebCore::IDBObjectStore> IDBDatabase::createObjectStore(const String&, const Dictionary&, ExceptionCodeWithMessage&)
-{
-    ASSERT_NOT_REACHED();
-    return nullptr;
-}
-
-RefPtr<WebCore::IDBObjectStore> IDBDatabase::createObjectStore(const String& name, const IDBKeyPath& keyPath, bool autoIncrement, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBDatabase::createObjectStore");
-
-    ASSERT(!m_versionChangeTransaction || m_versionChangeTransaction->isVersionChange());
-
-    if (!m_versionChangeTransaction) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'createObjectStore' on 'IDBDatabase': The database is not running a version change transaction.");
-        return nullptr;
-    }
-
-    if (!m_versionChangeTransaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        return nullptr;
-    }
-
-    if (m_info.hasObjectStore(name)) {
-        ec.code = IDBDatabaseException::ConstraintError;
-        ec.message = ASCIILiteral("Failed to execute 'createObjectStore' on 'IDBDatabase': An object store with the specified name already exists.");
-        return nullptr;
-    }
-
-    if (!keyPath.isNull() && !keyPath.isValid()) {
-        ec.code = IDBDatabaseException::SyntaxError;
-        ec.message = ASCIILiteral("Failed to execute 'createObjectStore' on 'IDBDatabase': The keyPath option is not a valid key path.");
-        return nullptr;
-    }
-
-    if (autoIncrement && !keyPath.isNull()) {
-        if ((keyPath.type() == IndexedDB::KeyPathType::String && keyPath.string().isEmpty()) || keyPath.type() == IndexedDB::KeyPathType::Array) {
-            ec.code = IDBDatabaseException::InvalidAccessError;
-            ec.message = ASCIILiteral("Failed to execute 'createObjectStore' on 'IDBDatabase': The autoIncrement option was set but the keyPath option was empty or an array.");
-            return nullptr;
-        }
-    }
-
-    // Install the new ObjectStore into the connection's metadata.
-    IDBObjectStoreInfo info = m_info.createNewObjectStore(name, keyPath, autoIncrement);
-
-    // Create the actual IDBObjectStore from the transaction, which also schedules the operation server side.
-    Ref<IDBObjectStore> objectStore = m_versionChangeTransaction->createObjectStore(info);
-    return adoptRef(&objectStore.leakRef());
-}
-
-RefPtr<WebCore::IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext*, const Vector<String>& objectStores, const String& modeString, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBDatabase::transaction");
-
-    if (m_closePending) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.");
-        return nullptr;
-    }
-
-    if (objectStores.isEmpty()) {
-        ec.code = IDBDatabaseException::InvalidAccessError;
-        ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty.");
-        return nullptr;
-    }
-
-    IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, ec.code);
-    if (ec.code) {
-        ec.message = makeString(ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('"), modeString, ASCIILiteral("') is not one of 'readonly' or 'readwrite'."));
-        return nullptr;
-    }
-
-    if (mode != IndexedDB::TransactionMode::ReadOnly && mode != IndexedDB::TransactionMode::ReadWrite) {
-        ec.code = TypeError;
-        return nullptr;
-    }
-
-    if (m_versionChangeTransaction && !m_versionChangeTransaction->isFinishedOrFinishing()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.");
-        return nullptr;
-    }
-
-    for (auto& objectStoreName : objectStores) {
-        if (m_info.hasObjectStore(objectStoreName))
-            continue;
-        ec.code = IDBDatabaseException::NotFoundError;
-        ec.message = ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.");
-        return nullptr;
-    }
-
-    auto info = IDBTransactionInfo::clientTransaction(m_serverConnection.get(), objectStores, mode);
-    auto transaction = IDBTransaction::create(*this, info);
-
-    LOG(IndexedDB, "IDBDatabase::transaction - Added active transaction %s", info.identifier().loggingString().utf8().data());
-
-    m_activeTransactions.set(info.identifier(), &transaction.get());
-
-    return adoptRef(&transaction.leakRef());
-}
-
-RefPtr<WebCore::IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* context, const String& objectStore, const String& mode, ExceptionCodeWithMessage& ec)
-{
-    Vector<String> objectStores(1);
-    objectStores[0] = objectStore;
-    return transaction(context, objectStores, mode, ec);
-}
-
-void IDBDatabase::deleteObjectStore(const String& objectStoreName, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBDatabase::deleteObjectStore");
-
-    if (!m_versionChangeTransaction) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'deleteObjectStore' on 'IDBDatabase': The database is not running a version change transaction.");
-        return;
-    }
-
-    if (!m_versionChangeTransaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        return;
-    }
-
-    if (!m_info.hasObjectStore(objectStoreName)) {
-        ec.code = IDBDatabaseException::NotFoundError;
-        ec.message = ASCIILiteral("Failed to execute 'deleteObjectStore' on 'IDBDatabase': The specified object store was not found.");
-        return;
-    }
-
-    m_info.deleteObjectStore(objectStoreName);
-    m_versionChangeTransaction->deleteObjectStore(objectStoreName);
-}
-
-void IDBDatabase::close()
-{
-    LOG(IndexedDB, "IDBDatabase::close - %" PRIu64, m_databaseConnectionIdentifier);
-
-    m_closePending = true;
-    maybeCloseInServer();
-}
-
-void IDBDatabase::maybeCloseInServer()
-{
-    LOG(IndexedDB, "IDBDatabase::maybeCloseInServer - %" PRIu64, m_databaseConnectionIdentifier);
-
-    if (m_closedInServer)
-        return;
-
-    // 3.3.9 Database closing steps
-    // Wait for all transactions created using this connection to complete.
-    // Once they are complete, this connection is closed.
-    if (!m_activeTransactions.isEmpty())
-        return;
-
-    m_closedInServer = true;
-    m_serverConnection->databaseConnectionClosed(*this);
-}
-
-const char* IDBDatabase::activeDOMObjectName() const
-{
-    return "IDBDatabase";
-}
-
-bool IDBDatabase::canSuspendForDocumentSuspension() const
-{
-    // FIXME: This value will sometimes be false when database operations are actually in progress.
-    // Such database operations do not yet exist.
-    return true;
-}
-
-void IDBDatabase::stop()
-{
-    LOG(IndexedDB, "IDBDatabase::stop - %" PRIu64, m_databaseConnectionIdentifier);
-
-    Vector<IDBResourceIdentifier> transactionIdentifiers;
-    transactionIdentifiers.reserveInitialCapacity(m_activeTransactions.size());
-
-    for (auto& id : m_activeTransactions.keys())
-        transactionIdentifiers.uncheckedAppend(id);
-
-    for (auto& id : transactionIdentifiers) {
-        IDBTransaction* transaction = m_activeTransactions.get(id);
-        if (transaction)
-            transaction->stop();
-    }
-
-    close();
-}
-
-Ref<IDBTransaction> IDBDatabase::startVersionChangeTransaction(const IDBTransactionInfo& info, IDBOpenDBRequest& request)
-{
-    LOG(IndexedDB, "IDBDatabase::startVersionChangeTransaction %s", info.identifier().loggingString().utf8().data());
-
-    ASSERT(!m_versionChangeTransaction);
-    ASSERT(info.mode() == IndexedDB::TransactionMode::VersionChange);
-    ASSERT(!m_closePending);
-    ASSERT(scriptExecutionContext());
-
-    Ref<IDBTransaction> transaction = IDBTransaction::create(*this, info, request);
-    m_versionChangeTransaction = &transaction.get();
-
-    m_activeTransactions.set(transaction->info().identifier(), &transaction.get());
-
-    return transaction;
-}
-
-void IDBDatabase::didStartTransaction(IDBTransaction& transaction)
-{
-    LOG(IndexedDB, "IDBDatabase::didStartTransaction %s", transaction.info().identifier().loggingString().utf8().data());
-    ASSERT(!m_versionChangeTransaction);
-
-    // It is possible for the client to have aborted a transaction before the server replies back that it has started.
-    if (m_abortingTransactions.contains(transaction.info().identifier()))
-        return;
-
-    m_activeTransactions.set(transaction.info().identifier(), &transaction);
-}
-
-void IDBDatabase::willCommitTransaction(IDBTransaction& transaction)
-{
-    LOG(IndexedDB, "IDBDatabase::willCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data());
-
-    auto refTransaction = m_activeTransactions.take(transaction.info().identifier());
-    ASSERT(refTransaction);
-    m_committingTransactions.set(transaction.info().identifier(), WTFMove(refTransaction));
-}
-
-void IDBDatabase::didCommitTransaction(IDBTransaction& transaction)
-{
-    LOG(IndexedDB, "IDBDatabase::didCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data());
-
-    if (m_versionChangeTransaction == &transaction)
-        m_info.setVersion(transaction.info().newVersion());
-
-    didCommitOrAbortTransaction(transaction);
-}
-
-void IDBDatabase::willAbortTransaction(IDBTransaction& transaction)
-{
-    LOG(IndexedDB, "IDBDatabase::willAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
-
-    auto refTransaction = m_activeTransactions.take(transaction.info().identifier());
-    if (!refTransaction)
-        refTransaction = m_committingTransactions.take(transaction.info().identifier());
-
-    ASSERT(refTransaction);
-    m_abortingTransactions.set(transaction.info().identifier(), WTFMove(refTransaction));
-
-    if (transaction.isVersionChange()) {
-        ASSERT(transaction.originalDatabaseInfo());
-        m_info = *transaction.originalDatabaseInfo();
-        m_closePending = true;
-    }
-}
-
-void IDBDatabase::didAbortTransaction(IDBTransaction& transaction)
-{
-    LOG(IndexedDB, "IDBDatabase::didAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
-
-    if (transaction.isVersionChange()) {
-        ASSERT(transaction.originalDatabaseInfo());
-        ASSERT(m_info.version() == transaction.originalDatabaseInfo()->version());
-        m_closePending = true;
-        maybeCloseInServer();
-    }
-
-    didCommitOrAbortTransaction(transaction);
-}
-
-void IDBDatabase::didCommitOrAbortTransaction(IDBTransaction& transaction)
-{
-    LOG(IndexedDB, "IDBDatabase::didCommitOrAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
-
-    if (m_versionChangeTransaction == &transaction)
-        m_versionChangeTransaction = nullptr;
-
-#ifndef NDBEBUG
-    unsigned count = 0;
-    if (m_activeTransactions.contains(transaction.info().identifier()))
-        ++count;
-    if (m_committingTransactions.contains(transaction.info().identifier()))
-        ++count;
-    if (m_abortingTransactions.contains(transaction.info().identifier()))
-        ++count;
-
-    ASSERT(count == 1);
-#endif
-
-    m_activeTransactions.remove(transaction.info().identifier());
-    m_committingTransactions.remove(transaction.info().identifier());
-    m_abortingTransactions.remove(transaction.info().identifier());
-
-    if (m_closePending)
-        maybeCloseInServer();
-}
-
-void IDBDatabase::fireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion)
-{
-    uint64_t currentVersion = m_info.version();
-    LOG(IndexedDB, "IDBDatabase::fireVersionChangeEvent - current version %" PRIu64 ", requested version %" PRIu64 ", connection %" PRIu64, currentVersion, requestedVersion, m_databaseConnectionIdentifier);
-
-    if (!scriptExecutionContext() || m_closePending) {
-        serverConnection().didFireVersionChangeEvent(m_databaseConnectionIdentifier, requestIdentifier);
-        return;
-    }
-
-    Ref<Event> event = IDBVersionChangeEvent::create(requestIdentifier, currentVersion, requestedVersion, eventNames().versionchangeEvent);
-    event->setTarget(this);
-    scriptExecutionContext()->eventQueue().enqueueEvent(WTFMove(event));
-}
-
-bool IDBDatabase::dispatchEvent(Event& event)
-{
-    LOG(IndexedDB, "IDBDatabase::dispatchEvent (%" PRIu64 ")", m_databaseConnectionIdentifier);
-
-    bool result = WebCore::IDBDatabase::dispatchEvent(event);
-
-    if (event.isVersionChangeEvent() && event.type() == eventNames().versionchangeEvent)
-        serverConnection().didFireVersionChangeEvent(m_databaseConnectionIdentifier, downcast<IDBVersionChangeEvent>(event).requestIdentifier());
-
-    return result;
-}
-
-void IDBDatabase::didCreateIndexInfo(const IDBIndexInfo& info)
-{
-    auto* objectStore = m_info.infoForExistingObjectStore(info.objectStoreIdentifier());
-    ASSERT(objectStore);
-    objectStore->addExistingIndex(info);
-}
-
-void IDBDatabase::didDeleteIndexInfo(const IDBIndexInfo& info)
-{
-    auto* objectStore = m_info.infoForExistingObjectStore(info.objectStoreIdentifier());
-    ASSERT(objectStore);
-    objectStore->deleteIndex(info.name());
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.h
deleted file mode 100644 (file)
index 8cafcb4..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBDatabaseImpl_h
-#define IDBDatabaseImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBConnectionToServer.h"
-#include "IDBDatabase.h"
-#include "IDBDatabaseInfo.h"
-
-namespace WebCore {
-
-class IDBResultData;
-class IDBTransaction;
-class IDBTransactionInfo;
-
-namespace IDBClient {
-
-class IDBTransaction;
-
-class IDBDatabase : public WebCore::IDBDatabase {
-public:
-    static Ref<IDBDatabase> create(ScriptExecutionContext&, IDBConnectionToServer&, const IDBResultData&);
-
-    virtual ~IDBDatabase();
-
-    // IDBDatabase IDL
-    const String name() const final;
-    uint64_t version() const final;
-    RefPtr<DOMStringList> objectStoreNames() const final;
-
-    RefPtr<WebCore::IDBObjectStore> createObjectStore(const String& name, const Dictionary&, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBObjectStore> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBTransaction> transaction(ScriptExecutionContext*, const Vector<String>&, const String& mode, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBTransaction> transaction(ScriptExecutionContext*, const String&, const String& mode, ExceptionCodeWithMessage&) final;
-    void deleteObjectStore(const String& name, ExceptionCodeWithMessage&) final;
-    void close() final;
-
-    // EventTarget
-    EventTargetInterface eventTargetInterface() const final { return IDBDatabaseEventTargetInterfaceType; }
-    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
-    void refEventTarget() final { ref(); }
-    void derefEventTarget() final { deref(); }
-
-    const char* activeDOMObjectName() const final;
-    bool canSuspendForDocumentSuspension() const final;
-    void stop() final;
-
-    const IDBDatabaseInfo& info() const { return m_info; }
-    uint64_t databaseConnectionIdentifier() const { return m_databaseConnectionIdentifier; }
-
-    Ref<IDBTransaction> startVersionChangeTransaction(const IDBTransactionInfo&, IDBOpenDBRequest&);
-    void didStartTransaction(IDBTransaction&);
-
-    void willCommitTransaction(IDBTransaction&);
-    void didCommitTransaction(IDBTransaction&);
-    void willAbortTransaction(IDBTransaction&);
-    void didAbortTransaction(IDBTransaction&);
-
-    void fireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
-
-    IDBConnectionToServer& serverConnection() { return m_serverConnection.get(); }
-
-    void didCreateIndexInfo(const IDBIndexInfo&);
-    void didDeleteIndexInfo(const IDBIndexInfo&);
-
-    bool isClosingOrClosed() const { return m_closePending || m_closedInServer; }
-
-    bool dispatchEvent(Event&) final;
-
-private:
-    IDBDatabase(ScriptExecutionContext&, IDBConnectionToServer&, const IDBResultData&);
-
-    void didCommitOrAbortTransaction(IDBTransaction&);
-
-    void maybeCloseInServer();
-
-    bool hasPendingActivity() const final;
-
-    Ref<IDBConnectionToServer> m_serverConnection;
-    IDBDatabaseInfo m_info;
-    uint64_t m_databaseConnectionIdentifier { 0 };
-
-    bool m_closePending { false };
-    bool m_closedInServer { false };
-
-    RefPtr<IDBTransaction> m_versionChangeTransaction;
-    HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_activeTransactions;
-    HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_committingTransactions;
-    HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_abortingTransactions;
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBDatabaseImpl_h
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp
deleted file mode 100644 (file)
index 53be22d..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBFactoryImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "DOMRequestState.h"
-#include "Document.h"
-#include "ExceptionCode.h"
-#include "IDBBindingUtilities.h"
-#include "IDBDatabaseIdentifier.h"
-#include "IDBOpenDBRequestImpl.h"
-#include "Logging.h"
-#include "Page.h"
-#include "SchemeRegistry.h"
-#include "ScriptExecutionContext.h"
-#include "SecurityOrigin.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-static bool shouldThrowSecurityException(ScriptExecutionContext& context)
-{
-    ASSERT(is<Document>(context) || context.isWorkerGlobalScope());
-    if (is<Document>(context)) {
-        Document& document = downcast<Document>(context);
-        if (!document.frame())
-            return true;
-        if (!document.page())
-            return true;
-    }
-
-    if (!context.securityOrigin()->canAccessDatabase(context.topOrigin()))
-        return true;
-
-    return false;
-}
-
-Ref<IDBFactory> IDBFactory::create(IDBConnectionToServer& connection)
-{
-    return adoptRef(*new IDBFactory(connection));
-}
-
-IDBFactory::IDBFactory(IDBConnectionToServer& connection)
-    : m_connectionToServer(connection)
-{
-}
-
-RefPtr<WebCore::IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext&, ExceptionCode&)
-{
-    return nullptr;
-}
-
-RefPtr<WebCore::IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, ExceptionCode& ec)
-{
-    LOG(IndexedDB, "IDBFactory::open");
-    
-    return openInternal(context, name, 0, ec).release();
-}
-
-RefPtr<WebCore::IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCode& ec)
-{
-    LOG(IndexedDB, "IDBFactory::open");
-    
-    if (!version) {
-        ec = TypeError;
-        return nullptr;
-    }
-
-    return openInternal(context, name, version, ec).release();
-}
-
-RefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCode& ec)
-{
-    if (name.isNull()) {
-        ec = TypeError;
-        return nullptr;
-    }
-
-    if (shouldThrowSecurityException(context)) {
-        ec = SECURITY_ERR;
-        return nullptr;
-    }
-
-    ASSERT(context.securityOrigin());
-    ASSERT(context.topOrigin());
-    IDBDatabaseIdentifier databaseIdentifier(name, *context.securityOrigin(), *context.topOrigin());
-    if (!databaseIdentifier.isValid()) {
-        ec = TypeError;
-        return nullptr;
-    }
-
-    auto request = IDBOpenDBRequest::createOpenRequest(m_connectionToServer.get(), context, databaseIdentifier, version);
-    m_connectionToServer->openDatabase(request.get());
-
-    return adoptRef(&request.leakRef());
-}
-
-RefPtr<WebCore::IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext& context, const String& name, ExceptionCode& ec)
-{
-    LOG(IndexedDB, "IDBFactory::deleteDatabase - %s", name.utf8().data());
-
-    if (name.isNull()) {
-        ec = TypeError;
-        return nullptr;
-    }
-    
-    if (shouldThrowSecurityException(context)) {
-        ec = SECURITY_ERR;
-        return nullptr;
-    }
-
-    ASSERT(context.securityOrigin());
-    ASSERT(context.topOrigin());
-    IDBDatabaseIdentifier databaseIdentifier(name, *context.securityOrigin(), *context.topOrigin());
-    if (!databaseIdentifier.isValid()) {
-        ec = TypeError;
-        return nullptr;
-    }
-
-    auto request = IDBOpenDBRequest::createDeleteRequest(m_connectionToServer.get(), context, databaseIdentifier);
-    m_connectionToServer->deleteDatabase(request.get());
-
-    return adoptRef(&request.leakRef());
-}
-
-short IDBFactory::cmp(ScriptExecutionContext& context, const Deprecated::ScriptValue& firstValue, const Deprecated::ScriptValue& secondValue, ExceptionCodeWithMessage& ec)
-{
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> first = scriptValueToIDBKey(&requestState, firstValue);
-    RefPtr<IDBKey> second = scriptValueToIDBKey(&requestState, secondValue);
-
-    ASSERT(first);
-    ASSERT(second);
-
-    if (!first->isValid() || !second->isValid()) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'cmp' on 'IDBFactory': The parameter is not a valid key.");
-        return 0;
-    }
-
-    return static_cast<short>(first->compare(second.get()));
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.h
deleted file mode 100644 (file)
index 8407421..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBFactoryImpl_h
-#define IDBFactoryImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBConnectionToServer.h"
-#include "IDBFactory.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-class IDBOpenDBRequest;
-
-class IDBFactory : public WebCore::IDBFactory {
-public:
-    static Ref<IDBFactory> create(IDBConnectionToServer&);
-
-    RefPtr<WebCore::IDBRequest> getDatabaseNames(ScriptExecutionContext&, ExceptionCode&) final;
-
-    RefPtr<WebCore::IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, ExceptionCode&) final;
-    RefPtr<WebCore::IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCode&) final;
-    RefPtr<WebCore::IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const String& name, ExceptionCode&) final;
-
-    short cmp(ScriptExecutionContext&, const Deprecated::ScriptValue& first, const Deprecated::ScriptValue& second, ExceptionCodeWithMessage&) final;
-
-private:
-    IDBFactory(IDBConnectionToServer&);
-    
-    RefPtr<IDBOpenDBRequest> openInternal(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCode&);
-    
-    Ref<IDBConnectionToServer> m_connectionToServer;
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBFactoryImpl_h
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp
deleted file mode 100644 (file)
index 3f6e8df..0000000
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBIndexImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "DOMRequestState.h"
-#include "IDBAnyImpl.h"
-#include "IDBBindingUtilities.h"
-#include "IDBCursorImpl.h"
-#include "IDBDatabaseException.h"
-#include "IDBKeyRangeData.h"
-#include "IDBObjectStoreImpl.h"
-#include "IDBTransactionImpl.h"
-#include "Logging.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-IDBIndex::IDBIndex(ScriptExecutionContext& context, const IDBIndexInfo& info, IDBObjectStore& objectStore)
-    : ActiveDOMObject(&context)
-    , m_info(info)
-    , m_objectStore(objectStore)
-{
-    suspendIfNeeded();
-}
-
-IDBIndex::~IDBIndex()
-{
-}
-
-const char* IDBIndex::activeDOMObjectName() const
-{
-    return "IDBIndex";
-}
-
-bool IDBIndex::canSuspendForDocumentSuspension() const
-{
-    return false;
-}
-
-bool IDBIndex::hasPendingActivity() const
-{
-    return !m_objectStore.modernTransaction().isFinished();
-}
-
-const String& IDBIndex::name() const
-{
-    return m_info.name();
-}
-
-RefPtr<WebCore::IDBObjectStore> IDBIndex::objectStore()
-{
-    return &m_objectStore;
-}
-
-RefPtr<WebCore::IDBAny> IDBIndex::keyPathAny() const
-{
-    return IDBAny::create(m_info.keyPath());
-}
-
-const IDBKeyPath& IDBIndex::keyPath() const
-{
-    return m_info.keyPath();
-}
-
-bool IDBIndex::unique() const
-{
-    return m_info.unique();
-}
-
-bool IDBIndex::multiEntry() const
-{
-    return m_info.multiEntry();
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext& context, IDBKeyRange* range, const String& directionString, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::openCursor");
-
-    if (m_deleted || m_objectStore.isDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The index or its object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!m_objectStore.modernTransaction().isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec.code);
-    if (ec.code) {
-        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.");
-        return nullptr;
-    }
-
-    IDBKeyRangeData rangeData = range;
-    if (rangeData.lowerKey.isNull())
-        rangeData.lowerKey = IDBKeyData::minimum();
-    if (rangeData.upperKey.isNull())
-        rangeData.upperKey = IDBKeyData::maximum();
-
-    auto info = IDBCursorInfo::indexCursor(m_objectStore.modernTransaction(), m_objectStore.info().identifier(), m_info.identifier(), rangeData, direction, IndexedDB::CursorType::KeyAndValue);
-    return m_objectStore.modernTransaction().requestOpenCursor(context, *this, info);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::openCursor");
-    RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec.code);
-    if (ec.code) {
-        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The parameter is not a valid key.");
-        return nullptr;
-    }
-
-    return openCursor(context, keyRange.get(), direction, ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::count(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::count");
-
-    return doCount(context, IDBKeyRangeData::allKeys(), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::count(ScriptExecutionContext& context, IDBKeyRange* range, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::count");
-
-    return doCount(context, range ? IDBKeyRangeData(range) : IDBKeyRangeData::allKeys(), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::count(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::count");
-
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
-    if (!idbKey || idbKey->type() == KeyType::Invalid) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key.");
-        return nullptr;
-    }
-
-    return doCount(context, IDBKeyRangeData(idbKey.get()), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::doCount(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
-{
-    if (m_deleted || m_objectStore.isDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The index or its object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!range.isValid()) {
-        ec.code = IDBDatabaseException::DataError;
-        return nullptr;
-    }
-
-    auto& transaction = m_objectStore.modernTransaction();
-    if (!transaction.isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    return transaction.requestCount(context, *this, range);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext& context, IDBKeyRange* range, const String& directionString, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::openKeyCursor");
-
-    if (m_deleted || m_objectStore.isDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The index or its object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!m_objectStore.modernTransaction().isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec.code);
-    if (ec.code) {
-        ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.");
-        return nullptr;
-    }
-
-    auto info = IDBCursorInfo::indexCursor(m_objectStore.modernTransaction(), m_objectStore.info().identifier(), m_info.identifier(), range, direction, IndexedDB::CursorType::KeyOnly);
-    return m_objectStore.modernTransaction().requestOpenCursor(context, *this, info);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::openKeyCursor");
-    RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec.code);
-    if (ec.code) {
-        ec.message = ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The parameter is not a valid key.");
-        return nullptr;
-    }
-    return openKeyCursor(context, keyRange.get(), direction, ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::get(ScriptExecutionContext& context, IDBKeyRange* range, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::get");
-
-    return doGet(context, IDBKeyRangeData(range), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::get(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::get");
-
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
-    if (!idbKey || idbKey->type() == KeyType::Invalid) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The parameter is not a valid key.");
-        return nullptr;
-    }
-
-    return doGet(context, IDBKeyRangeData(idbKey.get()), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::doGet(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
-{
-    if (m_deleted || m_objectStore.isDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The index or its object store has been deleted.");
-        return nullptr;
-    }
-
-    if (range.isNull) {
-        ec.code = IDBDatabaseException::DataError;
-        return nullptr;
-    }
-
-    auto& transaction = m_objectStore.modernTransaction();
-    if (!transaction.isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    return transaction.requestGetValue(context, *this, range);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::getKey(ScriptExecutionContext& context, IDBKeyRange* range, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::getKey");
-
-    return doGetKey(context, IDBKeyRangeData(range), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::getKey(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBIndex::getKey");
-
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
-    if (!idbKey || idbKey->type() == KeyType::Invalid) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The parameter is not a valid key.");
-        return nullptr;
-    }
-
-    return doGetKey(context, IDBKeyRangeData(idbKey.get()), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBIndex::doGetKey(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
-{
-    if (m_deleted || m_objectStore.isDeleted()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The index or its object store has been deleted.");
-        return nullptr;
-    }
-
-    if (range.isNull) {
-        ec.code = IDBDatabaseException::DataError;
-        return nullptr;
-    }
-
-    auto& transaction = m_objectStore.modernTransaction();
-    if (!transaction.isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    return transaction.requestGetKey(context, *this, range);
-}
-
-void IDBIndex::markAsDeleted()
-{
-    ASSERT(!m_deleted);
-    m_deleted = true;
-}
-
-void IDBIndex::ref()
-{
-    m_objectStore.ref();
-}
-
-void IDBIndex::deref()
-{
-    m_objectStore.deref();
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h
deleted file mode 100644 (file)
index fd2425e..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBIndexImpl_h
-#define IDBIndexImpl_h
-
-#include "IDBIndex.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "ActiveDOMObject.h"
-#include "IDBIndexInfo.h"
-
-namespace WebCore {
-
-struct IDBKeyRangeData;
-
-namespace IDBClient {
-
-class IDBObjectStore;
-
-class IDBIndex : public WebCore::IDBIndex, public ActiveDOMObject {
-public:
-    IDBIndex(ScriptExecutionContext&, const IDBIndexInfo&, IDBObjectStore&);
-
-    virtual ~IDBIndex();
-
-    // Implement the IDL
-    const String& name() const final;
-    RefPtr<WebCore::IDBObjectStore> objectStore() final;
-    RefPtr<WebCore::IDBAny> keyPathAny() const final;
-    const IDBKeyPath& keyPath() const final;
-    bool unique() const final;
-    bool multiEntry() const final;
-
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec) final { return openCursor(context, static_cast<IDBKeyRange*>(nullptr), ec); }
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) final { return openCursor(context, keyRange, IDBCursor::directionNext(), ec); }
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec) final { return openCursor(context, key, IDBCursor::directionNext(), ec); }
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&) final;
-
-    RefPtr<WebCore::IDBRequest> count(ScriptExecutionContext&, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> count(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> count(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) final;
-
-    RefPtr<WebCore::IDBRequest> openKeyCursor(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec) final { return openKeyCursor(context, static_cast<IDBKeyRange*>(nullptr), ec); }
-    RefPtr<WebCore::IDBRequest> openKeyCursor(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) final { return openKeyCursor(context, keyRange, IDBCursor::directionNext(), ec); }
-    RefPtr<WebCore::IDBRequest> openKeyCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec) final { return openKeyCursor(context, key, IDBCursor::directionNext(), ec); }
-    RefPtr<WebCore::IDBRequest> openKeyCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> openKeyCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&) final;
-
-    RefPtr<WebCore::IDBRequest> get(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> get(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> getKey(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> getKey(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) final;
-
-    const IDBIndexInfo& info() const { return m_info; }
-
-    IDBObjectStore& modernObjectStore() { return m_objectStore; }
-
-    void markAsDeleted();
-    bool isDeleted() const { return m_deleted; }
-
-    bool isModern() const override { return true; }
-
-    void ref() override;
-    void deref() override;
-
-private:
-    RefPtr<WebCore::IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
-    RefPtr<WebCore::IDBRequest> doGet(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
-    RefPtr<WebCore::IDBRequest> doGetKey(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
-
-    // ActiveDOMObject
-    const char* activeDOMObjectName() const final;
-    bool canSuspendForDocumentSuspension() const final;
-    bool hasPendingActivity() const final;
-
-    IDBIndexInfo m_info;
-
-    bool m_deleted { false };
-
-    // IDBIndex objects are always owned by their referencing IDBObjectStore.
-    // Indexes will never outlive ObjectStores so its okay to keep a raw C++ reference here.
-    IDBObjectStore& m_objectStore;
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBIndexImpl_h
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp
deleted file mode 100644 (file)
index fa0c876..0000000
+++ /dev/null
@@ -1,661 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBObjectStoreImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "DOMRequestState.h"
-#include "IDBBindingUtilities.h"
-#include "IDBCursorImpl.h"
-#include "IDBDatabaseException.h"
-#include "IDBError.h"
-#include "IDBIndexImpl.h"
-#include "IDBKey.h"
-#include "IDBKeyRangeData.h"
-#include "IDBRequestImpl.h"
-#include "IDBTransactionImpl.h"
-#include "IndexedDB.h"
-#include "Logging.h"
-#include "SerializedScriptValue.h"
-#include <wtf/Locker.h>
-
-namespace WebCore {
-namespace IDBClient {
-
-Ref<IDBObjectStore> IDBObjectStore::create(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
-{
-    return adoptRef(*new IDBObjectStore(context, info, transaction));
-}
-
-IDBObjectStore::IDBObjectStore(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
-    : ActiveDOMObject(&context)
-    , m_info(info)
-    , m_originalInfo(info)
-    , m_transaction(transaction)
-{
-    suspendIfNeeded();
-}
-
-IDBObjectStore::~IDBObjectStore()
-{
-}
-
-const char* IDBObjectStore::activeDOMObjectName() const
-{
-    return "IDBObjectStore";
-}
-
-bool IDBObjectStore::canSuspendForDocumentSuspension() const
-{
-    return false;
-}
-
-bool IDBObjectStore::hasPendingActivity() const
-{
-    return !m_transaction->isFinished();
-}
-
-const String IDBObjectStore::name() const
-{
-    return m_info.name();
-}
-
-RefPtr<WebCore::IDBAny> IDBObjectStore::keyPathAny() const
-{
-    return IDBAny::create(m_info.keyPath());
-}
-
-const IDBKeyPath IDBObjectStore::keyPath() const
-{
-    return m_info.keyPath();
-}
-
-RefPtr<DOMStringList> IDBObjectStore::indexNames() const
-{
-    RefPtr<DOMStringList> indexNames = DOMStringList::create();
-    for (auto& name : m_info.indexNames())
-        indexNames->append(name);
-    indexNames->sort();
-
-    return indexNames;
-}
-
-RefPtr<WebCore::IDBTransaction> IDBObjectStore::transaction()
-{
-    return &m_transaction.get();
-}
-
-bool IDBObjectStore::autoIncrement() const
-{
-    return m_info.autoIncrement();
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
-{
-    return openCursor(context, static_cast<IDBKeyRange*>(nullptr), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
-{
-    return openCursor(context, keyRange, IDBCursor::directionNext(), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
-{
-    return openCursor(context, key, IDBCursor::directionNext(), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, IDBKeyRange* range, const String& directionString, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::openCursor");
-
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec.code);
-    if (ec.code)
-        return nullptr;
-
-    auto info = IDBCursorInfo::objectStoreCursor(m_transaction.get(), m_info.identifier(), range, direction);
-    Ref<IDBRequest> request = m_transaction->requestOpenCursor(context, *this, info);
-    return WTFMove(request);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage& ec)
-{
-    RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec.code);
-    if (ec.code) {
-        ec.message = ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The parameter is not a valid key.");
-        return 0;
-    }
-
-    return openCursor(context, keyRange.get(), direction, ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::get(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::get");
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted.");
-        return nullptr;
-    }
-
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
-    if (!idbKey || idbKey->type() == KeyType::Invalid) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The parameter is not a valid key.");
-        return nullptr;
-    }
-
-    Ref<IDBRequest> request = m_transaction->requestGetRecord(context, *this, idbKey.get());
-    return WTFMove(request);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::get(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::get");
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        return nullptr;
-    }
-
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted.");
-        return nullptr;
-    }
-
-    IDBKeyRangeData keyRangeData(keyRange);
-    if (!keyRangeData.isValid()) {
-        ec.code = IDBDatabaseException::DataError;
-        return nullptr;
-    }
-
-    Ref<IDBRequest> request = m_transaction->requestGetRecord(context, *this, keyRangeData);
-    return WTFMove(request);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& state, JSC::JSValue value, ExceptionCodeWithMessage& ec)
-{
-    return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, InlineKeyCheck::Perform, ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& execState, JSC::JSValue value, JSC::JSValue key, ExceptionCodeWithMessage& ec)
-{
-    RefPtr<IDBKey> idbKey;
-    if (!key.isUndefined())
-        idbKey = scriptValueToIDBKey(execState, key);
-    return putOrAdd(execState, value, idbKey, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, InlineKeyCheck::Perform, ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& execState, JSC::JSValue value, JSC::JSValue key, ExceptionCodeWithMessage& ec)
-{
-    RefPtr<IDBKey> idbKey;
-    if (!key.isUndefined())
-        idbKey = scriptValueToIDBKey(execState, key);
-    return putOrAdd(execState, value, idbKey, IndexedDB::ObjectStoreOverwriteMode::Overwrite, InlineKeyCheck::Perform, ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& state, JSC::JSValue value, ExceptionCodeWithMessage& ec)
-{
-    return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::Overwrite, InlineKeyCheck::Perform, ec);
-}
-
-RefPtr<IDBRequest> IDBObjectStore::putForCursorUpdate(JSC::ExecState& state, JSC::JSValue value, JSC::JSValue key, ExceptionCodeWithMessage& ec)
-{
-    return putOrAdd(state, value, scriptValueToIDBKey(state, key), IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor, InlineKeyCheck::DoNotPerform, ec);
-}
-
-RefPtr<IDBRequest> IDBObjectStore::putOrAdd(JSC::ExecState& state, JSC::JSValue value, RefPtr<IDBKey> key, IndexedDB::ObjectStoreOverwriteMode overwriteMode, InlineKeyCheck inlineKeyCheck, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::putOrAdd");
-
-    // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
-    // the exception for an object store being deleted.
-    // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies.
-    // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit.
-    // Until this is sorted out, we'll agree with the test and the majority share browsers.
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    if (m_transaction->isReadOnly()) {
-        ec.code = IDBDatabaseException::ReadOnlyError;
-        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The transaction is read-only.");
-        return nullptr;
-    }
-
-    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(&state, value, nullptr, nullptr);
-    if (state.hadException()) {
-        // Clear the DOM exception from the serializer so we can give a more targeted exception.
-        state.clearException();
-
-        ec.code = IDBDatabaseException::DataCloneError;
-        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: An object could not be cloned.");
-        return nullptr;
-    }
-
-    if (serializedValue->hasBlobURLs()) {
-        // FIXME: Add Blob/File/FileList support
-        ec.code = IDBDatabaseException::DataCloneError;
-        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: BlobURLs are not yet supported.");
-        return nullptr;
-    }
-
-    if (key && !key->isValid()) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The parameter is not a valid key.");
-        return nullptr;
-    }
-
-    bool usesInlineKeys = !m_info.keyPath().isNull();
-    bool usesKeyGenerator = autoIncrement();
-    if (usesInlineKeys && inlineKeyCheck == InlineKeyCheck::Perform) {
-        if (key) {
-            ec.code = IDBDatabaseException::DataError;
-            ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The object store uses in-line keys and the key parameter was provided.");
-            return nullptr;
-        }
-
-        RefPtr<IDBKey> keyPathKey = maybeCreateIDBKeyFromScriptValueAndKeyPath(state, value, m_info.keyPath());
-        if (keyPathKey && !keyPathKey->isValid()) {
-            ec.code = IDBDatabaseException::DataError;
-            ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: Evaluating the object store's key path yielded a value that is not a valid key.");
-            return nullptr;
-        }
-
-        if (!keyPathKey) {
-            if (usesKeyGenerator) {
-                if (!canInjectIDBKeyIntoScriptValue(state, value, m_info.keyPath())) {
-                    ec.code = IDBDatabaseException::DataError;
-                    return nullptr;
-                }
-            } else {
-                ec.code = IDBDatabaseException::DataError;
-                ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value.");
-                return nullptr;
-            }
-        }
-
-        if (keyPathKey) {
-            ASSERT(!key);
-            key = keyPathKey;
-        }
-    } else if (!usesKeyGenerator && !key) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to store record in an IDBObjectStore: The object store uses out-of-line keys and has no key generator and the key parameter was not provided.");
-        return nullptr;
-    }
-
-    auto context = scriptExecutionContextFromExecState(&state);
-    if (!context) {
-        ec.code = IDBDatabaseException::UnknownError;
-        return nullptr;
-    }
-
-    Ref<IDBRequest> request = m_transaction->requestPutOrAdd(*context, *this, key.get(), *serializedValue, overwriteMode);
-    return adoptRef(request.leakRef());
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
-{
-    return doDelete(context, keyRange, ec);
-}
-
-RefPtr<IDBRequest> IDBObjectStore::doDelete(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::deleteFunction");
-
-    // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
-    // the exception for an object store being deleted.
-    // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies.
-    // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit.
-    // Until this is sorted out, we'll agree with the test and the majority share browsers.
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    if (m_transaction->isReadOnly()) {
-        ec.code = IDBDatabaseException::ReadOnlyError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The transaction is read-only.");
-        return nullptr;
-    }
-
-    IDBKeyRangeData keyRangeData(keyRange);
-    if (!keyRangeData.isValid()) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range.");
-        return nullptr;
-    }
-
-    Ref<IDBRequest> request = m_transaction->requestDeleteRecord(context, *this, keyRangeData);
-    return WTFMove(request);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
-{
-    return modernDelete(context, key.jsValue(), ec);
-}
-
-RefPtr<IDBRequest> IDBObjectStore::modernDelete(ScriptExecutionContext& context, JSC::JSValue key, ExceptionCodeWithMessage& ec)
-{
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
-    if (!idbKey || idbKey->type() == KeyType::Invalid) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key.");
-        return nullptr;
-    }
-
-    return doDelete(context, &IDBKeyRange::create(idbKey.get()).get(), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::clear(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::clear");
-
-    // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
-    // the exception for an object store being deleted.
-    // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies.
-    // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit.
-    // Until this is sorted out, we'll agree with the test and the majority share browsers.
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'clear' on 'IDBObjectStore': The object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'clear' on 'IDBObjectStore': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    if (m_transaction->isReadOnly()) {
-        ec.code = IDBDatabaseException::ReadOnlyError;
-        ec.message = ASCIILiteral("Failed to execute 'clear' on 'IDBObjectStore': The transaction is read-only.");
-        return nullptr;
-    }
-
-    Ref<IDBRequest> request = m_transaction->requestClearObjectStore(context, *this);
-    return adoptRef(request.leakRef());
-}
-
-RefPtr<WebCore::IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext&, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::createIndex %s", name.utf8().data());
-
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!m_transaction->isVersionChange()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The database is not running a version change transaction.");
-        return nullptr;
-    }
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        return nullptr;
-    }
-
-    if (!keyPath.isValid()) {
-        ec.code = IDBDatabaseException::SyntaxError;
-        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The keyPath argument contains an invalid key path.");
-        return nullptr;
-    }
-
-    if (name.isNull()) {
-        ec.code = TypeError;
-        return nullptr;
-    }
-
-    if (m_info.hasIndex(name)) {
-        ec.code = IDBDatabaseException::ConstraintError;
-        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': An index with the specified name already exists.");
-        return nullptr;
-    }
-
-    if (keyPath.type() == IndexedDB::KeyPathType::Array && multiEntry) {
-        ec.code = IDBDatabaseException::InvalidAccessError;
-        ec.message = ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The keyPath argument was an array and the multiEntry option is true.");
-        return nullptr;
-    }
-
-    // Install the new Index into the ObjectStore's info.
-    IDBIndexInfo info = m_info.createNewIndex(name, keyPath, unique, multiEntry);
-    m_transaction->database().didCreateIndexInfo(info);
-
-    // Create the actual IDBObjectStore from the transaction, which also schedules the operation server side.
-    auto index = m_transaction->createIndex(*this, info);
-    RefPtr<IDBIndex> refIndex = index.get();
-
-    Locker<Lock> locker(m_referencedIndexLock);
-    m_referencedIndexes.set(name, WTFMove(index));
-
-    return WTFMove(refIndex);
-}
-
-RefPtr<WebCore::IDBIndex> IDBObjectStore::index(const String& indexName, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::index");
-
-    if (!scriptExecutionContext())
-        return nullptr;
-
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'index' on 'IDBObjectStore': The object store has been deleted.");
-        return nullptr;
-    }
-
-    if (m_transaction->isFinishedOrFinishing()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'index' on 'IDBObjectStore': The transaction is finished.");
-        return nullptr;
-    }
-
-    Locker<Lock> locker(m_referencedIndexLock);
-    auto iterator = m_referencedIndexes.find(indexName);
-    if (iterator != m_referencedIndexes.end())
-        return iterator->value.get();
-
-    auto* info = m_info.infoForExistingIndex(indexName);
-    if (!info) {
-        ec.code = IDBDatabaseException::NotFoundError;
-        ec.message = ASCIILiteral("Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.");
-        return nullptr;
-    }
-
-    auto index = std::make_unique<IDBIndex>(*scriptExecutionContext(), *info, *this);
-    RefPtr<IDBIndex> refIndex = index.get();
-    m_referencedIndexes.set(indexName, WTFMove(index));
-
-    return refIndex;
-}
-
-void IDBObjectStore::deleteIndex(const String& name, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::deleteIndex %s", name.utf8().data());
-
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The object store has been deleted.");
-        return;
-    }
-
-    if (!m_transaction->isVersionChange()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The database is not running a version change transaction.");
-        return;
-    }
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The transaction is inactive or finished.");
-        return;
-    }
-
-    if (!m_info.hasIndex(name)) {
-        ec.code = IDBDatabaseException::NotFoundError;
-        ec.message = ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The specified index was not found.");
-        return;
-    }
-
-    auto* info = m_info.infoForExistingIndex(name);
-    ASSERT(info);
-    m_transaction->database().didDeleteIndexInfo(*info);
-
-    m_info.deleteIndex(name);
-
-    {
-        Locker<Lock> locker(m_referencedIndexLock);
-        if (auto index = m_referencedIndexes.take(name)) {
-            index->markAsDeleted();
-            m_deletedIndexes.add(WTFMove(index));
-        }
-
-    }
-
-    m_transaction->deleteIndex(m_info.identifier(), name);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext& context, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::count");
-
-    return doCount(context, IDBKeyRangeData::allKeys(), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext& context, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::count");
-
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
-    if (!idbKey || idbKey->type() == KeyType::Invalid) {
-        ec.code = IDBDatabaseException::DataError;
-        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key.");
-        return nullptr;
-    }
-
-    return doCount(context, IDBKeyRangeData(idbKey.get()), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext& context, IDBKeyRange* range, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBObjectStore::count");
-
-    return doCount(context, range ? IDBKeyRangeData(range) : IDBKeyRangeData::allKeys(), ec);
-}
-
-RefPtr<WebCore::IDBRequest> IDBObjectStore::doCount(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCodeWithMessage& ec)
-{
-    // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
-    // the exception for an object store being deleted.
-    // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies.
-    // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit.
-    // Until this is sorted out, we'll agree with the test and the majority share browsers.
-    if (m_deleted) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBObjectStore': The object store has been deleted.");
-        return nullptr;
-    }
-
-    if (!m_transaction->isActive()) {
-        ec.code = IDBDatabaseException::TransactionInactiveError;
-        ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBObjectStore': The transaction is inactive or finished.");
-        return nullptr;
-    }
-
-    if (!range.isValid()) {
-        ec.code = IDBDatabaseException::DataError;
-        return nullptr;
-    }
-
-    return m_transaction->requestCount(context, *this, range);
-}
-
-void IDBObjectStore::markAsDeleted()
-{
-    m_deleted = true;
-}
-
-void IDBObjectStore::rollbackInfoForVersionChangeAbort()
-{
-    m_info = m_originalInfo;
-}
-
-void IDBObjectStore::visitReferencedIndexes(JSC::SlotVisitor& visitor) const
-{
-    Locker<Lock> locker(m_referencedIndexLock);
-    for (auto& index : m_referencedIndexes.values())
-        visitor.addOpaqueRoot(index.get());
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h
deleted file mode 100644 (file)
index 306b150..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBObjectStoreImpl_h
-#define IDBObjectStoreImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "ActiveDOMObject.h"
-#include "IDBIndexImpl.h"
-#include "IDBObjectStore.h"
-#include "IDBObjectStoreInfo.h"
-#include "IndexedDB.h"
-
-namespace WebCore {
-
-class IDBKey;
-
-struct IDBKeyRangeData;
-
-namespace IDBClient {
-
-class IDBRequest;
-class IDBTransaction;
-
-class IDBObjectStore : public WebCore::IDBObjectStore, public ActiveDOMObject {
-public:
-    static Ref<IDBObjectStore> create(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&);
-
-    ~IDBObjectStore() final;
-
-    // Implement the IDBObjectStore IDL
-    const String name() const final;
-    RefPtr<WebCore::IDBAny> keyPathAny() const final;
-    const IDBKeyPath keyPath() const final;
-    RefPtr<DOMStringList> indexNames() const final;
-    RefPtr<WebCore::IDBTransaction> transaction() final;
-    bool autoIncrement() const final;
-
-    RefPtr<WebCore::IDBRequest> add(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> put(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext&, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> openCursor(ScriptExecutionContext&, const Deprecated::ScriptValue& key, const String& direction, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> get(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> get(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> add(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> put(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> clear(ScriptExecutionContext&, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBIndex> createIndex(ScriptExecutionContext&, const String& name, const IDBKeyPath&, bool unique, bool multiEntry, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBIndex> index(const String& name, ExceptionCodeWithMessage&) final;
-    void deleteIndex(const String& name, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> count(ScriptExecutionContext&, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> count(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&) final;
-    RefPtr<WebCore::IDBRequest> count(ScriptExecutionContext&, const Deprecated::ScriptValue& key, ExceptionCodeWithMessage&) final;
-
-    RefPtr<IDBRequest> putForCursorUpdate(JSC::ExecState&, JSC::JSValue, JSC::JSValue key, ExceptionCodeWithMessage&);
-    RefPtr<IDBRequest> modernDelete(ScriptExecutionContext&, JSC::JSValue key, ExceptionCodeWithMessage&);
-
-    void markAsDeleted();
-    bool isDeleted() const { return m_deleted; }
-
-    const IDBObjectStoreInfo& info() const { return m_info; }
-
-    // FIXME: After removing LegacyIDB and folding abstract/implementation classes together,
-    // this will no longer be necessary.
-    IDBTransaction& modernTransaction() { return m_transaction.get(); }
-
-    void rollbackInfoForVersionChangeAbort();
-
-    bool isModern() const override { return true; }
-
-    void visitReferencedIndexes(JSC::SlotVisitor&) const;
-
-private:
-    IDBObjectStore(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&);
-
-    enum class InlineKeyCheck {
-        Perform,
-        DoNotPerform,
-    };
-
-    RefPtr<IDBRequest> putOrAdd(JSC::ExecState&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, InlineKeyCheck, ExceptionCodeWithMessage&);
-    RefPtr<WebCore::IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
-    RefPtr<IDBRequest> doDelete(ScriptExecutionContext&, IDBKeyRange*, ExceptionCodeWithMessage&);
-
-    // ActiveDOMObject
-    const char* activeDOMObjectName() const final;
-    bool canSuspendForDocumentSuspension() const final;
-    bool hasPendingActivity() const final;
-
-    IDBObjectStoreInfo m_info;
-    IDBObjectStoreInfo m_originalInfo;
-    Ref<IDBTransaction> m_transaction;
-
-    bool m_deleted { false };
-
-    mutable Lock m_referencedIndexLock;
-    HashMap<String, std::unique_ptr<IDBIndex>> m_referencedIndexes;
-    HashSet<std::unique_ptr<IDBIndex>> m_deletedIndexes;
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBObjectStoreImpl_h
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp
deleted file mode 100644 (file)
index 6cf40fa..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBOpenDBRequestImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBDatabaseImpl.h"
-#include "IDBError.h"
-#include "IDBRequestCompletionEvent.h"
-#include "IDBResultData.h"
-#include "IDBTransactionImpl.h"
-#include "IDBVersionChangeEventImpl.h"
-#include "Logging.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-Ref<IDBOpenDBRequest> IDBOpenDBRequest::createDeleteRequest(IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier)
-{
-    ASSERT(databaseIdentifier.isValid());
-    return adoptRef(*new IDBOpenDBRequest(connection, context, databaseIdentifier, 0, IndexedDB::RequestType::Delete));
-}
-
-Ref<IDBOpenDBRequest> IDBOpenDBRequest::createOpenRequest(IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
-{
-    ASSERT(databaseIdentifier.isValid());
-    return adoptRef(*new IDBOpenDBRequest(connection, context, databaseIdentifier, version, IndexedDB::RequestType::Open));
-}
-    
-IDBOpenDBRequest::IDBOpenDBRequest(IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType)
-    : IDBRequest(connection, context)
-    , m_databaseIdentifier(databaseIdentifier)
-    , m_version(version)
-{
-    m_requestType = requestType;
-}
-
-IDBOpenDBRequest::~IDBOpenDBRequest()
-{
-}
-
-void IDBOpenDBRequest::onError(const IDBResultData& data)
-{
-    m_domError = DOMError::create(data.error().name());
-    enqueueEvent(IDBRequestCompletionEvent::create(eventNames().errorEvent, true, true, *this));
-}
-
-void IDBOpenDBRequest::versionChangeTransactionDidFinish()
-{
-    // 3.3.7 "versionchange" transaction steps
-    // When the transaction is finished, after firing complete/abort on the transaction, immediately set request's transaction property to null.
-    m_shouldExposeTransactionToDOM = false;
-}
-
-void IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit()
-{
-    LOG(IndexedDB, "IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit()");
-
-    ASSERT(hasPendingActivity());
-    ASSERT(m_result);
-    ASSERT(m_result->type() == IDBAny::Type::IDBDatabase);
-    m_transaction->addRequest(*this);
-
-    auto event = IDBRequestCompletionEvent::create(eventNames().successEvent, false, false, *this);
-    m_openDatabaseSuccessEvent = &event.get();
-
-    enqueueEvent(WTFMove(event));
-}
-
-void IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion()
-{
-    LOG(IndexedDB, "IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion()");
-
-    ASSERT(hasPendingActivity());
-
-    IDBError idbError(IDBDatabaseException::AbortError);
-    m_domError = DOMError::create(idbError.name());
-    m_result = IDBAny::createUndefined();
-
-    m_transaction->addRequest(*this);
-    enqueueEvent(IDBRequestCompletionEvent::create(eventNames().errorEvent, true, true, *this));
-}
-
-bool IDBOpenDBRequest::dispatchEvent(Event& event)
-{
-    bool result = IDBRequest::dispatchEvent(event);
-
-    if (m_transaction && m_transaction->isVersionChange() && (event.type() == eventNames().errorEvent || event.type() == eventNames().successEvent))
-        m_transaction->database().serverConnection().didFinishHandlingVersionChangeTransaction(*m_transaction);
-
-    return result;
-}
-
-void IDBOpenDBRequest::onSuccess(const IDBResultData& resultData)
-{
-    LOG(IndexedDB, "IDBOpenDBRequest::onSuccess()");
-
-    if (!scriptExecutionContext())
-        return;
-
-    Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connection(), resultData);
-    m_result = IDBAny::create(WTFMove(database));
-    m_readyState = IDBRequestReadyState::Done;
-
-    enqueueEvent(IDBRequestCompletionEvent::create(eventNames().successEvent, false, false, *this));
-}
-
-void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
-{
-    Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connection(), resultData);
-    Ref<IDBTransaction> transaction = database->startVersionChangeTransaction(resultData.transactionInfo(), *this);
-
-    ASSERT(transaction->info().mode() == IndexedDB::TransactionMode::VersionChange);
-    ASSERT(transaction->originalDatabaseInfo());
-
-    uint64_t oldVersion = transaction->originalDatabaseInfo()->version();
-    uint64_t newVersion = transaction->info().newVersion();
-
-    LOG(IndexedDB, "IDBOpenDBRequest::onUpgradeNeeded() - current version is %" PRIu64 ", new is %" PRIu64, oldVersion, newVersion);
-
-    m_result = IDBAny::create(WTFMove(database));
-    m_readyState = IDBRequestReadyState::Done;
-    m_transaction = adoptRef(&transaction.leakRef());
-    m_transaction->addRequest(*this);
-
-    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, newVersion, eventNames().upgradeneededEvent));
-}
-
-void IDBOpenDBRequest::onDeleteDatabaseSuccess(const IDBResultData& resultData)
-{
-    uint64_t oldVersion = resultData.databaseInfo().version();
-
-    LOG(IndexedDB, "IDBOpenDBRequest::onDeleteDatabaseSuccess() - current version is %" PRIu64, oldVersion);
-
-    m_readyState = IDBRequestReadyState::Done;
-    m_result = IDBAny::createUndefined();
-
-    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, 0, eventNames().successEvent));
-}
-
-void IDBOpenDBRequest::requestCompleted(const IDBResultData& data)
-{
-    LOG(IndexedDB, "IDBOpenDBRequest::requestCompleted");
-
-    // If an Open request was completed after the page has navigated, leaving this request
-    // with a stopped script execution context, we need to message back to the server so it
-    // doesn't hang waiting on a database connection or transaction that will never exist.
-    if (m_contextStopped) {
-        switch (data.type()) {
-        case IDBResultType::OpenDatabaseSuccess:
-            connection().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), IDBResourceIdentifier::emptyValue());
-            break;
-        case IDBResultType::OpenDatabaseUpgradeNeeded:
-            connection().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier());
-            break;
-        default:
-            break;
-        }
-
-        return;
-    }
-
-    switch (data.type()) {
-    case IDBResultType::Error:
-        onError(data);
-        break;
-    case IDBResultType::OpenDatabaseSuccess:
-        onSuccess(data);
-        break;
-    case IDBResultType::OpenDatabaseUpgradeNeeded:
-        onUpgradeNeeded(data);
-        break;
-    case IDBResultType::DeleteDatabaseSuccess:
-        onDeleteDatabaseSuccess(data);
-        break;
-    default:
-        RELEASE_ASSERT_NOT_REACHED();
-    }
-}
-
-void IDBOpenDBRequest::requestBlocked(uint64_t oldVersion, uint64_t newVersion)
-{
-    LOG(IndexedDB, "IDBOpenDBRequest::requestBlocked");
-    enqueueEvent(IDBVersionChangeEvent::create(oldVersion, newVersion, eventNames().blockedEvent));
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.h
deleted file mode 100644 (file)
index da804c1..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBOpenDBRequestImpl_h
-#define IDBOpenDBRequestImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "DOMError.h"
-#include "IDBDatabaseIdentifier.h"
-#include "IDBRequestImpl.h"
-
-namespace WebCore {
-
-class IDBDatabaseIdentifier;
-
-namespace IDBClient {
-
-class IDBConnectionToServer;
-
-class IDBOpenDBRequest : public IDBRequest {
-public:
-    static Ref<IDBOpenDBRequest> createDeleteRequest(IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&);
-    static Ref<IDBOpenDBRequest> createOpenRequest(IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version);
-
-    ~IDBOpenDBRequest() final;
-    
-    const IDBDatabaseIdentifier& databaseIdentifier() const { return m_databaseIdentifier; }
-    uint64_t version() const { return m_version; }
-
-    void requestCompleted(const IDBResultData&);
-    void requestBlocked(uint64_t oldVersion, uint64_t newVersion);
-
-    void versionChangeTransactionDidFinish();
-    void fireSuccessAfterVersionChangeCommit();
-    void fireErrorAfterVersionChangeCompletion();
-
-    bool dispatchEvent(Event&) final;
-
-private:
-    IDBOpenDBRequest(IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType);
-
-    void onError(const IDBResultData&);
-    void onSuccess(const IDBResultData&);
-    void onUpgradeNeeded(const IDBResultData&);
-    void onDeleteDatabaseSuccess(const IDBResultData&);
-
-    bool isOpenDBRequest() const override { return true; }
-
-    IDBDatabaseIdentifier m_databaseIdentifier;
-    uint64_t m_version { 0 };
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBOpenDBRequestImpl_h
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp
deleted file mode 100644 (file)
index d02a742..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBRequestImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "DOMRequestState.h"
-#include "EventQueue.h"
-#include "IDBBindingUtilities.h"
-#include "IDBCursorImpl.h"
-#include "IDBDatabaseException.h"
-#include "IDBEventDispatcher.h"
-#include "IDBKeyData.h"
-#include "IDBResultData.h"
-#include "Logging.h"
-#include "ScriptExecutionContext.h"
-#include "ThreadSafeDataBuffer.h"
-#include <wtf/NeverDestroyed.h>
-
-namespace WebCore {
-namespace IDBClient {
-
-Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction)
-{
-    return adoptRef(*new IDBRequest(context, objectStore, transaction));
-}
-
-Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
-{
-    return adoptRef(*new IDBRequest(context, cursor, transaction));
-}
-
-Ref<IDBRequest> IDBRequest::createCount(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction)
-{
-    return adoptRef(*new IDBRequest(context, index, transaction));
-}
-
-Ref<IDBRequest> IDBRequest::createGet(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType requestedRecordType, IDBTransaction& transaction)
-{
-    return adoptRef(*new IDBRequest(context, index, requestedRecordType, transaction));
-}
-
-IDBRequest::IDBRequest(IDBConnectionToServer& connection, ScriptExecutionContext& context)
-    : IDBOpenDBRequest(context)
-    , m_connection(connection)
-    , m_resourceIdentifier(connection)
-{
-    suspendIfNeeded();
-}
-
-IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction)
-    : IDBOpenDBRequest(context)
-    , m_transaction(&transaction)
-    , m_connection(transaction.serverConnection())
-    , m_resourceIdentifier(transaction.serverConnection())
-    , m_source(IDBAny::create(objectStore))
-{
-    suspendIfNeeded();
-}
-
-IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
-    : IDBOpenDBRequest(context)
-    , m_transaction(&transaction)
-    , m_connection(transaction.serverConnection())
-    , m_resourceIdentifier(transaction.serverConnection())
-    , m_source(cursor.source())
-    , m_pendingCursor(&cursor)
-{
-    suspendIfNeeded();
-
-    cursor.setRequest(*this);
-}
-
-IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction)
-    : IDBOpenDBRequest(context)
-    , m_transaction(&transaction)
-    , m_connection(transaction.serverConnection())
-    , m_resourceIdentifier(transaction.serverConnection())
-    , m_source(IDBAny::create(index))
-{
-    suspendIfNeeded();
-}
-
-IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType requestedRecordType, IDBTransaction& transaction)
-    : IDBRequest(context, index, transaction)
-{
-    m_requestedIndexRecordType = requestedRecordType;
-}
-
-IDBRequest::~IDBRequest()
-{
-    if (m_result) {
-        auto type = m_result->type();
-        if (type == IDBAny::Type::IDBCursor || type == IDBAny::Type::IDBCursorWithValue)
-            m_result->modernIDBCursor()->clearRequest();
-    }
-}
-
-RefPtr<WebCore::IDBAny> IDBRequest::result(ExceptionCodeWithMessage& ec) const
-{
-    if (m_readyState == IDBRequestReadyState::Done)
-        return m_result;
-
-    ec.code = IDBDatabaseException::InvalidStateError;
-    ec.message = ASCIILiteral("Failed to read the 'result' property from 'IDBRequest': The request has not finished.");
-    return nullptr;
-}
-
-unsigned short IDBRequest::errorCode(ExceptionCode&) const
-{
-    return 0;
-}
-
-RefPtr<DOMError> IDBRequest::error(ExceptionCodeWithMessage& ec) const
-{
-    if (m_readyState == IDBRequestReadyState::Done)
-        return m_domError;
-
-    ec.code = IDBDatabaseException::InvalidStateError;
-    ec.message = ASCIILiteral("Failed to read the 'error' property from 'IDBRequest': The request has not finished.");
-    return nullptr;
-}
-
-RefPtr<WebCore::IDBAny> IDBRequest::source() const
-{
-    return m_source;
-}
-
-void IDBRequest::setSource(IDBCursor& cursor)
-{
-    ASSERT(!m_cursorRequestNotifier);
-
-    m_source = IDBAny::create(cursor);
-    m_cursorRequestNotifier = std::make_unique<ScopeGuard>([this]() {
-        ASSERT(m_source->type() == IDBAny::Type::IDBCursor || m_source->type() == IDBAny::Type::IDBCursorWithValue);
-        m_source->modernIDBCursor()->decrementOutstandingRequestCount();
-    });
-}
-
-void IDBRequest::setVersionChangeTransaction(IDBTransaction& transaction)
-{
-    ASSERT(!m_transaction);
-    ASSERT(transaction.isVersionChange());
-    ASSERT(!transaction.isFinishedOrFinishing());
-
-    m_transaction = &transaction;
-}
-
-RefPtr<WebCore::IDBTransaction> IDBRequest::transaction() const
-{
-    return m_shouldExposeTransactionToDOM ? m_transaction : nullptr;
-}
-
-const String& IDBRequest::readyState() const
-{
-    static WTF::NeverDestroyed<String> pendingString("pending");
-    static WTF::NeverDestroyed<String> doneString("done");
-
-    switch (m_readyState) {
-    case IDBRequestReadyState::Pending:
-        return pendingString;
-    case IDBRequestReadyState::Done:
-        return doneString;
-    default:
-        RELEASE_ASSERT_NOT_REACHED();
-    }
-}
-
-uint64_t IDBRequest::sourceObjectStoreIdentifier() const
-{
-    if (!m_source)
-        return 0;
-
-    if (m_source->type() == IDBAny::Type::IDBObjectStore) {
-        auto* objectStore = m_source->modernIDBObjectStore();
-        if (!objectStore)
-            return 0;
-        return objectStore->info().identifier();
-    }
-
-    if (m_source->type() == IDBAny::Type::IDBIndex) {
-        auto* index = m_source->modernIDBIndex();
-        if (!index)
-            return 0;
-        return index->info().objectStoreIdentifier();
-    }
-
-    return 0;
-}
-
-uint64_t IDBRequest::sourceIndexIdentifier() const
-{
-    if (!m_source)
-        return 0;
-    if (m_source->type() != IDBAny::Type::IDBIndex)
-        return 0;
-    if (!m_source->modernIDBIndex())
-        return 0;
-
-    return m_source->modernIDBIndex()->info().identifier();
-}
-
-IndexedDB::IndexRecordType IDBRequest::requestedIndexRecordType() const
-{
-    ASSERT(m_source);
-    ASSERT(m_source->type() == IDBAny::Type::IDBIndex);
-
-    return m_requestedIndexRecordType;
-}
-
-EventTargetInterface IDBRequest::eventTargetInterface() const
-{
-    return IDBRequestEventTargetInterfaceType;
-}
-
-const char* IDBRequest::activeDOMObjectName() const
-{
-    return "IDBRequest";
-}
-
-bool IDBRequest::canSuspendForDocumentSuspension() const
-{
-    return false;
-}
-
-bool IDBRequest::hasPendingActivity() const
-{
-    return m_hasPendingActivity;
-}
-
-void IDBRequest::stop()
-{
-    ASSERT(!m_contextStopped);
-    m_contextStopped = true;
-}
-
-void IDBRequest::enqueueEvent(Ref<Event>&& event)
-{
-    if (!scriptExecutionContext() || m_contextStopped)
-        return;
-
-    event->setTarget(this);
-    scriptExecutionContext()->eventQueue().enqueueEvent(WTFMove(event));
-}
-
-bool IDBRequest::dispatchEvent(Event& event)
-{
-    LOG(IndexedDB, "IDBRequest::dispatchEvent - %s (%p)", event.type().string().utf8().data(), this);
-
-    ASSERT(m_hasPendingActivity);
-    ASSERT(!m_contextStopped);
-
-    if (event.type() != eventNames().blockedEvent)
-        m_readyState = IDBRequestReadyState::Done;
-
-    Vector<RefPtr<EventTarget>> targets;
-    targets.append(this);
-
-    if (&event == m_openDatabaseSuccessEvent)
-        m_openDatabaseSuccessEvent = nullptr;
-    else if (m_transaction && !m_transaction->isFinished()) {
-            targets.append(m_transaction);
-            targets.append(m_transaction->db());
-    }
-
-    m_hasPendingActivity = false;
-
-    m_cursorRequestNotifier = nullptr;
-
-    bool dontPreventDefault;
-    {
-        TransactionActivator activator(m_transaction.get());
-        dontPreventDefault = IDBEventDispatcher::dispatch(event, targets);
-    }
-
-    // IDBEventDispatcher::dispatch() might have set the pending activity flag back to true, suggesting the request will be reused.
-    // We might also re-use the request if this event was the upgradeneeded event for an IDBOpenDBRequest.
-    if (!m_hasPendingActivity)
-        m_hasPendingActivity = isOpenDBRequest() && (event.type() == eventNames().upgradeneededEvent || event.type() == eventNames().blockedEvent);
-
-    // The request should only remain in the transaction's request list if it represents a pending cursor operation, or this is an open request that was blocked.
-    if (m_transaction && !m_pendingCursor && event.type() != eventNames().blockedEvent)
-        m_transaction->removeRequest(*this);
-
-    if (dontPreventDefault && event.type() == eventNames().errorEvent && m_transaction && !m_transaction->isFinishedOrFinishing()) {
-        ASSERT(m_domError);
-        m_transaction->abortDueToFailedRequest(*m_domError);
-    }
-
-    return dontPreventDefault;
-}
-
-void IDBRequest::uncaughtExceptionInEventHandler()
-{
-    LOG(IndexedDB, "IDBRequest::uncaughtExceptionInEventHandler");
-
-    if (m_transaction && m_idbError.code() != IDBDatabaseException::AbortError)
-        m_transaction->abortDueToFailedRequest(DOMError::create(IDBDatabaseException::getErrorName(IDBDatabaseException::AbortError)));
-}
-
-void IDBRequest::setResult(const IDBKeyData* keyData)
-{
-    if (!keyData) {
-        m_result = nullptr;
-        return;
-    }
-
-    Deprecated::ScriptValue value = idbKeyDataToScriptValue(scriptExecutionContext(), *keyData);
-    m_result = IDBAny::create(WTFMove(value));
-}
-
-void IDBRequest::setResult(uint64_t number)
-{
-    ASSERT(scriptExecutionContext());
-    m_result = IDBAny::create(Deprecated::ScriptValue(scriptExecutionContext()->vm(), JSC::JSValue(number)));
-}
-
-void IDBRequest::setResultToStructuredClone(const ThreadSafeDataBuffer& valueData)
-{
-    LOG(IndexedDB, "IDBRequest::setResultToStructuredClone");
-
-    auto context = scriptExecutionContext();
-    if (!context)
-        return;
-
-    Deprecated::ScriptValue value = deserializeIDBValueData(*context, valueData);
-    m_result = IDBAny::create(WTFMove(value));
-}
-
-void IDBRequest::setResultToUndefined()
-{
-    m_result = IDBAny::createUndefined();
-}
-
-IDBCursor* IDBRequest::resultCursor()
-{
-    if (!m_result)
-        return nullptr;
-    if (m_result->type() == IDBAny::Type::IDBCursor || m_result->type() == IDBAny::Type::IDBCursorWithValue)
-        return m_result->modernIDBCursor();
-    return nullptr;
-}
-
-void IDBRequest::willIterateCursor(IDBCursor& cursor)
-{
-    ASSERT(m_readyState == IDBRequestReadyState::Done);
-    ASSERT(scriptExecutionContext());
-    ASSERT(m_transaction);
-    ASSERT(!m_pendingCursor);
-    ASSERT(&cursor == resultCursor());
-    ASSERT(!m_cursorRequestNotifier);
-
-    m_pendingCursor = &cursor;
-    m_hasPendingActivity = true;
-    m_result = nullptr;
-    m_readyState = IDBRequestReadyState::Pending;
-    m_domError = nullptr;
-    m_idbError = { };
-
-    m_cursorRequestNotifier = std::make_unique<ScopeGuard>([this]() {
-        m_pendingCursor->decrementOutstandingRequestCount();
-    });
-}
-
-void IDBRequest::didOpenOrIterateCursor(const IDBResultData& resultData)
-{
-    ASSERT(m_pendingCursor);
-    m_result = nullptr;
-
-    if (resultData.type() == IDBResultType::IterateCursorSuccess || resultData.type() == IDBResultType::OpenCursorSuccess) {
-        m_pendingCursor->setGetResult(*this, resultData.getResult());
-        if (resultData.getResult().isDefined())
-            m_result = IDBAny::create(*m_pendingCursor);
-    }
-
-    m_cursorRequestNotifier = nullptr;
-    m_pendingCursor = nullptr;
-
-    requestCompleted(resultData);
-}
-
-void IDBRequest::requestCompleted(const IDBResultData& resultData)
-{
-    m_readyState = IDBRequestReadyState::Done;
-
-    m_idbError = resultData.error();
-    if (!m_idbError.isNull())
-        onError();
-    else
-        onSuccess();
-}
-
-void IDBRequest::onError()
-{
-    LOG(IndexedDB, "IDBRequest::onError");
-
-    ASSERT(!m_idbError.isNull());
-    m_domError = DOMError::create(m_idbError.name());
-    enqueueEvent(Event::create(eventNames().errorEvent, true, true));
-}
-
-void IDBRequest::onSuccess()
-{
-    LOG(IndexedDB, "IDBRequest::onSuccess");
-
-    enqueueEvent(Event::create(eventNames().successEvent, false, false));
-}
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h b/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h
deleted file mode 100644 (file)
index 555913c..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBRequestImpl_h
-#define IDBRequestImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBAnyImpl.h"
-#include "IDBOpenDBRequest.h"
-#include "IDBResourceIdentifier.h"
-#include "IDBTransactionImpl.h"
-#include "ScopeGuard.h"
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class Event;
-class IDBKeyData;
-class IDBResultData;
-class ThreadSafeDataBuffer;
-
-namespace IndexedDB {
-enum class IndexRecordType;
-}
-
-namespace IDBClient {
-
-class IDBConnectionToServer;
-
-class IDBRequest : public WebCore::IDBOpenDBRequest, public RefCounted<IDBRequest> {
-public:
-    static Ref<IDBRequest> create(ScriptExecutionContext&, IDBObjectStore&, IDBTransaction&);
-    static Ref<IDBRequest> create(ScriptExecutionContext&, IDBCursor&, IDBTransaction&);
-    static Ref<IDBRequest> createCount(ScriptExecutionContext&, IDBIndex&, IDBTransaction&);
-    static Ref<IDBRequest> createGet(ScriptExecutionContext&, IDBIndex&, IndexedDB::IndexRecordType, IDBTransaction&);
-
-    const IDBResourceIdentifier& resourceIdentifier() const { return m_resourceIdentifier; }
-
-    ~IDBRequest() override;
-
-    RefPtr<WebCore::IDBAny> result(ExceptionCodeWithMessage&) const override;
-    unsigned short errorCode(ExceptionCode&) const override;
-    RefPtr<DOMError> error(ExceptionCodeWithMessage&) const override;
-    RefPtr<WebCore::IDBAny> source() const override;
-    RefPtr<WebCore::IDBTransaction> transaction() const override;
-    const String& readyState() const override;
-
-    uint64_t sourceObjectStoreIdentifier() const;
-    uint64_t sourceIndexIdentifier() const;
-    IndexedDB::IndexRecordType requestedIndexRecordType() const;
-
-    // EventTarget
-    EventTargetInterface eventTargetInterface() const override;
-    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
-
-    using RefCounted<IDBRequest>::ref;
-    using RefCounted<IDBRequest>::deref;
-
-    void enqueueEvent(Ref<Event>&&);
-    bool dispatchEvent(Event&) override;
-
-    IDBConnectionToServer& connection() { return m_connection; }
-
-    void requestCompleted(const IDBResultData&);
-
-    void setResult(const IDBKeyData*);
-    void setResult(uint64_t);
-    void setResultToStructuredClone(const ThreadSafeDataBuffer&);
-    void setResultToUndefined();
-
-    IDBAny* modernResult() { return m_result.get(); }
-
-    void willIterateCursor(IDBCursor&);
-    void didOpenOrIterateCursor(const IDBResultData&);
-
-    const IDBCursor* pendingCursor() const { return m_pendingCursor.get(); }
-
-    void setSource(IDBCursor&);
-    void setVersionChangeTransaction(IDBTransaction&);
-
-    IndexedDB::RequestType requestType() const { return m_requestType; }
-
-protected:
-    IDBRequest(IDBConnectionToServer&, ScriptExecutionContext&);
-    IDBRequest(ScriptExecutionContext&, IDBObjectStore&, IDBTransaction&);
-    IDBRequest(ScriptExecutionContext&, IDBCursor&, IDBTransaction&);
-    IDBRequest(ScriptExecutionContext&, IDBIndex&, IDBTransaction&);
-    IDBRequest(ScriptExecutionContext&, IDBIndex&, IndexedDB::IndexRecordType, IDBTransaction&);
-
-    // ActiveDOMObject.
-    const char* activeDOMObjectName() const final;
-    bool canSuspendForDocumentSuspension() const final;
-    bool hasPendingActivity() const final;
-    void stop() final;
-
-    // EventTarget.
-    void refEventTarget() final { RefCounted<IDBRequest>::ref(); }
-    void derefEventTarget() final { RefCounted<IDBRequest>::deref(); }
-    void uncaughtExceptionInEventHandler() final;
-
-    virtual bool isOpenDBRequest() const { return false; }
-
-    IDBRequestReadyState m_readyState { IDBRequestReadyState::Pending };
-    RefPtr<IDBAny> m_result;
-    RefPtr<IDBTransaction> m_transaction;
-    bool m_shouldExposeTransactionToDOM { true };
-    RefPtr<DOMError> m_domError;
-    IDBError m_idbError;
-    IndexedDB::RequestType m_requestType = { IndexedDB::RequestType::Other };
-    bool m_contextStopped { false };
-
-    Event* m_openDatabaseSuccessEvent { nullptr };
-
-private:
-    void onError();
-    void onSuccess();
-
-    IDBCursor* resultCursor();
-
-    IDBConnectionToServer& m_connection;
-    IDBResourceIdentifier m_resourceIdentifier;
-    RefPtr<IDBAny> m_source;
-    bool m_hasPendingActivity { true };
-    IndexedDB::IndexRecordType m_requestedIndexRecordType;
-
-    RefPtr<IDBCursor> m_pendingCursor;
-
-    std::unique_ptr<ScopeGuard> m_cursorRequestNotifier;
-};
-
-} // namespace IDBClient
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBRequestImpl_h
diff --git a/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp b/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp
deleted file mode 100644 (file)
index f64ccf9..0000000
+++ /dev/null
@@ -1,907 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBTransactionImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "DOMError.h"
-#include "EventQueue.h"
-#include "IDBCursorWithValueImpl.h"
-#include "IDBDatabaseException.h"
-#include "IDBDatabaseImpl.h"
-#include "IDBError.h"
-#include "IDBEventDispatcher.h"
-#include "IDBKeyData.h"
-#include "IDBKeyRangeData.h"
-#include "IDBObjectStore.h"
-#include "IDBOpenDBRequestImpl.h"
-#include "IDBRequestImpl.h"
-#include "IDBResultData.h"
-#include "JSDOMWindowBase.h"
-#include "Logging.h"
-#include "ScriptExecutionContext.h"
-#include "TransactionOperation.h"
-
-namespace WebCore {
-namespace IDBClient {
-
-Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info)
-{
-    return adoptRef(*new IDBTransaction(database, info, nullptr));
-}
-
-Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info, IDBOpenDBRequest& request)
-{
-    return adoptRef(*new IDBTransaction(database, info, &request));
-}
-
-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();
-}
-
-IDBTransaction::~IDBTransaction()
-{
-}
-
-const String& IDBTransaction::mode() const
-{
-    switch (m_info.mode()) {
-    case IndexedDB::TransactionMode::ReadOnly:
-        return IDBTransaction::modeReadOnly();
-    case IndexedDB::TransactionMode::ReadWrite:
-        return IDBTransaction::modeReadWrite();
-    case IndexedDB::TransactionMode::VersionChange:
-        return IDBTransaction::modeVersionChange();
-    }
-
-    RELEASE_ASSERT_NOT_REACHED();
-}
-
-WebCore::IDBDatabase* IDBTransaction::db()
-{
-    return &m_database.get();
-}
-
-IDBConnectionToServer& IDBTransaction::serverConnection()
-{
-    return m_database->serverConnection();
-}
-
-RefPtr<DOMError> IDBTransaction::error() const
-{
-    return m_domError;
-}
-
-RefPtr<WebCore::IDBObjectStore> IDBTransaction::objectStore(const String& objectStoreName, ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBTransaction::objectStore");
-
-    if (!scriptExecutionContext())
-        return nullptr;
-
-    if (isFinishedOrFinishing()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'objectStore' on 'IDBTransaction': The transaction finished.");
-        return nullptr;
-    }
-
-    auto iterator = m_referencedObjectStores.find(objectStoreName);
-    if (iterator != m_referencedObjectStores.end())
-        return iterator->value;
-
-    bool found = false;
-    for (auto& objectStore : m_info.objectStores()) {
-        if (objectStore == objectStoreName) {
-            found = true;
-            break;
-        }
-    }
-
-    auto* info = m_database->info().infoForExistingObjectStore(objectStoreName);
-    if (!info) {
-        ec.code = IDBDatabaseException::NotFoundError;
-        ec.message = ASCIILiteral("Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.");
-        return nullptr;
-    }
-
-    // Version change transactions are scoped to every object store in the database.
-    if (!info || (!found && !isVersionChange())) {
-        ec.code = IDBDatabaseException::NotFoundError;
-        ec.message = ASCIILiteral("Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.");
-        return nullptr;
-    }
-
-    auto objectStore = IDBObjectStore::create(*scriptExecutionContext(), *info, *this);
-    m_referencedObjectStores.set(objectStoreName, &objectStore.get());
-
-    return adoptRef(&objectStore.leakRef());
-}
-
-
-void IDBTransaction::abortDueToFailedRequest(DOMError& error)
-{
-    LOG(IndexedDB, "IDBTransaction::abortDueToFailedRequest");
-    if (isFinishedOrFinishing())
-        return;
-
-    m_domError = &error;
-    ExceptionCodeWithMessage ec;
-    abort(ec);
-}
-
-void IDBTransaction::transitionedToFinishing(IndexedDB::TransactionState state)
-{
-    ASSERT(!isFinishedOrFinishing());
-    m_state = state;
-    ASSERT(isFinishedOrFinishing());
-    m_referencedObjectStores.clear();
-}
-
-void IDBTransaction::abort(ExceptionCodeWithMessage& ec)
-{
-    LOG(IndexedDB, "IDBTransaction::abort");
-
-    if (isFinishedOrFinishing()) {
-        ec.code = IDBDatabaseException::InvalidStateError;
-        ec.message = ASCIILiteral("Failed to execute 'abort' on 'IDBTransaction': The transaction is inactive or finished.");
-        return;
-    }
-
-    m_database->willAbortTransaction(*this);
-
-    if (isVersionChange()) {
-        for (auto& objectStore : m_referencedObjectStores.values())
-            objectStore->rollbackInfoForVersionChangeAbort();
-    }
-
-    transitionedToFinishing(IndexedDB::TransactionState::Aborting);
-    
-    m_abortQueue.swap(m_transactionOperationQueue);
-
-    auto operation = createTransactionOperation(*this, nullptr, &IDBTransaction::abortOnServerAndCancelRequests);
-    scheduleOperation(WTFMove(operation));
-}
-
-void IDBTransaction::abortOnServerAndCancelRequests(TransactionOperation& operation)
-{
-    LOG(IndexedDB, "IDBTransaction::abortOnServerAndCancelRequests");
-
-    ASSERT(m_transactionOperationQueue.isEmpty());
-
-    serverConnection().abortTransaction(*this);
-
-    ASSERT(m_transactionOperationMap.contains(operation.identifier()));
-    m_transactionOperationMap.remove(operation.identifier());
-
-    IDBError error(IDBDatabaseException::AbortError);
-    for (auto& operation : m_abortQueue)
-        operation->completed(IDBResultData::error(operation->identifier(), error));
-
-    // Since we're aborting, it should be impossible to have queued any further operations.
-    ASSERT(m_transactionOperationQueue.isEmpty());
-}
-
-const char* IDBTransaction::activeDOMObjectName() const
-{
-    return "IDBTransaction";
-}
-
-bool IDBTransaction::canSuspendForDocumentSuspension() const
-{
-    return false;
-}
-
-bool IDBTransaction::hasPendingActivity() const
-{
-    return !m_contextStopped && m_state != IndexedDB::TransactionState::Finished;
-}
-
-void IDBTransaction::stop()
-{
-    LOG(IndexedDB, "IDBTransaction::stop");
-
-    // IDBDatabase::stop() calls IDBTransaction::stop() for each of its active transactions.
-    // Since the order of calling ActiveDOMObject::stop() is random, we might already have been stopped.
-    if (m_contextStopped)
-        return;
-
-    m_contextStopped = true;
-
-    if (isFinishedOrFinishing())
-        return;
-
-    ExceptionCodeWithMessage ec;
-    abort(ec);
-}
-
-bool IDBTransaction::isActive() const
-{
-    return m_state == IndexedDB::TransactionState::Active;
-}
-
-bool IDBTransaction::isFinishedOrFinishing() const
-{
-    return m_state == IndexedDB::TransactionState::Committing
-        || m_state == IndexedDB::TransactionState::Aborting
-        || m_state == IndexedDB::TransactionState::Finished;
-}
-
-void IDBTransaction::addRequest(IDBRequest& request)
-{
-    m_openRequests.add(&request);
-}
-
-void IDBTransaction::removeRequest(IDBRequest& request)
-{
-    ASSERT(m_openRequests.contains(&request));
-    m_openRequests.remove(&request);
-}
-
-void IDBTransaction::scheduleOperation(RefPtr<TransactionOperation>&& operation)
-{
-    ASSERT(!m_transactionOperationMap.contains(operation->identifier()));
-
-    m_transactionOperationQueue.append(operation);
-    m_transactionOperationMap.set(operation->identifier(), WTFMove(operation));
-
-    scheduleOperationTimer();
-}
-
-void IDBTransaction::scheduleOperationTimer()
-{
-    if (!m_operationTimer.isActive())
-        m_operationTimer.startOneShot(0);
-}
-
-void IDBTransaction::operationTimerFired()
-{
-    LOG(IndexedDB, "IDBTransaction::operationTimerFired (%p)", this);
-
-    if (!m_startedOnServer)
-        return;
-
-    if (!m_transactionOperationQueue.isEmpty()) {
-        auto operation = m_transactionOperationQueue.takeFirst();
-        operation->perform();
-
-        return;
-    }
-
-    if (!m_transactionOperationMap.isEmpty() || !m_openRequests.isEmpty())
-        return;
-
-    if (!isFinishedOrFinishing())
-        commit();
-}
-
-void IDBTransaction::commit()
-{
-    LOG(IndexedDB, "IDBTransaction::commit");
-
-    ASSERT(!isFinishedOrFinishing());
-
-    transitionedToFinishing(IndexedDB::TransactionState::Committing);
-    m_database->willCommitTransaction(*this);
-
-    auto operation = createTransactionOperation(*this, nullptr, &IDBTransaction::commitOnServer);
-    scheduleOperation(WTFMove(operation));
-}
-
-void IDBTransaction::commitOnServer(TransactionOperation& operation)
-{
-    LOG(IndexedDB, "IDBTransaction::commitOnServer");
-    serverConnection().commitTransaction(*this);
-
-    ASSERT(m_transactionOperationMap.contains(operation.identifier()));
-    m_transactionOperationMap.remove(operation.identifier());
-}
-
-void IDBTransaction::finishAbortOrCommit()
-{
-    ASSERT(m_state != IndexedDB::TransactionState::Finished);
-    m_state = IndexedDB::TransactionState::Finished;
-}
-
-void IDBTransaction::didStart(const IDBError& error)
-{
-    LOG(IndexedDB, "IDBTransaction::didStart");
-
-    m_database->didStartTransaction(*this);
-
-    m_startedOnServer = true;
-
-    // It's possible the transaction failed to start on the server.
-    // That equates to an abort.
-    if (!error.isNull()) {
-        didAbort(error);
-        return;
-    }
-
-    scheduleOperationTimer();
-}
-
-void IDBTransaction::notifyDidAbort(const IDBError& error)
-{
-    m_database->didAbortTransaction(*this);
-    m_idbError = error;
-    fireOnAbort();
-
-    if (isVersionChange()) {
-        ASSERT(m_openDBRequest);
-        m_openDBRequest->fireErrorAfterVersionChangeCompletion();
-    }
-}
-
-void IDBTransaction::didAbort(const IDBError& error)
-{
-    LOG(IndexedDB, "IDBTransaction::didAbort");
-
-    if (m_state == IndexedDB::TransactionState::Finished)
-        return;
-
-    notifyDidAbort(error);
-
-    finishAbortOrCommit();
-}
-
-void IDBTransaction::didCommit(const IDBError& error)
-{
-    LOG(IndexedDB, "IDBTransaction::didCommit");
-
-    ASSERT(m_state == IndexedDB::TransactionState::Committing);
-
-    if (error.isNull()) {
-        m_database->didCommitTransaction(*this);
-        fireOnComplete();
-    } else {
-        m_database->willAbortTransaction(*this);
-        notifyDidAbort(error);
-    }
-
-    finishAbortOrCommit();
-}
-
-void IDBTransaction::fireOnComplete()
-{
-    LOG(IndexedDB, "IDBTransaction::fireOnComplete");
-    enqueueEvent(Event::create(eventNames().completeEvent, false, false));
-}
-
-void IDBTransaction::fireOnAbort()
-{
-    LOG(IndexedDB, "IDBTransaction::fireOnAbort");
-    enqueueEvent(Event::create(eventNames().abortEvent, true, false));
-}
-
-void IDBTransaction::enqueueEvent(Ref<Event>&& event)
-{
-    ASSERT(m_state != IndexedDB::TransactionState::Finished);
-
-    if (!scriptExecutionContext() || m_contextStopped)
-        return;
-
-    event->setTarget(this);
-    scriptExecutionContext()->eventQueue().enqueueEvent(WTFMove(event));
-}
-
-bool IDBTransaction::dispatchEvent(Event& event)
-{
-    LOG(IndexedDB, "IDBTransaction::dispatchEvent");
-
-    ASSERT(scriptExecutionContext());
-    ASSERT(!m_contextStopped);
-    ASSERT(event.target() == this);
-    ASSERT(event.type() == eventNames().completeEvent || event.type() == eventNames().abortEvent);
-
-    Vector<RefPtr<EventTarget>> targets;
-    targets.append(this);
-    targets.append(db());
-
-    bool result = IDBEventDispatcher::dispatch(event, targets);
-
-    if (isVersionChange()) {
-        ASSERT(m_openDBRequest);
-        m_openDBRequest->versionChangeTransactionDidFinish();
-
-        if (event.type() == eventNames().completeEvent) {
-            if (m_database->isClosingOrClosed())
-                m_openDBRequest->fireErrorAfterVersionChangeCompletion();
-            else
-                m_openDBRequest->fireSuccessAfterVersionChangeCommit();
-        }
-
-        m_openDBRequest = nullptr;
-    }
-
-    return result;
-}
-
-Ref<IDBObjectStore> IDBTransaction::createObjectStore(const IDBObjectStoreInfo& info)
<