Use lambdas instead of member pointer functions for TransactionOperationImpl
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Jan 2019 16:39:47 +0000 (16:39 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Jan 2019 16:39:47 +0000 (16:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193933

Reviewed by Tim Horton.

No change in behavior.  This just makes it easier to add new parameters to these functions in a straightforward manner.

* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::putOrAdd):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::internalAbort):
(WebCore::IDBTransaction::commit):
(WebCore::IDBTransaction::createObjectStore):
(WebCore::IDBTransaction::renameObjectStore):
(WebCore::IDBTransaction::createIndex):
(WebCore::IDBTransaction::renameIndex):
(WebCore::IDBTransaction::doRequestOpenCursor):
(WebCore::IDBTransaction::iterateCursor):
(WebCore::IDBTransaction::requestGetAllObjectStoreRecords):
(WebCore::IDBTransaction::requestGetAllIndexRecords):
(WebCore::IDBTransaction::requestGetRecord):
(WebCore::IDBTransaction::requestIndexRecord):
(WebCore::IDBTransaction::requestCount):
(WebCore::IDBTransaction::requestDeleteRecord):
(WebCore::IDBTransaction::requestClearObjectStore):
(WebCore::IDBTransaction::requestPutOrAdd):
(WebCore::IDBTransaction::deleteObjectStore):
(WebCore::IDBTransaction::deleteIndex):
* Modules/indexeddb/IDBTransaction.h:
* Modules/indexeddb/client/TransactionOperation.h:
(WebCore::IDBClient::TransactionOperation::doComplete):
(WebCore::IDBClient::createTransactionOperation): Deleted.

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/indexeddb/client/TransactionOperation.h

index 0c1fd2c..fe06edf 100644 (file)
@@ -1,3 +1,39 @@
+
+2019-01-29  Alex Christensen  <achristensen@webkit.org>
+
+        Use lambdas instead of member pointer functions for TransactionOperationImpl
+        https://bugs.webkit.org/show_bug.cgi?id=193933
+
+        Reviewed by Tim Horton.
+
+        No change in behavior.  This just makes it easier to add new parameters to these functions in a straightforward manner.
+
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::putOrAdd):
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::internalAbort):
+        (WebCore::IDBTransaction::commit):
+        (WebCore::IDBTransaction::createObjectStore):
+        (WebCore::IDBTransaction::renameObjectStore):
+        (WebCore::IDBTransaction::createIndex):
+        (WebCore::IDBTransaction::renameIndex):
+        (WebCore::IDBTransaction::doRequestOpenCursor):
+        (WebCore::IDBTransaction::iterateCursor):
+        (WebCore::IDBTransaction::requestGetAllObjectStoreRecords):
+        (WebCore::IDBTransaction::requestGetAllIndexRecords):
+        (WebCore::IDBTransaction::requestGetRecord):
+        (WebCore::IDBTransaction::requestIndexRecord):
+        (WebCore::IDBTransaction::requestCount):
+        (WebCore::IDBTransaction::requestDeleteRecord):
+        (WebCore::IDBTransaction::requestClearObjectStore):
+        (WebCore::IDBTransaction::requestPutOrAdd):
+        (WebCore::IDBTransaction::deleteObjectStore):
+        (WebCore::IDBTransaction::deleteIndex):
+        * Modules/indexeddb/IDBTransaction.h:
+        * Modules/indexeddb/client/TransactionOperation.h:
+        (WebCore::IDBClient::TransactionOperation::doComplete):
+        (WebCore::IDBClient::createTransactionOperation): Deleted.
+
 2019-01-29  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][BFC][MarginCollapsing] Remove incorrect downcast<Container>
index 66cec0c..b96cfd0 100644 (file)
@@ -357,7 +357,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::putOrAdd(ExecState& state, JSValue
     } else if (!usesKeyGenerator && !key)
         return Exception { DataError, "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."_s };
 
-    return m_transaction.requestPutOrAdd(state, *this, key.get(), *serializedValue, overwriteMode);
+    return m_transaction.requestPutOrAdd(state, *this, WTFMove(key), *serializedValue, overwriteMode);
 }
 
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::deleteFunction(ExecState& execState, IDBKeyRange* keyRange)
index b2f650f..2e965e9 100644 (file)
@@ -246,7 +246,9 @@ void IDBTransaction::internalAbort()
     m_abortQueue.swap(m_pendingTransactionOperationQueue);
 
     LOG(IndexedDBOperations, "IDB abort-on-server operation: Transaction %s", info().identifier().loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, nullptr, &IDBTransaction::abortOnServerAndCancelRequests));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, nullptr, [protectedThis = makeRef(*this)] (auto& operation) {
+        protectedThis->abortOnServerAndCancelRequests(operation);
+    }));
 }
 
 void IDBTransaction::abortInProgressOperations(const IDBError& error)
@@ -501,7 +503,9 @@ void IDBTransaction::commit()
     m_database->willCommitTransaction(*this);
 
     LOG(IndexedDBOperations, "IDB commit operation: Transaction %s", info().identifier().loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, nullptr, &IDBTransaction::commitOnServer));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, nullptr, [protectedThis = makeRef(*this)] (auto& operation) {
+        protectedThis->commitOnServer(operation);
+    }));
 }
 
 void IDBTransaction::commitOnServer(IDBClient::TransactionOperation& operation)
@@ -659,7 +663,11 @@ Ref<IDBObjectStore> IDBTransaction::createObjectStore(const IDBObjectStoreInfo&
     m_referencedObjectStores.set(info.name(), WTFMove(objectStore));
 
     LOG(IndexedDBOperations, "IDB create object store operation: %s", info.condensedLoggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didCreateObjectStoreOnServer, &IDBTransaction::createObjectStoreOnServer, info));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
+        protectedThis->didCreateObjectStoreOnServer(result);
+    }, [protectedThis = makeRef(*this), info = info.isolatedCopy()] (auto& operation) {
+        protectedThis->createObjectStoreOnServer(operation, info);
+    }));
 
     return *rawObjectStore;
 }
@@ -697,7 +705,11 @@ void IDBTransaction::renameObjectStore(IDBObjectStore& objectStore, const String
     uint64_t objectStoreIdentifier = objectStore.info().identifier();
 
     LOG(IndexedDBOperations, "IDB rename object store operation: %s to %s", objectStore.info().condensedLoggingString().utf8().data(), newName.utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didRenameObjectStoreOnServer, &IDBTransaction::renameObjectStoreOnServer, objectStoreIdentifier, newName));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
+        protectedThis->didRenameObjectStoreOnServer(result);
+    }, [protectedThis = makeRef(*this), objectStoreIdentifier, newName = newName.isolatedCopy()] (auto& operation) {
+        protectedThis->renameObjectStoreOnServer(operation, objectStoreIdentifier, newName);
+    }));
 
     m_referencedObjectStores.set(newName, m_referencedObjectStores.take(objectStore.info().name()));
 }
@@ -728,7 +740,11 @@ std::unique_ptr<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStor
         return nullptr;
 
     LOG(IndexedDBOperations, "IDB create index operation: %s under object store %s", info.condensedLoggingString().utf8().data(), objectStore.info().condensedLoggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didCreateIndexOnServer, &IDBTransaction::createIndexOnServer, info));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
+        protectedThis->didCreateIndexOnServer(result);
+    }, [protectedThis = makeRef(*this), info = info.isolatedCopy()] (auto& operation) {
+        protectedThis->createIndexOnServer(operation, info);
+    }));
 
     return std::make_unique<IDBIndex>(*scriptExecutionContext(), info, objectStore);
 }
@@ -778,7 +794,11 @@ void IDBTransaction::renameIndex(IDBIndex& index, const String& newName)
     uint64_t indexIdentifier = index.info().identifier();
 
     LOG(IndexedDBOperations, "IDB rename index operation: %s to %s under object store %" PRIu64, index.info().condensedLoggingString().utf8().data(), newName.utf8().data(), index.info().objectStoreIdentifier());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didRenameIndexOnServer, &IDBTransaction::renameIndexOnServer, objectStoreIdentifier, indexIdentifier, newName));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
+        protectedThis->didRenameIndexOnServer(result);
+    }, [protectedThis = makeRef(*this), objectStoreIdentifier, indexIdentifier, newName = newName.isolatedCopy()] (auto& operation) {
+        protectedThis->renameIndexOnServer(operation, objectStoreIdentifier, indexIdentifier, newName);
+    }));
 }
 
 void IDBTransaction::renameIndexOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const uint64_t& indexIdentifier, const String& newName)
@@ -830,7 +850,11 @@ Ref<IDBRequest> IDBTransaction::doRequestOpenCursor(ExecState& state, Ref<IDBCur
     addRequest(request.get());
 
     LOG(IndexedDBOperations, "IDB open cursor operation: %s", cursor->info().loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didOpenCursorOnServer, &IDBTransaction::openCursorOnServer, cursor->info()));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didOpenCursorOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), info = cursor->info().isolatedCopy()] (auto& operation) {
+        protectedThis->openCursorOnServer(operation, info);
+    }));
 
     return request;
 }
@@ -861,7 +885,11 @@ void IDBTransaction::iterateCursor(IDBCursor& cursor, const IDBIterateCursorData
     addRequest(*cursor.request());
 
     LOG(IndexedDBOperations, "IDB iterate cursor operation: %s %s", cursor.info().loggingString().utf8().data(), data.loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, *cursor.request(), &IDBTransaction::didIterateCursorOnServer, &IDBTransaction::iterateCursorOnServer, data));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, *cursor.request(), [protectedThis = makeRef(*this), request = makeRef(*cursor.request())] (const auto& result) {
+        protectedThis->didIterateCursorOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), data = data.isolatedCopy()] (auto& operation) {
+        protectedThis->iterateCursorOnServer(operation, data);
+    }));
 }
 
 // FIXME: changes here
@@ -895,7 +923,11 @@ Ref<IDBRequest> IDBTransaction::requestGetAllObjectStoreRecords(JSC::ExecState&
     IDBGetAllRecordsData getAllRecordsData { keyRangeData, getAllType, count, objectStore.info().identifier(), 0 };
 
     LOG(IndexedDBOperations, "IDB get all object store records operation: %s", getAllRecordsData.loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetAllRecordsOnServer, &IDBTransaction::getAllRecordsOnServer, getAllRecordsData));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didGetAllRecordsOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), getAllRecordsData = getAllRecordsData.isolatedCopy()] (auto& operation) {
+        protectedThis->getAllRecordsOnServer(operation, getAllRecordsData);
+    }));
 
     return request;
 }
@@ -914,7 +946,11 @@ Ref<IDBRequest> IDBTransaction::requestGetAllIndexRecords(JSC::ExecState& state,
     IDBGetAllRecordsData getAllRecordsData { keyRangeData, getAllType, count, index.objectStore().info().identifier(), index.info().identifier() };
 
     LOG(IndexedDBOperations, "IDB get all index records operation: %s", getAllRecordsData.loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetAllRecordsOnServer, &IDBTransaction::getAllRecordsOnServer, getAllRecordsData));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didGetAllRecordsOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), getAllRecordsData = getAllRecordsData.isolatedCopy()] (auto& operation) {
+        protectedThis->getAllRecordsOnServer(operation, getAllRecordsData);
+    }));
 
     return request;
 }
@@ -967,7 +1003,11 @@ Ref<IDBRequest> IDBTransaction::requestGetRecord(ExecState& state, IDBObjectStor
     addRequest(request.get());
 
     LOG(IndexedDBOperations, "IDB get record operation: %s %s", objectStore.info().condensedLoggingString().utf8().data(), getRecordData.loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetRecordOnServer, &IDBTransaction::getRecordOnServer, getRecordData));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didGetRecordOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), getRecordData = getRecordData.isolatedCopy()] (auto& operation) {
+        protectedThis->getRecordOnServer(operation, getRecordData);
+    }));
 
     return request;
 }
@@ -1003,7 +1043,11 @@ Ref<IDBRequest> IDBTransaction::requestIndexRecord(ExecState& state, IDBIndex& i
     IDBGetRecordData getRecordData = { range, IDBGetRecordDataType::KeyAndValue };
 
     LOG(IndexedDBOperations, "IDB get index record operation: %s %s", index.info().condensedLoggingString().utf8().data(), getRecordData.loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetRecordOnServer, &IDBTransaction::getRecordOnServer, getRecordData));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didGetRecordOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), getRecordData = getRecordData.isolatedCopy()] (auto& operation) {
+        protectedThis->getRecordOnServer(operation, getRecordData);
+    }));
 
     return request;
 }
@@ -1062,7 +1106,11 @@ Ref<IDBRequest> IDBTransaction::requestCount(ExecState& state, IDBObjectStore& o
     addRequest(request.get());
 
     LOG(IndexedDBOperations, "IDB object store count operation: %s, range %s", objectStore.info().condensedLoggingString().utf8().data(), range.loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetCountOnServer, &IDBTransaction::getCountOnServer, range));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didGetCountOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), range = range.isolatedCopy()] (auto& operation) {
+        protectedThis->getCountOnServer(operation, range);
+    }));
 
     return request;
 }
@@ -1080,7 +1128,11 @@ Ref<IDBRequest> IDBTransaction::requestCount(ExecState& state, IDBIndex& index,
     addRequest(request.get());
 
     LOG(IndexedDBOperations, "IDB index count operation: %s, range %s", index.info().condensedLoggingString().utf8().data(), range.loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetCountOnServer, &IDBTransaction::getCountOnServer, range));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didGetCountOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), range = range.isolatedCopy()] (auto& operation) {
+        protectedThis->getCountOnServer(operation, range);
+    }));
 
     return request;
 }
@@ -1115,7 +1167,11 @@ Ref<IDBRequest> IDBTransaction::requestDeleteRecord(ExecState& state, IDBObjectS
     addRequest(request.get());
 
     LOG(IndexedDBOperations, "IDB delete record operation: %s, range %s", objectStore.info().condensedLoggingString().utf8().data(), range.loggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didDeleteRecordOnServer, &IDBTransaction::deleteRecordOnServer, range));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didDeleteRecordOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), range = range.isolatedCopy()] (auto& operation) {
+        protectedThis->deleteRecordOnServer(operation, range);
+    }));
     return request;
 }
 
@@ -1150,7 +1206,11 @@ Ref<IDBRequest> IDBTransaction::requestClearObjectStore(ExecState& state, IDBObj
     uint64_t objectStoreIdentifier = objectStore.info().identifier();
 
     LOG(IndexedDBOperations, "IDB clear object store operation: %s", objectStore.info().condensedLoggingString().utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didClearObjectStoreOnServer, &IDBTransaction::clearObjectStoreOnServer, objectStoreIdentifier));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didClearObjectStoreOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), objectStoreIdentifier] (auto& operation) {
+        protectedThis->clearObjectStoreOnServer(operation, objectStoreIdentifier);
+    }));
 
     return request;
 }
@@ -1172,7 +1232,7 @@ void IDBTransaction::didClearObjectStoreOnServer(IDBRequest& request, const IDBR
     completeNoncursorRequest(request, resultData);
 }
 
-Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ExecState& state, IDBObjectStore& objectStore, IDBKey* key, SerializedScriptValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
+Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ExecState& state, IDBObjectStore& objectStore, RefPtr<IDBKey>&& key, SerializedScriptValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
 {
     LOG(IndexedDB, "IDBTransaction::requestPutOrAdd");
     ASSERT(isActive());
@@ -1186,7 +1246,11 @@ Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ExecState& state, IDBObjectStore
     addRequest(request.get());
 
     LOG(IndexedDBOperations, "IDB putOrAdd operation: %s key: %s", objectStore.info().condensedLoggingString().utf8().data(), key ? key->loggingString().utf8().data() : "<null key>");
-    scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didPutOrAddOnServer, &IDBTransaction::putOrAddOnServer, key, &value, overwriteMode));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
+        protectedThis->didPutOrAddOnServer(request.get(), result);
+    }, [protectedThis = makeRef(*this), key, value = makeRef(value), overwriteMode] (auto& operation) {
+        protectedThis->putOrAddOnServer(operation, key.get(), value.ptr(), overwriteMode);
+    }));
 
     return request;
 }
@@ -1270,7 +1334,11 @@ void IDBTransaction::deleteObjectStore(const String& objectStoreName)
     }
 
     LOG(IndexedDBOperations, "IDB delete object store operation: %s", objectStoreName.utf8().data());
-    scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didDeleteObjectStoreOnServer, &IDBTransaction::deleteObjectStoreOnServer, objectStoreName));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
+        protectedThis->didDeleteObjectStoreOnServer(result);
+    }, [protectedThis = makeRef(*this), objectStoreName = objectStoreName.isolatedCopy()] (auto& operation) {
+        protectedThis->deleteObjectStoreOnServer(operation, objectStoreName);
+    }));
 }
 
 void IDBTransaction::deleteObjectStoreOnServer(IDBClient::TransactionOperation& operation, const String& objectStoreName)
@@ -1296,7 +1364,11 @@ void IDBTransaction::deleteIndex(uint64_t objectStoreIdentifier, const String& i
     ASSERT(isVersionChange());
 
     LOG(IndexedDBOperations, "IDB delete index operation: %s (%" PRIu64 ")", indexName.utf8().data(), objectStoreIdentifier);
-    scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didDeleteIndexOnServer, &IDBTransaction::deleteIndexOnServer, objectStoreIdentifier, indexName));
+    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
+        protectedThis->didDeleteIndexOnServer(result);
+    }, [protectedThis = makeRef(*this), objectStoreIdentifier, indexName = indexName.isolatedCopy()] (auto& operation) {
+        protectedThis->deleteIndexOnServer(operation, objectStoreIdentifier, indexName);
+    }));
 }
 
 void IDBTransaction::deleteIndexOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const String& indexName)
index 1f76753..722f12c 100644 (file)
@@ -113,7 +113,7 @@ public:
     std::unique_ptr<IDBIndex> createIndex(IDBObjectStore&, const IDBIndexInfo&);
     void renameIndex(IDBIndex&, const String& newName);
 
-    Ref<IDBRequest> requestPutOrAdd(JSC::ExecState&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
+    Ref<IDBRequest> requestPutOrAdd(JSC::ExecState&, IDBObjectStore&, RefPtr<IDBKey>&&, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
     Ref<IDBRequest> requestGetRecord(JSC::ExecState&, IDBObjectStore&, const IDBGetRecordData&);
     Ref<IDBRequest> requestGetAllObjectStoreRecords(JSC::ExecState&, IDBObjectStore&, const IDBKeyRangeData&, IndexedDB::GetAllType, Optional<uint32_t> count);
     Ref<IDBRequest> requestGetAllIndexRecords(JSC::ExecState&, IDBIndex&, const IDBKeyRangeData&, IndexedDB::GetAllType, Optional<uint32_t> count);
index 3e02d59..74eb736 100644 (file)
@@ -96,7 +96,7 @@ public:
 
         // m_completeFunction might be holding the last ref to this TransactionOperation,
         // so we need to do this trick to null it out without first destroying it.
-        WTF::Function<void (const IDBResultData&)> oldCompleteFunction;
+        Function<void(const IDBResultData&)> oldCompleteFunction;
         std::swap(m_completeFunction, oldCompleteFunction);
 
         m_performFunction = { };
@@ -126,8 +126,8 @@ protected:
     uint64_t m_indexIdentifier { 0 };
     std::unique_ptr<IDBResourceIdentifier> m_cursorIdentifier;
     IndexedDB::IndexRecordType m_indexRecordType;
-    WTF::Function<void ()> m_performFunction;
-    WTF::Function<void (const IDBResultData&)> m_completeFunction;
+    Function<void()> m_performFunction;
+    Function<void(const IDBResultData&)> m_completeFunction;
 
 private:
     IDBResourceIdentifier transactionIdentifier() const { return m_transaction->info().identifier(); }
@@ -142,124 +142,41 @@ private:
     bool m_nextRequestCanGoToServer { true };
 };
 
-template <typename... Arguments>
 class TransactionOperationImpl final : public TransactionOperation {
 public:
-    TransactionOperationImpl(IDBTransaction& transaction, void (IDBTransaction::*completeMethod)(const IDBResultData&), void (IDBTransaction::*performMethod)(TransactionOperation&, Arguments...), Arguments&&... arguments)
+    template<typename... Args> static Ref<TransactionOperationImpl> create(Args&&... args) { return adoptRef(*new TransactionOperationImpl(std::forward<Args>(args)...)); }
+private:
+    TransactionOperationImpl(IDBTransaction& transaction, Function<void(const IDBResultData&)> completeMethod, Function<void(TransactionOperation&)> performMethod)
         : TransactionOperation(transaction)
     {
-        RefPtr<TransactionOperation> protectedThis(this);
-
         ASSERT(performMethod);
-        m_performFunction = [protectedThis, this, performMethod, arguments...] {
-            (&m_transaction.get()->*performMethod)(*this, arguments...);
+        m_performFunction = [protectedThis = makeRef(*this), performMethod = WTFMove(performMethod)] {
+            performMethod(protectedThis.get());
         };
 
         if (completeMethod) {
-            m_completeFunction = [protectedThis, this, completeMethod](const IDBResultData& resultData) {
-                if (completeMethod)
-                    (&m_transaction.get()->*completeMethod)(resultData);
+            m_completeFunction = [protectedThis = makeRef(*this), completeMethod = WTFMove(completeMethod)] (const IDBResultData& resultData) {
+                completeMethod(resultData);
             };
         }
     }
 
-    TransactionOperationImpl(IDBTransaction& transaction, IDBRequest& request, void (IDBTransaction::*completeMethod)(IDBRequest&, const IDBResultData&), void (IDBTransaction::*performMethod)(TransactionOperation&, Arguments...), Arguments&&... arguments)
+    TransactionOperationImpl(IDBTransaction& transaction, IDBRequest& request, Function<void(const IDBResultData&)> completeMethod, Function<void(TransactionOperation&)> performMethod)
         : TransactionOperation(transaction, request)
     {
-        RefPtr<TransactionOperation> protectedThis(this);
-
         ASSERT(performMethod);
-        m_performFunction = [protectedThis, this, performMethod, arguments...] {
-            (&m_transaction.get()->*performMethod)(*this, arguments...);
+        m_performFunction = [protectedThis = makeRef(*this), performMethod = WTFMove(performMethod)] {
+            performMethod(protectedThis.get());
         };
 
         if (completeMethod) {
-            RefPtr<IDBRequest> refRequest(&request);
-            m_completeFunction = [protectedThis, this, refRequest, completeMethod](const IDBResultData& resultData) {
-                if (completeMethod)
-                    (&m_transaction.get()->*completeMethod)(*refRequest, resultData);
+            m_completeFunction = [protectedThis = makeRef(*this), completeMethod = WTFMove(completeMethod)] (const IDBResultData& resultData) {
+                completeMethod(resultData);
             };
         }
     }
 };
 
-inline Ref<TransactionOperation> createTransactionOperation(
-    IDBTransaction& transaction,
-    void (IDBTransaction::*complete)(const IDBResultData&),
-    void (IDBTransaction::*perform)(TransactionOperation&))
-{
-    return adoptRef(*new TransactionOperationImpl<>(transaction, complete, perform));
-}
-
-template<typename MP1, typename P1>
-Ref<TransactionOperation> createTransactionOperation(
-    IDBTransaction& transaction,
-    void (IDBTransaction::*complete)(const IDBResultData&),
-    void (IDBTransaction::*perform)(TransactionOperation&, MP1),
-    const P1& parameter1)
-{
-    return adoptRef(*new TransactionOperationImpl<MP1>(transaction, complete, perform, parameter1));
-}
-
-template<typename MP1, typename P1, typename MP2, typename P2>
-Ref<TransactionOperation> createTransactionOperation(
-    IDBTransaction& transaction,
-    void (IDBTransaction::*complete)(const IDBResultData&),
-    void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2),
-    const P1& parameter1,
-    const P2& parameter2)
-{
-    return adoptRef(*new TransactionOperationImpl<MP1, MP2>(transaction, complete, perform, parameter1, parameter2));
-}
-
-template<typename MP1, typename P1, typename MP2, typename P2, typename MP3, typename P3>
-Ref<TransactionOperation> createTransactionOperation(
-    IDBTransaction& transaction,
-    void (IDBTransaction::*complete)(const IDBResultData&),
-    void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2, MP3),
-    const P1& parameter1,
-    const P2& parameter2,
-    const P3& parameter3)
-{
-    return adoptRef(*new TransactionOperationImpl<MP1, MP2, MP3>(transaction, complete, perform, parameter1, parameter2, parameter3));
-}
-
-template<typename MP1, typename P1>
-Ref<TransactionOperation> createTransactionOperation(
-    IDBTransaction& transaction,
-    IDBRequest& request,
-    void (IDBTransaction::*complete)(IDBRequest&, const IDBResultData&),
-    void (IDBTransaction::*perform)(TransactionOperation&, MP1),
-    const P1& parameter1)
-{
-    return adoptRef(*new TransactionOperationImpl<MP1>(transaction, request, complete, perform, parameter1));
-}
-
-template<typename MP1, typename P1, typename MP2, typename P2>
-Ref<TransactionOperation> createTransactionOperation(
-    IDBTransaction& transaction,
-    IDBRequest& request,
-    void (IDBTransaction::*complete)(IDBRequest&, const IDBResultData&),
-    void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2),
-    const P1& parameter1,
-    const P2& parameter2)
-{
-    return adoptRef(*new TransactionOperationImpl<MP1, MP2>(transaction, request, complete, perform, parameter1, parameter2));
-}
-
-template<typename MP1, typename MP2, typename MP3, typename P1, typename P2, typename P3>
-Ref<TransactionOperation> createTransactionOperation(
-    IDBTransaction& transaction,
-    IDBRequest& request,
-    void (IDBTransaction::*complete)(IDBRequest&, const IDBResultData&),
-    void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2, MP3),
-    const P1& parameter1,
-    const P2& parameter2,
-    const P3& parameter3)
-{
-    return adoptRef(*new TransactionOperationImpl<MP1, MP2, MP3>(transaction, request, complete, perform, parameter1, parameter2, parameter3));
-}
-
 } // namespace IDBClient
 } // namespace WebCore