mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 05:48:26 +00:00
Bug 1168606 - Part 2: Convert DelayedDeleteRunnable into reusable DelayedActionRunnable class. r=bent
This commit is contained in:
parent
d39c90fbcb
commit
5609390bdb
@ -2349,28 +2349,33 @@ BackgroundRequestChild::Recv__delete__(const RequestResponse& aResponse)
|
||||
* BackgroundCursorChild
|
||||
******************************************************************************/
|
||||
|
||||
class BackgroundCursorChild::DelayedDeleteRunnable final
|
||||
class BackgroundCursorChild::DelayedActionRunnable final
|
||||
: public nsICancelableRunnable
|
||||
{
|
||||
using ActionFunc = void (BackgroundCursorChild::*)();
|
||||
|
||||
BackgroundCursorChild* mActor;
|
||||
nsRefPtr<IDBRequest> mRequest;
|
||||
ActionFunc mActionFunc;
|
||||
|
||||
public:
|
||||
explicit
|
||||
DelayedDeleteRunnable(BackgroundCursorChild* aActor)
|
||||
DelayedActionRunnable(BackgroundCursorChild* aActor, ActionFunc aActionFunc)
|
||||
: mActor(aActor)
|
||||
, mRequest(aActor->mRequest)
|
||||
, mActionFunc(aActionFunc)
|
||||
{
|
||||
MOZ_ASSERT(aActor);
|
||||
aActor->AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mRequest);
|
||||
MOZ_ASSERT(mActionFunc);
|
||||
}
|
||||
|
||||
// Does not need to be threadsafe since this only runs on one thread.
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
private:
|
||||
~DelayedDeleteRunnable()
|
||||
~DelayedActionRunnable()
|
||||
{ }
|
||||
|
||||
NS_DECL_NSIRUNNABLE
|
||||
@ -2510,7 +2515,8 @@ BackgroundCursorChild::HandleResponse(const void_t& aResponse)
|
||||
DispatchSuccessEvent(&helper);
|
||||
|
||||
if (!mCursor) {
|
||||
nsCOMPtr<nsIRunnable> deleteRunnable = new DelayedDeleteRunnable(this);
|
||||
nsCOMPtr<nsIRunnable> deleteRunnable = new DelayedActionRunnable(
|
||||
this, &BackgroundCursorChild::SendDeleteMeInternal);
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToCurrentThread(deleteRunnable)));
|
||||
}
|
||||
}
|
||||
@ -2745,19 +2751,20 @@ DispatchMutableFileResult(IDBRequest* aRequest,
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(BackgroundCursorChild::DelayedDeleteRunnable,
|
||||
NS_IMPL_ISUPPORTS(BackgroundCursorChild::DelayedActionRunnable,
|
||||
nsIRunnable,
|
||||
nsICancelableRunnable)
|
||||
|
||||
NS_IMETHODIMP
|
||||
BackgroundCursorChild::
|
||||
DelayedDeleteRunnable::Run()
|
||||
DelayedActionRunnable::Run()
|
||||
{
|
||||
MOZ_ASSERT(mActor);
|
||||
mActor->AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mRequest);
|
||||
MOZ_ASSERT(mActionFunc);
|
||||
|
||||
mActor->SendDeleteMeInternal();
|
||||
(mActor->*mActionFunc)();
|
||||
|
||||
mActor = nullptr;
|
||||
mRequest = nullptr;
|
||||
@ -2767,7 +2774,7 @@ DelayedDeleteRunnable::Run()
|
||||
|
||||
NS_IMETHODIMP
|
||||
BackgroundCursorChild::
|
||||
DelayedDeleteRunnable::Cancel()
|
||||
DelayedActionRunnable::Cancel()
|
||||
{
|
||||
if (NS_WARN_IF(!mActor)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -624,7 +624,7 @@ class BackgroundCursorChild final
|
||||
friend class BackgroundTransactionChild;
|
||||
friend class BackgroundVersionChangeTransactionChild;
|
||||
|
||||
class DelayedDeleteRunnable;
|
||||
class DelayedActionRunnable;
|
||||
|
||||
IDBRequest* mRequest;
|
||||
IDBTransaction* mTransaction;
|
||||
|
Loading…
x
Reference in New Issue
Block a user