From 02011058af0ae86b2c050a1db2f0dcd8a767b068 Mon Sep 17 00:00:00 2001 From: Jan Varga Date: Sat, 23 Mar 2024 08:42:40 +0000 Subject: [PATCH] Bug 1799374 - Add support for tracking request ids to cursor continue operation; r=dom-storage-reviewers,asuth Differential Revision: https://phabricator.services.mozilla.com/D204195 --- dom/indexedDB/ActorsChild.cpp | 4 ++-- dom/indexedDB/ActorsChild.h | 6 ++++-- dom/indexedDB/ActorsParent.cpp | 16 ++++++++-------- dom/indexedDB/IDBCursor.cpp | 8 +++++--- dom/indexedDB/PBackgroundIDBCursor.ipdl | 4 ++-- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp index 504ab4ff03e6..1a122ea3c1b7 100644 --- a/dom/indexedDB/ActorsChild.cpp +++ b/dom/indexedDB/ActorsChild.cpp @@ -2211,7 +2211,7 @@ BackgroundCursorChild::SafeRefPtrFromThis() { template void BackgroundCursorChild::SendContinueInternal( - const CursorRequestParams& aParams, + const int64_t aRequestId, const CursorRequestParams& aParams, const CursorData& aCurrentData) { AssertIsOnOwningThread(); MOZ_ASSERT(mRequest); @@ -2394,7 +2394,7 @@ void BackgroundCursorChild::SendContinueInternal( // handling model disallow this? } else { MOZ_ALWAYS_TRUE(PBackgroundIDBCursorChild::SendContinue( - params, currentKey, currentObjectStoreKey)); + aRequestId, params, currentKey, currentObjectStoreKey)); } } diff --git a/dom/indexedDB/ActorsChild.h b/dom/indexedDB/ActorsChild.h index 9b6ae3ce5545..194ed2887818 100644 --- a/dom/indexedDB/ActorsChild.h +++ b/dom/indexedDB/ActorsChild.h @@ -548,7 +548,8 @@ class BackgroundCursorChild final : public BackgroundCursorChildBase { BackgroundCursorChild(NotNull aRequest, SourceType* aSource, Direction aDirection); - void SendContinueInternal(const CursorRequestParams& aParams, + void SendContinueInternal(const int64_t aRequestId, + const CursorRequestParams& aParams, const CursorData& aCurrentData); void InvalidateCachedResponses(); @@ -594,7 +595,8 @@ class BackgroundCursorChild final : public BackgroundCursorChildBase { mozilla::ipc::IPCResult RecvResponse(CursorResponse&& aResponse) override; // Force callers to use SendContinueInternal. - bool SendContinue(const CursorRequestParams& aParams, const Key& aCurrentKey, + bool SendContinue(const int64_t& aRequestId, + const CursorRequestParams& aParams, const Key& aCurrentKey, const Key& aCurrentObjectStoreKey) = delete; bool SendDeleteMe() = delete; diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 081a40e4ec6e..d34de35c772f 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -4345,8 +4345,8 @@ class Cursor final mozilla::ipc::IPCResult RecvDeleteMe() override; mozilla::ipc::IPCResult RecvContinue( - const CursorRequestParams& aParams, const Key& aCurrentKey, - const Key& aCurrentObjectStoreKey) override; + const int64_t& aRequestId, const CursorRequestParams& aParams, + const Key& aCurrentKey, const Key& aCurrentObjectStoreKey) override; public: Cursor(SafeRefPtr aTransaction, @@ -4594,9 +4594,9 @@ class Cursor::ContinueOp final const CursorRequestParams mParams; // Only created by Cursor. - ContinueOp(Cursor* const aCursor, CursorRequestParams aParams, - CursorPosition aPosition) - : CursorOpBase(aCursor, 0), + ContinueOp(Cursor* const aCursor, int64_t aRequestId, + CursorRequestParams aParams, CursorPosition aPosition) + : CursorOpBase(aCursor, aRequestId), mParams(std::move(aParams)), mCurrentPosition{std::move(aPosition)} { MOZ_ASSERT(mParams.type() != CursorRequestParams::T__None); @@ -11602,8 +11602,8 @@ mozilla::ipc::IPCResult Cursor::RecvDeleteMe() { template mozilla::ipc::IPCResult Cursor::RecvContinue( - const CursorRequestParams& aParams, const Key& aCurrentKey, - const Key& aCurrentObjectStoreKey) { + const int64_t& aRequestId, const CursorRequestParams& aParams, + const Key& aCurrentKey, const Key& aCurrentObjectStoreKey) { AssertIsOnBackgroundThread(); MOZ_ASSERT(aParams.type() != CursorRequestParams::T__None); MOZ_ASSERT(this->mObjectStoreMetadata); @@ -11653,7 +11653,7 @@ mozilla::ipc::IPCResult Cursor::RecvContinue( } const RefPtr continueOp = - new ContinueOp(this, aParams, std::move(position)); + new ContinueOp(this, aRequestId, aParams, std::move(position)); if (NS_WARN_IF(!continueOp->Init(*mTransaction))) { continueOp->Cleanup(); return IPC_FAIL(this, "ContinueOp initialization failed!"); diff --git a/dom/indexedDB/IDBCursor.cpp b/dom/indexedDB/IDBCursor.cpp index 2fb6e987150f..65234bf79263 100644 --- a/dom/indexedDB/IDBCursor.cpp +++ b/dom/indexedDB/IDBCursor.cpp @@ -417,7 +417,8 @@ void IDBTypedCursor::Continue(JSContext* const aCx, IDB_LOG_STRINGIFY(key)); } - GetTypedBackgroundActorRef().SendContinueInternal(ContinueParams(key), mData); + GetTypedBackgroundActorRef().SendContinueInternal( + mTransaction->NextRequestId(), ContinueParams(key), mData); mContinueCalled = true; } @@ -523,6 +524,7 @@ void IDBTypedCursor::ContinuePrimaryKey( IDB_LOG_STRINGIFY(key), IDB_LOG_STRINGIFY(primaryKey)); GetTypedBackgroundActorRef().SendContinueInternal( + mTransaction->NextRequestId(), ContinuePrimaryKeyParams(key, primaryKey), mData); mContinueCalled = true; @@ -573,8 +575,8 @@ void IDBTypedCursor::Advance(const uint32_t aCount, IDB_LOG_STRINGIFY(mSource), IDB_LOG_STRINGIFY(mDirection), aCount); } - GetTypedBackgroundActorRef().SendContinueInternal(AdvanceParams(aCount), - mData); + GetTypedBackgroundActorRef().SendContinueInternal( + mTransaction->NextRequestId(), AdvanceParams(aCount), mData); mContinueCalled = true; } diff --git a/dom/indexedDB/PBackgroundIDBCursor.ipdl b/dom/indexedDB/PBackgroundIDBCursor.ipdl index 60c8d2ca7b94..e7669f2554f5 100644 --- a/dom/indexedDB/PBackgroundIDBCursor.ipdl +++ b/dom/indexedDB/PBackgroundIDBCursor.ipdl @@ -87,8 +87,8 @@ protocol PBackgroundIDBCursor parent: async DeleteMe(); - async Continue(CursorRequestParams params, Key currentKey, - Key currentObjectStoreKey); + async Continue(int64_t requestId, CursorRequestParams params, + Key currentKey, Key currentObjectStoreKey); child: async __delete__();