mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1162333 - Add stronger assertions to PromiseWorkerProxy in debug builds. r=catalinb
This commit is contained in:
parent
b58b4730d9
commit
0f8b18879b
@ -1481,7 +1481,7 @@ Promise::GetDependentPromises(nsTArray<nsRefPtr<Promise>>& aPromises)
|
||||
}
|
||||
|
||||
// A WorkerRunnable to resolve/reject the Promise on the worker thread.
|
||||
|
||||
// Calling thread MUST hold PromiseWorkerProxy's mutex before creating this.
|
||||
class PromiseWorkerProxyRunnable : public workers::WorkerRunnable
|
||||
{
|
||||
public:
|
||||
@ -1589,12 +1589,24 @@ PromiseWorkerProxy::GetWorkerPrivate() const
|
||||
// the assertion when we should not.
|
||||
MOZ_ASSERT(!mCleanedUp);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (NS_IsMainThread()) {
|
||||
mCleanUpLock.AssertCurrentThreadOwns();
|
||||
}
|
||||
#endif
|
||||
|
||||
return mWorkerPrivate;
|
||||
}
|
||||
|
||||
Promise*
|
||||
PromiseWorkerProxy::GetWorkerPromise() const
|
||||
{
|
||||
|
||||
#ifdef DEBUG
|
||||
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(worker);
|
||||
worker->AssertIsOnWorkerThread();
|
||||
#endif
|
||||
return mWorkerPromise;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "ServiceWorkerWindowClient.h"
|
||||
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/dom/ClientBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/PromiseWorkerProxy.h"
|
||||
@ -108,6 +109,12 @@ private:
|
||||
void
|
||||
DispatchResult(UniquePtr<ServiceWorkerClientInfo>&& aClientInfo)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MutexAutoLock lock(mPromiseProxy->GetCleanUpLock());
|
||||
if (mPromiseProxy->IsClean()) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorkerPrivate* workerPrivate = mPromiseProxy->GetWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user