Changeset 240658 in webkit


Ignore:
Timestamp:
Jan 29, 2019 8:39:47 AM (5 years ago)
Author:
achristensen@apple.com
Message:

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.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r240656 r240658  
     1
     22019-01-29  Alex Christensen  <achristensen@webkit.org>
     3
     4        Use lambdas instead of member pointer functions for TransactionOperationImpl
     5        https://bugs.webkit.org/show_bug.cgi?id=193933
     6
     7        Reviewed by Tim Horton.
     8
     9        No change in behavior.  This just makes it easier to add new parameters to these functions in a straightforward manner.
     10
     11        * Modules/indexeddb/IDBObjectStore.cpp:
     12        (WebCore::IDBObjectStore::putOrAdd):
     13        * Modules/indexeddb/IDBTransaction.cpp:
     14        (WebCore::IDBTransaction::internalAbort):
     15        (WebCore::IDBTransaction::commit):
     16        (WebCore::IDBTransaction::createObjectStore):
     17        (WebCore::IDBTransaction::renameObjectStore):
     18        (WebCore::IDBTransaction::createIndex):
     19        (WebCore::IDBTransaction::renameIndex):
     20        (WebCore::IDBTransaction::doRequestOpenCursor):
     21        (WebCore::IDBTransaction::iterateCursor):
     22        (WebCore::IDBTransaction::requestGetAllObjectStoreRecords):
     23        (WebCore::IDBTransaction::requestGetAllIndexRecords):
     24        (WebCore::IDBTransaction::requestGetRecord):
     25        (WebCore::IDBTransaction::requestIndexRecord):
     26        (WebCore::IDBTransaction::requestCount):
     27        (WebCore::IDBTransaction::requestDeleteRecord):
     28        (WebCore::IDBTransaction::requestClearObjectStore):
     29        (WebCore::IDBTransaction::requestPutOrAdd):
     30        (WebCore::IDBTransaction::deleteObjectStore):
     31        (WebCore::IDBTransaction::deleteIndex):
     32        * Modules/indexeddb/IDBTransaction.h:
     33        * Modules/indexeddb/client/TransactionOperation.h:
     34        (WebCore::IDBClient::TransactionOperation::doComplete):
     35        (WebCore::IDBClient::createTransactionOperation): Deleted.
     36
    1372019-01-29  Zalan Bujtas  <zalan@apple.com>
    238
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

    r239535 r240658  
    358358        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 };
    359359
    360     return m_transaction.requestPutOrAdd(state, *this, key.get(), *serializedValue, overwriteMode);
     360    return m_transaction.requestPutOrAdd(state, *this, WTFMove(key), *serializedValue, overwriteMode);
    361361}
    362362
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp

    r239865 r240658  
    247247
    248248    LOG(IndexedDBOperations, "IDB abort-on-server operation: Transaction %s", info().identifier().loggingString().utf8().data());
    249     scheduleOperation(IDBClient::createTransactionOperation(*this, nullptr, &IDBTransaction::abortOnServerAndCancelRequests));
     249    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, nullptr, [protectedThis = makeRef(*this)] (auto& operation) {
     250        protectedThis->abortOnServerAndCancelRequests(operation);
     251    }));
    250252}
    251253
     
    502504
    503505    LOG(IndexedDBOperations, "IDB commit operation: Transaction %s", info().identifier().loggingString().utf8().data());
    504     scheduleOperation(IDBClient::createTransactionOperation(*this, nullptr, &IDBTransaction::commitOnServer));
     506    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, nullptr, [protectedThis = makeRef(*this)] (auto& operation) {
     507        protectedThis->commitOnServer(operation);
     508    }));
    505509}
    506510
     
    660664
    661665    LOG(IndexedDBOperations, "IDB create object store operation: %s", info.condensedLoggingString().utf8().data());
    662     scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didCreateObjectStoreOnServer, &IDBTransaction::createObjectStoreOnServer, info));
     666    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
     667        protectedThis->didCreateObjectStoreOnServer(result);
     668    }, [protectedThis = makeRef(*this), info = info.isolatedCopy()] (auto& operation) {
     669        protectedThis->createObjectStoreOnServer(operation, info);
     670    }));
    663671
    664672    return *rawObjectStore;
     
    698706
    699707    LOG(IndexedDBOperations, "IDB rename object store operation: %s to %s", objectStore.info().condensedLoggingString().utf8().data(), newName.utf8().data());
    700     scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didRenameObjectStoreOnServer, &IDBTransaction::renameObjectStoreOnServer, objectStoreIdentifier, newName));
     708    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
     709        protectedThis->didRenameObjectStoreOnServer(result);
     710    }, [protectedThis = makeRef(*this), objectStoreIdentifier, newName = newName.isolatedCopy()] (auto& operation) {
     711        protectedThis->renameObjectStoreOnServer(operation, objectStoreIdentifier, newName);
     712    }));
    701713
    702714    m_referencedObjectStores.set(newName, m_referencedObjectStores.take(objectStore.info().name()));
     
    729741
    730742    LOG(IndexedDBOperations, "IDB create index operation: %s under object store %s", info.condensedLoggingString().utf8().data(), objectStore.info().condensedLoggingString().utf8().data());
    731     scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didCreateIndexOnServer, &IDBTransaction::createIndexOnServer, info));
     743    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
     744        protectedThis->didCreateIndexOnServer(result);
     745    }, [protectedThis = makeRef(*this), info = info.isolatedCopy()] (auto& operation) {
     746        protectedThis->createIndexOnServer(operation, info);
     747    }));
    732748
    733749    return std::make_unique<IDBIndex>(*scriptExecutionContext(), info, objectStore);
     
    779795
    780796    LOG(IndexedDBOperations, "IDB rename index operation: %s to %s under object store %" PRIu64, index.info().condensedLoggingString().utf8().data(), newName.utf8().data(), index.info().objectStoreIdentifier());
    781     scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didRenameIndexOnServer, &IDBTransaction::renameIndexOnServer, objectStoreIdentifier, indexIdentifier, newName));
     797    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
     798        protectedThis->didRenameIndexOnServer(result);
     799    }, [protectedThis = makeRef(*this), objectStoreIdentifier, indexIdentifier, newName = newName.isolatedCopy()] (auto& operation) {
     800        protectedThis->renameIndexOnServer(operation, objectStoreIdentifier, indexIdentifier, newName);
     801    }));
    782802}
    783803
     
    831851
    832852    LOG(IndexedDBOperations, "IDB open cursor operation: %s", cursor->info().loggingString().utf8().data());
    833     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didOpenCursorOnServer, &IDBTransaction::openCursorOnServer, cursor->info()));
     853    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     854        protectedThis->didOpenCursorOnServer(request.get(), result);
     855    }, [protectedThis = makeRef(*this), info = cursor->info().isolatedCopy()] (auto& operation) {
     856        protectedThis->openCursorOnServer(operation, info);
     857    }));
    834858
    835859    return request;
     
    862886
    863887    LOG(IndexedDBOperations, "IDB iterate cursor operation: %s %s", cursor.info().loggingString().utf8().data(), data.loggingString().utf8().data());
    864     scheduleOperation(IDBClient::createTransactionOperation(*this, *cursor.request(), &IDBTransaction::didIterateCursorOnServer, &IDBTransaction::iterateCursorOnServer, data));
     888    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, *cursor.request(), [protectedThis = makeRef(*this), request = makeRef(*cursor.request())] (const auto& result) {
     889        protectedThis->didIterateCursorOnServer(request.get(), result);
     890    }, [protectedThis = makeRef(*this), data = data.isolatedCopy()] (auto& operation) {
     891        protectedThis->iterateCursorOnServer(operation, data);
     892    }));
    865893}
    866894
     
    896924
    897925    LOG(IndexedDBOperations, "IDB get all object store records operation: %s", getAllRecordsData.loggingString().utf8().data());
    898     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetAllRecordsOnServer, &IDBTransaction::getAllRecordsOnServer, getAllRecordsData));
     926    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     927        protectedThis->didGetAllRecordsOnServer(request.get(), result);
     928    }, [protectedThis = makeRef(*this), getAllRecordsData = getAllRecordsData.isolatedCopy()] (auto& operation) {
     929        protectedThis->getAllRecordsOnServer(operation, getAllRecordsData);
     930    }));
    899931
    900932    return request;
     
    915947
    916948    LOG(IndexedDBOperations, "IDB get all index records operation: %s", getAllRecordsData.loggingString().utf8().data());
    917     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetAllRecordsOnServer, &IDBTransaction::getAllRecordsOnServer, getAllRecordsData));
     949    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     950        protectedThis->didGetAllRecordsOnServer(request.get(), result);
     951    }, [protectedThis = makeRef(*this), getAllRecordsData = getAllRecordsData.isolatedCopy()] (auto& operation) {
     952        protectedThis->getAllRecordsOnServer(operation, getAllRecordsData);
     953    }));
    918954
    919955    return request;
     
    9681004
    9691005    LOG(IndexedDBOperations, "IDB get record operation: %s %s", objectStore.info().condensedLoggingString().utf8().data(), getRecordData.loggingString().utf8().data());
    970     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetRecordOnServer, &IDBTransaction::getRecordOnServer, getRecordData));
     1006    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     1007        protectedThis->didGetRecordOnServer(request.get(), result);
     1008    }, [protectedThis = makeRef(*this), getRecordData = getRecordData.isolatedCopy()] (auto& operation) {
     1009        protectedThis->getRecordOnServer(operation, getRecordData);
     1010    }));
    9711011
    9721012    return request;
     
    10041044
    10051045    LOG(IndexedDBOperations, "IDB get index record operation: %s %s", index.info().condensedLoggingString().utf8().data(), getRecordData.loggingString().utf8().data());
    1006     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetRecordOnServer, &IDBTransaction::getRecordOnServer, getRecordData));
     1046    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     1047        protectedThis->didGetRecordOnServer(request.get(), result);
     1048    }, [protectedThis = makeRef(*this), getRecordData = getRecordData.isolatedCopy()] (auto& operation) {
     1049        protectedThis->getRecordOnServer(operation, getRecordData);
     1050    }));
    10071051
    10081052    return request;
     
    10631107
    10641108    LOG(IndexedDBOperations, "IDB object store count operation: %s, range %s", objectStore.info().condensedLoggingString().utf8().data(), range.loggingString().utf8().data());
    1065     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetCountOnServer, &IDBTransaction::getCountOnServer, range));
     1109    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     1110        protectedThis->didGetCountOnServer(request.get(), result);
     1111    }, [protectedThis = makeRef(*this), range = range.isolatedCopy()] (auto& operation) {
     1112        protectedThis->getCountOnServer(operation, range);
     1113    }));
    10661114
    10671115    return request;
     
    10811129
    10821130    LOG(IndexedDBOperations, "IDB index count operation: %s, range %s", index.info().condensedLoggingString().utf8().data(), range.loggingString().utf8().data());
    1083     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didGetCountOnServer, &IDBTransaction::getCountOnServer, range));
     1131    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     1132        protectedThis->didGetCountOnServer(request.get(), result);
     1133    }, [protectedThis = makeRef(*this), range = range.isolatedCopy()] (auto& operation) {
     1134        protectedThis->getCountOnServer(operation, range);
     1135    }));
    10841136
    10851137    return request;
     
    11161168
    11171169    LOG(IndexedDBOperations, "IDB delete record operation: %s, range %s", objectStore.info().condensedLoggingString().utf8().data(), range.loggingString().utf8().data());
    1118     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didDeleteRecordOnServer, &IDBTransaction::deleteRecordOnServer, range));
     1170    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     1171        protectedThis->didDeleteRecordOnServer(request.get(), result);
     1172    }, [protectedThis = makeRef(*this), range = range.isolatedCopy()] (auto& operation) {
     1173        protectedThis->deleteRecordOnServer(operation, range);
     1174    }));
    11191175    return request;
    11201176}
     
    11511207
    11521208    LOG(IndexedDBOperations, "IDB clear object store operation: %s", objectStore.info().condensedLoggingString().utf8().data());
    1153     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didClearObjectStoreOnServer, &IDBTransaction::clearObjectStoreOnServer, objectStoreIdentifier));
     1209    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     1210        protectedThis->didClearObjectStoreOnServer(request.get(), result);
     1211    }, [protectedThis = makeRef(*this), objectStoreIdentifier] (auto& operation) {
     1212        protectedThis->clearObjectStoreOnServer(operation, objectStoreIdentifier);
     1213    }));
    11541214
    11551215    return request;
     
    11731233}
    11741234
    1175 Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ExecState& state, IDBObjectStore& objectStore, IDBKey* key, SerializedScriptValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
     1235Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ExecState& state, IDBObjectStore& objectStore, RefPtr<IDBKey>&& key, SerializedScriptValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
    11761236{
    11771237    LOG(IndexedDB, "IDBTransaction::requestPutOrAdd");
     
    11871247
    11881248    LOG(IndexedDBOperations, "IDB putOrAdd operation: %s key: %s", objectStore.info().condensedLoggingString().utf8().data(), key ? key->loggingString().utf8().data() : "<null key>");
    1189     scheduleOperation(IDBClient::createTransactionOperation(*this, request.get(), &IDBTransaction::didPutOrAddOnServer, &IDBTransaction::putOrAddOnServer, key, &value, overwriteMode));
     1249    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, request.get(), [protectedThis = makeRef(*this), request = request.copyRef()] (const auto& result) {
     1250        protectedThis->didPutOrAddOnServer(request.get(), result);
     1251    }, [protectedThis = makeRef(*this), key, value = makeRef(value), overwriteMode] (auto& operation) {
     1252        protectedThis->putOrAddOnServer(operation, key.get(), value.ptr(), overwriteMode);
     1253    }));
    11901254
    11911255    return request;
     
    12711335
    12721336    LOG(IndexedDBOperations, "IDB delete object store operation: %s", objectStoreName.utf8().data());
    1273     scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didDeleteObjectStoreOnServer, &IDBTransaction::deleteObjectStoreOnServer, objectStoreName));
     1337    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
     1338        protectedThis->didDeleteObjectStoreOnServer(result);
     1339    }, [protectedThis = makeRef(*this), objectStoreName = objectStoreName.isolatedCopy()] (auto& operation) {
     1340        protectedThis->deleteObjectStoreOnServer(operation, objectStoreName);
     1341    }));
    12741342}
    12751343
     
    12971365
    12981366    LOG(IndexedDBOperations, "IDB delete index operation: %s (%" PRIu64 ")", indexName.utf8().data(), objectStoreIdentifier);
    1299     scheduleOperation(IDBClient::createTransactionOperation(*this, &IDBTransaction::didDeleteIndexOnServer, &IDBTransaction::deleteIndexOnServer, objectStoreIdentifier, indexName));
     1367    scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = makeRef(*this)] (const auto& result) {
     1368        protectedThis->didDeleteIndexOnServer(result);
     1369    }, [protectedThis = makeRef(*this), objectStoreIdentifier, indexName = indexName.isolatedCopy()] (auto& operation) {
     1370        protectedThis->deleteIndexOnServer(operation, objectStoreIdentifier, indexName);
     1371    }));
    13001372}
    13011373
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h

    r239535 r240658  
    114114    void renameIndex(IDBIndex&, const String& newName);
    115115
    116     Ref<IDBRequest> requestPutOrAdd(JSC::ExecState&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
     116    Ref<IDBRequest> requestPutOrAdd(JSC::ExecState&, IDBObjectStore&, RefPtr<IDBKey>&&, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
    117117    Ref<IDBRequest> requestGetRecord(JSC::ExecState&, IDBObjectStore&, const IDBGetRecordData&);
    118118    Ref<IDBRequest> requestGetAllObjectStoreRecords(JSC::ExecState&, IDBObjectStore&, const IDBKeyRangeData&, IndexedDB::GetAllType, Optional<uint32_t> count);
  • trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h

    r239865 r240658  
    9797        // m_completeFunction might be holding the last ref to this TransactionOperation,
    9898        // so we need to do this trick to null it out without first destroying it.
    99         WTF::Function<void (const IDBResultData&)> oldCompleteFunction;
     99        Function<void(const IDBResultData&)> oldCompleteFunction;
    100100        std::swap(m_completeFunction, oldCompleteFunction);
    101101
     
    127127    std::unique_ptr<IDBResourceIdentifier> m_cursorIdentifier;
    128128    IndexedDB::IndexRecordType m_indexRecordType;
    129     WTF::Function<void ()> m_performFunction;
    130     WTF::Function<void (const IDBResultData&)> m_completeFunction;
     129    Function<void()> m_performFunction;
     130    Function<void(const IDBResultData&)> m_completeFunction;
    131131
    132132private:
     
    143143};
    144144
    145 template <typename... Arguments>
    146145class TransactionOperationImpl final : public TransactionOperation {
    147146public:
    148     TransactionOperationImpl(IDBTransaction& transaction, void (IDBTransaction::*completeMethod)(const IDBResultData&), void (IDBTransaction::*performMethod)(TransactionOperation&, Arguments...), Arguments&&... arguments)
     147    template<typename... Args> static Ref<TransactionOperationImpl> create(Args&&... args) { return adoptRef(*new TransactionOperationImpl(std::forward<Args>(args)...)); }
     148private:
     149    TransactionOperationImpl(IDBTransaction& transaction, Function<void(const IDBResultData&)> completeMethod, Function<void(TransactionOperation&)> performMethod)
    149150        : TransactionOperation(transaction)
    150151    {
    151         RefPtr<TransactionOperation> protectedThis(this);
    152 
    153152        ASSERT(performMethod);
    154         m_performFunction = [protectedThis, this, performMethod, arguments...] {
    155             (&m_transaction.get()->*performMethod)(*this, arguments...);
     153        m_performFunction = [protectedThis = makeRef(*this), performMethod = WTFMove(performMethod)] {
     154            performMethod(protectedThis.get());
    156155        };
    157156
    158157        if (completeMethod) {
    159             m_completeFunction = [protectedThis, this, completeMethod](const IDBResultData& resultData) {
    160                 if (completeMethod)
    161                     (&m_transaction.get()->*completeMethod)(resultData);
     158            m_completeFunction = [protectedThis = makeRef(*this), completeMethod = WTFMove(completeMethod)] (const IDBResultData& resultData) {
     159                completeMethod(resultData);
    162160            };
    163161        }
    164162    }
    165163
    166     TransactionOperationImpl(IDBTransaction& transaction, IDBRequest& request, void (IDBTransaction::*completeMethod)(IDBRequest&, const IDBResultData&), void (IDBTransaction::*performMethod)(TransactionOperation&, Arguments...), Arguments&&... arguments)
     164    TransactionOperationImpl(IDBTransaction& transaction, IDBRequest& request, Function<void(const IDBResultData&)> completeMethod, Function<void(TransactionOperation&)> performMethod)
    167165        : TransactionOperation(transaction, request)
    168166    {
    169         RefPtr<TransactionOperation> protectedThis(this);
    170 
    171167        ASSERT(performMethod);
    172         m_performFunction = [protectedThis, this, performMethod, arguments...] {
    173             (&m_transaction.get()->*performMethod)(*this, arguments...);
     168        m_performFunction = [protectedThis = makeRef(*this), performMethod = WTFMove(performMethod)] {
     169            performMethod(protectedThis.get());
    174170        };
    175171
    176172        if (completeMethod) {
    177             RefPtr<IDBRequest> refRequest(&request);
    178             m_completeFunction = [protectedThis, this, refRequest, completeMethod](const IDBResultData& resultData) {
    179                 if (completeMethod)
    180                     (&m_transaction.get()->*completeMethod)(*refRequest, resultData);
     173            m_completeFunction = [protectedThis = makeRef(*this), completeMethod = WTFMove(completeMethod)] (const IDBResultData& resultData) {
     174                completeMethod(resultData);
    181175            };
    182176        }
     
    184178};
    185179
    186 inline Ref<TransactionOperation> createTransactionOperation(
    187     IDBTransaction& transaction,
    188     void (IDBTransaction::*complete)(const IDBResultData&),
    189     void (IDBTransaction::*perform)(TransactionOperation&))
    190 {
    191     return adoptRef(*new TransactionOperationImpl<>(transaction, complete, perform));
    192 }
    193 
    194 template<typename MP1, typename P1>
    195 Ref<TransactionOperation> createTransactionOperation(
    196     IDBTransaction& transaction,
    197     void (IDBTransaction::*complete)(const IDBResultData&),
    198     void (IDBTransaction::*perform)(TransactionOperation&, MP1),
    199     const P1& parameter1)
    200 {
    201     return adoptRef(*new TransactionOperationImpl<MP1>(transaction, complete, perform, parameter1));
    202 }
    203 
    204 template<typename MP1, typename P1, typename MP2, typename P2>
    205 Ref<TransactionOperation> createTransactionOperation(
    206     IDBTransaction& transaction,
    207     void (IDBTransaction::*complete)(const IDBResultData&),
    208     void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2),
    209     const P1& parameter1,
    210     const P2& parameter2)
    211 {
    212     return adoptRef(*new TransactionOperationImpl<MP1, MP2>(transaction, complete, perform, parameter1, parameter2));
    213 }
    214 
    215 template<typename MP1, typename P1, typename MP2, typename P2, typename MP3, typename P3>
    216 Ref<TransactionOperation> createTransactionOperation(
    217     IDBTransaction& transaction,
    218     void (IDBTransaction::*complete)(const IDBResultData&),
    219     void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2, MP3),
    220     const P1& parameter1,
    221     const P2& parameter2,
    222     const P3& parameter3)
    223 {
    224     return adoptRef(*new TransactionOperationImpl<MP1, MP2, MP3>(transaction, complete, perform, parameter1, parameter2, parameter3));
    225 }
    226 
    227 template<typename MP1, typename P1>
    228 Ref<TransactionOperation> createTransactionOperation(
    229     IDBTransaction& transaction,
    230     IDBRequest& request,
    231     void (IDBTransaction::*complete)(IDBRequest&, const IDBResultData&),
    232     void (IDBTransaction::*perform)(TransactionOperation&, MP1),
    233     const P1& parameter1)
    234 {
    235     return adoptRef(*new TransactionOperationImpl<MP1>(transaction, request, complete, perform, parameter1));
    236 }
    237 
    238 template<typename MP1, typename P1, typename MP2, typename P2>
    239 Ref<TransactionOperation> createTransactionOperation(
    240     IDBTransaction& transaction,
    241     IDBRequest& request,
    242     void (IDBTransaction::*complete)(IDBRequest&, const IDBResultData&),
    243     void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2),
    244     const P1& parameter1,
    245     const P2& parameter2)
    246 {
    247     return adoptRef(*new TransactionOperationImpl<MP1, MP2>(transaction, request, complete, perform, parameter1, parameter2));
    248 }
    249 
    250 template<typename MP1, typename MP2, typename MP3, typename P1, typename P2, typename P3>
    251 Ref<TransactionOperation> createTransactionOperation(
    252     IDBTransaction& transaction,
    253     IDBRequest& request,
    254     void (IDBTransaction::*complete)(IDBRequest&, const IDBResultData&),
    255     void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2, MP3),
    256     const P1& parameter1,
    257     const P2& parameter2,
    258     const P3& parameter3)
    259 {
    260     return adoptRef(*new TransactionOperationImpl<MP1, MP2, MP3>(transaction, request, complete, perform, parameter1, parameter2, parameter3));
    261 }
    262 
    263180} // namespace IDBClient
    264181} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.