--- a/dom/animation/EffectSet.h
+++ b/dom/animation/EffectSet.h
@@ -29,18 +29,18 @@ enum class CSSPseudoElementType : uint8_
// A wrapper around a hashset of AnimationEffect objects to handle
// storing the set as a property of an element.
class EffectSet
{
public:
EffectSet()
: mCascadeNeedsUpdate(false)
, mAnimationGeneration(0)
+#ifdef DEBUG
, mActiveIterators(0)
-#ifdef DEBUG
, mCalledPropertyDtor(false)
#endif
{
MOZ_COUNT_CTOR(EffectSet);
}
~EffectSet()
{
@@ -82,38 +82,44 @@ public:
class Iterator
{
public:
explicit Iterator(EffectSet& aEffectSet)
: mEffectSet(aEffectSet)
, mHashIterator(mozilla::Move(aEffectSet.mEffects.Iter()))
, mIsEndIterator(false)
{
+#ifdef DEBUG
mEffectSet.mActiveIterators++;
+#endif
}
Iterator(Iterator&& aOther)
: mEffectSet(aOther.mEffectSet)
, mHashIterator(mozilla::Move(aOther.mHashIterator))
, mIsEndIterator(aOther.mIsEndIterator)
{
+#ifdef DEBUG
mEffectSet.mActiveIterators++;
+#endif
}
static Iterator EndIterator(EffectSet& aEffectSet)
{
Iterator result(aEffectSet);
result.mIsEndIterator = true;
return result;
}
~Iterator()
{
+#ifdef DEBUG
MOZ_ASSERT(mEffectSet.mActiveIterators > 0);
mEffectSet.mActiveIterators--;
+#endif
}
bool operator!=(const Iterator& aOther) const {
if (Done() || aOther.Done()) {
return Done() != aOther.Done();
}
return mHashIterator.Get() != aOther.mHashIterator.Get();
}
@@ -216,20 +222,20 @@ private:
// RestyleManager keeps track of the number of animation restyles.
// 'mini-flushes' (see nsTransitionManager::UpdateAllThrottledStyles()).
// mAnimationGeneration is the sequence number of the last flush where a
// transition/animation changed. We keep a similar count on the
// corresponding layer so we can check that the layer is up to date with
// the animation manager.
uint64_t mAnimationGeneration;
+#ifdef DEBUG
// Track how many iterators are referencing this effect set when we are
// destroyed, we can assert that nothing is still pointing to us.
- DebugOnly<uint64_t> mActiveIterators;
+ uint64_t mActiveIterators;
-#ifdef DEBUG
bool mCalledPropertyDtor;
#endif
};
} // namespace mozilla
#endif // mozilla_EffectSet_h
--- a/dom/canvas/WebGLContextLossHandler.h
+++ b/dom/canvas/WebGLContextLossHandler.h
@@ -21,17 +21,19 @@ class WebGLContext;
class WebGLContextLossHandler : public dom::workers::WorkerFeature
{
WeakPtr<WebGLContext> mWeakWebGL;
nsCOMPtr<nsITimer> mTimer;
bool mIsTimerRunning;
bool mShouldRunTimerAgain;
bool mIsDisabled;
bool mFeatureAdded;
- DebugOnly<nsIThread*> mThread;
+#ifdef DEBUG
+ nsIThread* mThread;
+#endif
public:
NS_INLINE_DECL_REFCOUNTING(WebGLContextLossHandler)
explicit WebGLContextLossHandler(WebGLContext* webgl);
void RunTimer();
void DisableTimer();
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -750,17 +750,19 @@ public:
return true;
}
};
template <class Derived>
FetchBody<Derived>::FetchBody()
: mFeature(nullptr)
, mBodyUsed(false)
+#ifdef DEBUG
, mReadDone(false)
+#endif
{
if (!NS_IsMainThread()) {
mWorkerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(mWorkerPrivate);
} else {
mWorkerPrivate = nullptr;
}
}
@@ -935,17 +937,19 @@ void
FetchBody<Derived>::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength, uint8_t* aResult)
{
AssertIsOnTargetThread();
// Just a precaution to ensure ContinueConsumeBody is not called out of
// sync with a body read.
MOZ_ASSERT(mBodyUsed);
MOZ_ASSERT(!mReadDone);
MOZ_ASSERT_IF(mWorkerPrivate, mFeature);
+#ifdef DEBUG
mReadDone = true;
+#endif
AutoFreeBuffer autoFree(aResult);
MOZ_ASSERT(mConsumePromise);
RefPtr<Promise> localPromise = mConsumePromise.forget();
RefPtr<Derived> kungfuDeathGrip = DerivedClass();
ReleaseObject();
--- a/dom/fetch/Fetch.h
+++ b/dom/fetch/Fetch.h
@@ -209,17 +209,19 @@ private:
// Only ever set once, always on target thread.
bool mBodyUsed;
nsCString mMimeType;
// Only touched on target thread.
ConsumeType mConsumeType;
RefPtr<Promise> mConsumePromise;
- DebugOnly<bool> mReadDone;
+#ifdef DEBUG
+ bool mReadDone;
+#endif
nsMainThreadPtrHandle<nsIInputStreamPump> mConsumeBodyPump;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_Fetch_h
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -45,34 +45,38 @@ NS_IMPL_ISUPPORTS(FetchDriver,
nsIStreamListener, nsIChannelEventSink, nsIInterfaceRequestor,
nsIThreadRetargetableStreamListener)
FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
nsILoadGroup* aLoadGroup)
: mPrincipal(aPrincipal)
, mLoadGroup(aLoadGroup)
, mRequest(aRequest)
+#ifdef DEBUG
, mResponseAvailableCalled(false)
, mFetchCalled(false)
+#endif
{
}
FetchDriver::~FetchDriver()
{
// We assert this since even on failures, we should call
// FailWithNetworkError().
MOZ_ASSERT(mResponseAvailableCalled);
}
nsresult
FetchDriver::Fetch(FetchDriverObserver* aObserver)
{
workers::AssertIsOnMainThread();
+#ifdef DEBUG
MOZ_ASSERT(!mFetchCalled);
mFetchCalled = true;
+#endif
mObserver = aObserver;
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_REQUEST_PASSTHROUGH,
mRequest->WasCreatedByFetchEvent());
// FIXME(nsm): Deal with HSTS.
@@ -383,28 +387,32 @@ FetchDriver::BeginAndGetFilteredResponse
default:
MOZ_CRASH("Unexpected case");
}
}
MOZ_ASSERT(filteredResponse);
MOZ_ASSERT(mObserver);
mObserver->OnResponseAvailable(filteredResponse);
+#ifdef DEBUG
mResponseAvailableCalled = true;
+#endif
return filteredResponse.forget();
}
void
FetchDriver::FailWithNetworkError()
{
workers::AssertIsOnMainThread();
RefPtr<InternalResponse> error = InternalResponse::NetworkError();
if (mObserver) {
mObserver->OnResponseAvailable(error);
+#ifdef DEBUG
mResponseAvailableCalled = true;
+#endif
mObserver->OnResponseEnd();
mObserver = nullptr;
}
}
namespace {
class FillResponseHeaders final : public nsIHttpHeaderVisitor {
InternalResponse* mResponse;
--- a/dom/fetch/FetchDriver.h
+++ b/dom/fetch/FetchDriver.h
@@ -78,18 +78,20 @@ private:
nsCOMPtr<nsIPrincipal> mPrincipal;
nsCOMPtr<nsILoadGroup> mLoadGroup;
RefPtr<InternalRequest> mRequest;
RefPtr<InternalResponse> mResponse;
nsCOMPtr<nsIOutputStream> mPipeOutputStream;
RefPtr<FetchDriverObserver> mObserver;
nsCOMPtr<nsIDocument> mDocument;
- DebugOnly<bool> mResponseAvailableCalled;
- DebugOnly<bool> mFetchCalled;
+#ifdef DEBUG
+ bool mResponseAvailableCalled;
+ bool mFetchCalled;
+#endif
FetchDriver() = delete;
FetchDriver(const FetchDriver&) = delete;
FetchDriver& operator=(const FetchDriver&) = delete;
~FetchDriver();
nsresult ContinueFetch();
nsresult HttpFetch();
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -5648,17 +5648,19 @@ struct ConnectionPool::TransactionInfo f
const int64_t mLoggingSerialNumber;
const nsTArray<nsString> mObjectStoreNames;
nsTHashtable<nsPtrHashKey<TransactionInfo>> mBlockedOn;
nsTHashtable<nsPtrHashKey<TransactionInfo>> mBlocking;
nsTArray<nsCOMPtr<nsIRunnable>> mQueuedRunnables;
const bool mIsWriteTransaction;
bool mRunning;
- DebugOnly<bool> mFinished;
+#ifdef DEBUG
+ bool mFinished;
+#endif
TransactionInfo(DatabaseInfo* aDatabaseInfo,
const nsID& aBackgroundChildLoggingId,
const nsACString& aDatabaseId,
uint64_t aTransactionId,
int64_t aLoggingSerialNumber,
const nsTArray<nsString>& aObjectStoreNames,
bool aIsWriteTransaction,
@@ -5908,17 +5910,19 @@ private:
// Not to be overridden by subclasses.
NS_DECL_MOZISTORAGEPROGRESSHANDLER
};
class MOZ_STACK_CLASS DatabaseOperationBase::AutoSetProgressHandler final
{
mozIStorageConnection* mConnection;
- DebugOnly<DatabaseOperationBase*> mDEBUGDatabaseOp;
+#ifdef DEBUG
+ DatabaseOperationBase* mDEBUGDatabaseOp;
+#endif
public:
AutoSetProgressHandler();
~AutoSetProgressHandler();
nsresult
Register(mozIStorageConnection* aConnection,
@@ -6009,17 +6013,19 @@ class Factory final
: public PBackgroundIDBFactoryParent
{
// Counts the number of "live" Factory instances that have not yet had
// ActorDestroy called.
static uint64_t sFactoryInstanceCount;
RefPtr<DatabaseLoggingInfo> mLoggingInfo;
- DebugOnly<bool> mActorDestroyed;
+#ifdef DEBUG
+ bool mActorDestroyed;
+#endif
public:
static already_AddRefed<Factory>
Create(const LoggingInfo& aLoggingInfo);
DatabaseLoggingInfo*
GetLoggingInfo() const
{
@@ -7919,26 +7925,30 @@ private:
virtual nsresult
DoDatabaseWork(DatabaseConnection* aConnection) override;
};
class NormalTransactionOp
: public TransactionDatabaseOperationBase
, public PBackgroundIDBRequestParent
{
- DebugOnly<bool> mResponseSent;
+#ifdef DEBUG
+ bool mResponseSent;
+#endif
public:
virtual void
Cleanup() override;
protected:
explicit NormalTransactionOp(TransactionBase* aTransaction)
: TransactionDatabaseOperationBase(aTransaction)
+#ifdef DEBUG
, mResponseSent(false)
+#endif
{ }
virtual
~NormalTransactionOp()
{ }
// An overload of DatabaseOperationBase's function that can avoid doing extra
// work on non-versionchange transactions.
@@ -8387,23 +8397,27 @@ class Cursor::CursorOpBase
: public TransactionDatabaseOperationBase
{
protected:
RefPtr<Cursor> mCursor;
nsTArray<FallibleTArray<StructuredCloneFile>> mFiles;
CursorResponse mResponse;
- DebugOnly<bool> mResponseSent;
+#ifdef DEBUG
+ bool mResponseSent;
+#endif
protected:
explicit CursorOpBase(Cursor* aCursor)
: TransactionDatabaseOperationBase(aCursor->mTransaction)
, mCursor(aCursor)
+#ifdef DEBUG
, mResponseSent(false)
+#endif
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(aCursor);
}
virtual
~CursorOpBase()
{ }
@@ -9240,26 +9254,30 @@ private:
class MOZ_STACK_CLASS DatabaseMaintenance::AutoProgressHandler final
: public mozIStorageProgressHandler
{
Maintenance* mMaintenance;
mozIStorageConnection* mConnection;
NS_DECL_OWNINGTHREAD
+#ifdef DEBUG
// This class is stack-based so we never actually allow AddRef/Release to do
// anything. But we need to know if any consumer *thinks* that they have a
// reference to this object so we track the reference countin DEBUG builds.
- DebugOnly<nsrefcnt> mDEBUGRefCnt;
+ nsrefcnt mDEBUGRefCnt;
+#endif
public:
explicit AutoProgressHandler(Maintenance* aMaintenance)
: mMaintenance(aMaintenance)
, mConnection(nullptr)
+#ifdef DEBUG
, mDEBUGRefCnt(0)
+#endif
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!IsOnBackgroundThread());
NS_ASSERT_OWNINGTHREAD(DatabaseMaintenance::AutoProgressHandler);
MOZ_ASSERT(aMaintenance);
}
~AutoProgressHandler()
@@ -12637,17 +12655,19 @@ TransactionInfo::TransactionInfo(
: mDatabaseInfo(aDatabaseInfo)
, mBackgroundChildLoggingId(aBackgroundChildLoggingId)
, mDatabaseId(aDatabaseId)
, mTransactionId(aTransactionId)
, mLoggingSerialNumber(aLoggingSerialNumber)
, mObjectStoreNames(aObjectStoreNames)
, mIsWriteTransaction(aIsWriteTransaction)
, mRunning(false)
+#ifdef DEBUG
, mFinished(false)
+#endif
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(aDatabaseInfo);
aDatabaseInfo->mConnectionPool->AssertIsOnOwningThread();
MOZ_COUNT_CTOR(ConnectionPool::TransactionInfo);
if (aTransactionOp) {
@@ -12788,17 +12808,19 @@ DatabaseLoggingInfo::~DatabaseLoggingInf
/*******************************************************************************
* Factory
******************************************************************************/
uint64_t Factory::sFactoryInstanceCount = 0;
Factory::Factory(already_AddRefed<DatabaseLoggingInfo> aLoggingInfo)
: mLoggingInfo(Move(aLoggingInfo))
+#ifdef DEBUG
, mActorDestroyed(false)
+#endif
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(!QuotaClient::IsShuttingDownOnBackgroundThread());
}
Factory::~Factory()
{
MOZ_ASSERT(mActorDestroyed);
@@ -12877,17 +12899,19 @@ Factory::Create(const LoggingInfo& aLogg
}
void
Factory::ActorDestroy(ActorDestroyReason aWhy)
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(!mActorDestroyed);
+#ifdef DEBUG
mActorDestroyed = true;
+#endif
// Clean up if there are no more instances.
if (!(--sFactoryInstanceCount)) {
MOZ_ASSERT(gLoggingInfoHashtable);
gLoggingInfoHashtable = nullptr;
MOZ_ASSERT(gLiveDatabaseHashtable);
MOZ_ASSERT(!gLiveDatabaseHashtable->Count());
@@ -18200,27 +18224,31 @@ AutoProgressHandler::Unregister()
}
NS_IMETHODIMP_(MozExternalRefCountType)
DatabaseMaintenance::
AutoProgressHandler::AddRef()
{
NS_ASSERT_OWNINGTHREAD(DatabaseMaintenance::AutoProgressHandler);
+#ifdef DEBUG
mDEBUGRefCnt++;
+#endif
return 2;
}
NS_IMETHODIMP_(MozExternalRefCountType)
DatabaseMaintenance::
AutoProgressHandler::Release()
{
NS_ASSERT_OWNINGTHREAD(DatabaseMaintenance::AutoProgressHandler);
+#ifdef DEBUG
mDEBUGRefCnt--;
+#endif
return 1;
}
NS_IMPL_QUERY_INTERFACE(DatabaseMaintenance::AutoProgressHandler,
mozIStorageProgressHandler)
NS_IMETHODIMP
DatabaseMaintenance::
@@ -19198,17 +19226,19 @@ DatabaseOperationBase::OnProgress(mozISt
// This is intentionally racy.
*_retval = !OperationMayProceed();
return NS_OK;
}
DatabaseOperationBase::
AutoSetProgressHandler::AutoSetProgressHandler()
: mConnection(nullptr)
+#ifdef DEBUG
, mDEBUGDatabaseOp(nullptr)
+#endif
{
MOZ_ASSERT(!IsOnBackgroundThread());
}
DatabaseOperationBase::
AutoSetProgressHandler::~AutoSetProgressHandler()
{
MOZ_ASSERT(!IsOnBackgroundThread());
@@ -19239,17 +19269,19 @@ AutoSetProgressHandler::Register(mozISto
getter_AddRefs(oldProgressHandler));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
MOZ_ASSERT(!oldProgressHandler);
mConnection = aConnection;
+#ifdef DEBUG
mDEBUGDatabaseOp = aDatabaseOp;
+#endif
return NS_OK;
}
MutableFile::MutableFile(nsIFile* aFile,
Database* aDatabase,
FileInfo* aFileInfo)
: BackgroundMutableFileParentBase(FILE_HANDLE_STORAGE_IDB,
@@ -24347,17 +24379,19 @@ NormalTransactionOp::SendSuccessResult()
if (NS_WARN_IF(!PBackgroundIDBRequestParent::Send__delete__(this,
response))) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
+#ifdef DEBUG
mResponseSent = true;
+#endif
return NS_OK;
}
bool
NormalTransactionOp::SendFailureResult(nsresult aResultCode)
{
AssertIsOnOwningThread();
@@ -24366,17 +24400,19 @@ NormalTransactionOp::SendFailureResult(n
bool result = false;
if (!IsActorDestroyed()) {
result =
PBackgroundIDBRequestParent::Send__delete__(this,
ClampResultCode(aResultCode));
}
+#ifdef DEBUG
mResponseSent = true;
+#endif
return result;
}
void
NormalTransactionOp::Cleanup()
{
AssertIsOnOwningThread();
@@ -26057,17 +26093,19 @@ CursorOpBase::SendFailureResult(nsresult
MOZ_ASSERT(!mResponseSent);
if (!IsActorDestroyed()) {
mResponse = ClampResultCode(aResultCode);
mCursor->SendResponseInternal(mResponse, mFiles);
}
+#ifdef DEBUG
mResponseSent = true;
+#endif
return false;
}
void
Cursor::
CursorOpBase::Cleanup()
{
AssertIsOnOwningThread();
@@ -27067,17 +27105,19 @@ OpenOp::SendSuccessResult()
mCursor->mObjectKey.IsUnset());
if (IsActorDestroyed()) {
return NS_ERROR_DOM_INDEXEDDB_ABORT_ERR;
}
mCursor->SendResponseInternal(mResponse, mFiles);
+#ifdef DEBUG
mResponseSent = true;
+#endif
return NS_OK;
}
nsresult
Cursor::
ContinueOp::DoDatabaseWork(DatabaseConnection* aConnection)
{
MOZ_ASSERT(aConnection);
@@ -27243,17 +27283,19 @@ ContinueOp::SendSuccessResult()
mCursor->mObjectKey.IsUnset());
if (IsActorDestroyed()) {
return NS_ERROR_DOM_INDEXEDDB_ABORT_ERR;
}
mCursor->SendResponseInternal(mResponse, mFiles);
+#ifdef DEBUG
mResponseSent = true;
+#endif
return NS_OK;
}
Utils::Utils()
#ifdef DEBUG
: mActorDestroyed(false)
#endif
{
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -292,17 +292,19 @@ TabParent::TabParent(nsIContentParent* a
, mDragAreaY(0)
, mInitedByParent(false)
, mTabId(aTabId)
, mCreatingWindow(false)
, mNeedLayerTreeReadyNotification(false)
, mCursor(nsCursor(-1))
, mTabSetsCursor(false)
, mHasContentOpener(false)
+#ifdef DEBUG
, mActiveSupressDisplayportCount(0)
+#endif
{
MOZ_ASSERT(aManager);
}
TabParent::~TabParent()
{
}
@@ -2830,23 +2832,24 @@ TabParent::SetDocShellIsActiveAndForegro
NS_IMETHODIMP
TabParent::SuppressDisplayport(bool aEnabled)
{
if (IsDestroyed()) {
return NS_OK;
}
+#ifdef DEBUG
if (aEnabled) {
mActiveSupressDisplayportCount++;
} else {
mActiveSupressDisplayportCount--;
}
-
MOZ_ASSERT(mActiveSupressDisplayportCount >= 0);
+#endif
Unused << SendSuppressDisplayport(aEnabled);
return NS_OK;
}
NS_IMETHODIMP
TabParent::GetTabId(uint64_t* aId)
{
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -715,17 +715,19 @@ private:
// True if the cursor changes from the TabChild should change the widget
// cursor. This happens whenever the cursor is in the tab's region.
bool mTabSetsCursor;
RefPtr<nsIPresShell> mPresShellWithRefreshListener;
bool mHasContentOpener;
- DebugOnly<int32_t> mActiveSupressDisplayportCount;
+#ifdef DEBUG
+ int32_t mActiveSupressDisplayportCount;
+#endif
ShowInfo GetShowInfo();
private:
// This is used when APZ needs to find the TabParent associated with a layer
// to dispatch events.
typedef nsDataHashtable<nsUint64HashKey, TabParent*> LayerToTabParentTable;
static LayerToTabParentTable* sLayerToTabParentTable;
--- a/dom/media/webrtc/GonkCameraImage.h
+++ b/dom/media/webrtc/GonkCameraImage.h
@@ -62,14 +62,16 @@ public:
protected:
virtual ~GonkCameraImage();
// mMonitor protects mMediaBuffer and mThread.
ReentrantMonitor mMonitor;
android::MediaBuffer* mMediaBuffer;
// Check if current thread is the same one which called SetMediaBuffer().
// It doesn't need to hold reference count.
- DebugOnly<nsIThread*> mThread;
+#ifdef DEBUG
+ nsIThread* mThread;
+#endif
};
} // namespace mozilla
#endif /* GONKCAMERAIMAGE_H */
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -2792,17 +2792,19 @@ NS_IMPL_ISUPPORTS0(PromiseWorkerProxy)
PromiseWorkerProxy::PromiseWorkerProxy(workers::WorkerPrivate* aWorkerPrivate,
Promise* aWorkerPromise,
const PromiseWorkerProxyStructuredCloneCallbacks* aCallbacks)
: mWorkerPrivate(aWorkerPrivate)
, mWorkerPromise(aWorkerPromise)
, mCleanedUp(false)
, mCallbacks(aCallbacks)
, mCleanUpLock("cleanUpLock")
+#ifdef DEBUG
, mFeatureAdded(false)
+#endif
{
}
PromiseWorkerProxy::~PromiseWorkerProxy()
{
MOZ_ASSERT(mCleanedUp);
MOZ_ASSERT(!mFeatureAdded);
MOZ_ASSERT(!mWorkerPromise);
@@ -2832,17 +2834,19 @@ PromiseWorkerProxy::AddRefObject()
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(!mFeatureAdded);
if (!mWorkerPrivate->AddFeature(this)) {
return false;
}
+#ifdef DEBUG
mFeatureAdded = true;
+#endif
// Maintain a reference so that we have a valid object to clean up when
// removing the feature.
AddRef();
return true;
}
workers::WorkerPrivate*
PromiseWorkerProxy::GetWorkerPrivate() const
@@ -2947,17 +2951,19 @@ PromiseWorkerProxy::CleanUp()
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
// Release the Promise and remove the PromiseWorkerProxy from the features of
// the worker thread since the Promise has been resolved/rejected or the
// worker thread has been cancelled.
MOZ_ASSERT(mFeatureAdded);
mWorkerPrivate->RemoveFeature(this);
+#ifdef DEBUG
mFeatureAdded = false;
+#endif
CleanProperties();
}
Release();
}
JSObject*
PromiseWorkerProxy::CustomReadHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
--- a/dom/promise/PromiseWorkerProxy.h
+++ b/dom/promise/PromiseWorkerProxy.h
@@ -222,15 +222,17 @@ private:
// Aimed to keep objects alive when doing the structured-clone read/write,
// which can be added by calling StoreISupports() on the main thread.
nsTArray<nsMainThreadPtrHandle<nsISupports>> mSupportsArray;
// Ensure the worker and the main thread won't race to access |mCleanedUp|.
Mutex mCleanUpLock;
+#ifdef DEBUG
// Maybe get rid of this entirely and rely on mCleanedUp
- DebugOnly<bool> mFeatureAdded;
+ bool mFeatureAdded;
+#endif
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_PromiseWorkerProxy_h
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -913,17 +913,19 @@ private:
/*******************************************************************************
* Actor class declarations
******************************************************************************/
class Quota final
: public PQuotaParent
{
- DebugOnly<bool> mActorDestroyed;
+#ifdef DEBUG
+ bool mActorDestroyed;
+#endif
public:
Quota();
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::dom::quota::Quota)
private:
~Quota();
@@ -5120,17 +5122,19 @@ SaveOriginAccessTimeOp::SendResults()
#endif
}
/*******************************************************************************
* Quota
******************************************************************************/
Quota::Quota()
+#ifdef DEBUG
: mActorDestroyed(false)
+#endif
{
}
Quota::~Quota()
{
MOZ_ASSERT(mActorDestroyed);
}
@@ -5147,19 +5151,20 @@ Quota::StartIdleMaintenance()
quotaManager->StartIdleMaintenance();
}
void
Quota::ActorDestroy(ActorDestroyReason aWhy)
{
AssertIsOnBackgroundThread();
+#ifdef DEBUG
MOZ_ASSERT(!mActorDestroyed);
-
mActorDestroyed = true;
+#endif
}
PQuotaUsageRequestParent*
Quota::AllocPQuotaUsageRequestParent(const UsageRequestParams& aParams)
{
RefPtr<GetUsageOp> actor = new GetUsageOp(aParams);
// Transfer ownership to IPDL.
--- a/dom/workers/ServiceWorkerEvents.cpp
+++ b/dom/workers/ServiceWorkerEvents.cpp
@@ -251,17 +251,19 @@ public:
return decision == nsIContentPolicy::ACCEPT;
}
};
class RespondWithHandler final : public PromiseNativeHandler
{
nsMainThreadPtrHandle<nsIInterceptedChannel> mInterceptedChannel;
const RequestMode mRequestMode;
- const DebugOnly<bool> mIsClientRequest;
+#ifdef DEBUG
+ const bool mIsClientRequest;
+#endif
const bool mIsNavigationRequest;
const nsCString mScriptSpec;
const nsString mRequestURL;
const nsCString mRespondWithScriptSpec;
const uint32_t mRespondWithLineNumber;
const uint32_t mRespondWithColumnNumber;
bool mRequestWasHandled;
public:
@@ -272,17 +274,19 @@ public:
bool aIsNavigationRequest,
const nsACString& aScriptSpec,
const nsAString& aRequestURL,
const nsACString& aRespondWithScriptSpec,
uint32_t aRespondWithLineNumber,
uint32_t aRespondWithColumnNumber)
: mInterceptedChannel(aChannel)
, mRequestMode(aRequestMode)
+#ifdef DEBUG
, mIsClientRequest(aIsClientRequest)
+#endif
, mIsNavigationRequest(aIsNavigationRequest)
, mScriptSpec(aScriptSpec)
, mRequestURL(aRequestURL)
, mRespondWithScriptSpec(aRespondWithScriptSpec)
, mRespondWithLineNumber(aRespondWithLineNumber)
, mRespondWithColumnNumber(aRespondWithColumnNumber)
, mRequestWasHandled(false)
{
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -101,26 +101,30 @@ ServiceWorkerPrivate::SendMessageEvent(J
}
namespace {
class CheckScriptEvaluationWithCallback final : public WorkerRunnable
{
nsMainThreadPtrHandle<KeepAliveToken> mKeepAliveToken;
RefPtr<LifeCycleEventCallback> mCallback;
- DebugOnly<bool> mDone;
+#ifdef DEBUG
+ bool mDone;
+#endif
public:
CheckScriptEvaluationWithCallback(WorkerPrivate* aWorkerPrivate,
KeepAliveToken* aKeepAliveToken,
LifeCycleEventCallback* aCallback)
: WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount)
, mKeepAliveToken(new nsMainThreadPtrHolder<KeepAliveToken>(aKeepAliveToken))
, mCallback(aCallback)
+#ifdef DEBUG
, mDone(false)
+#endif
{
AssertIsOnMainThread();
}
~CheckScriptEvaluationWithCallback()
{
MOZ_ASSERT(mDone);
}
@@ -140,17 +144,19 @@ public:
Done(false);
return WorkerRunnable::Cancel();
}
private:
void
Done(bool aResult)
{
+#ifdef DEBUG
mDone = true;
+#endif
mCallback->SetResult(aResult);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(mCallback)));
}
};
} // anonymous namespace
nsresult
--- a/dom/workers/WorkerThread.cpp
+++ b/dom/workers/WorkerThread.cpp
@@ -64,17 +64,19 @@ private:
NS_DECL_NSITHREADOBSERVER
};
WorkerThread::WorkerThread()
: nsThread(nsThread::NOT_MAIN_THREAD, kWorkerStackSize)
, mWorkerPrivateCondVar(mLock, "WorkerThread::mWorkerPrivateCondVar")
, mWorkerPrivate(nullptr)
, mOtherThreadsDispatchingViaEventTarget(0)
+#ifdef DEBUG
, mAcceptingNonWorkerRunnables(true)
+#endif
{
}
WorkerThread::~WorkerThread()
{
MOZ_ASSERT(!mWorkerPrivate);
MOZ_ASSERT(!mOtherThreadsDispatchingViaEventTarget);
MOZ_ASSERT(mAcceptingNonWorkerRunnables);
@@ -104,17 +106,19 @@ WorkerThread::SetWorker(const WorkerThre
if (aWorkerPrivate) {
{
MutexAutoLock lock(mLock);
MOZ_ASSERT(!mWorkerPrivate);
MOZ_ASSERT(mAcceptingNonWorkerRunnables);
mWorkerPrivate = aWorkerPrivate;
+#ifdef DEBUG
mAcceptingNonWorkerRunnables = false;
+#endif
}
mObserver = new Observer(aWorkerPrivate);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(AddObserver(mObserver)));
} else {
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(RemoveObserver(mObserver)));
mObserver = nullptr;
@@ -126,17 +130,19 @@ WorkerThread::SetWorker(const WorkerThre
MOZ_ASSERT(!mOtherThreadsDispatchingViaEventTarget,
"XPCOM Dispatch hapenning at the same time our thread is "
"being unset! This should not be possible!");
while (mOtherThreadsDispatchingViaEventTarget) {
mWorkerPrivateCondVar.Wait();
}
+#ifdef DEBUG
mAcceptingNonWorkerRunnables = true;
+#endif
mWorkerPrivate = nullptr;
}
}
}
nsresult
WorkerThread::DispatchPrimaryRunnable(const WorkerThreadFriendKey& /* aKey */,
already_AddRefed<nsIRunnable>&& aRunnable)
--- a/dom/workers/WorkerThread.h
+++ b/dom/workers/WorkerThread.h
@@ -49,18 +49,20 @@ class WorkerThread final
WorkerPrivate* mWorkerPrivate;
// Only touched on the target thread.
RefPtr<Observer> mObserver;
// Protected by nsThread::mLock and waited on with mWorkerPrivateCondVar.
uint32_t mOtherThreadsDispatchingViaEventTarget;
+#ifdef DEBUG
// Protected by nsThread::mLock.
- DebugOnly<bool> mAcceptingNonWorkerRunnables;
+ bool mAcceptingNonWorkerRunnables;
+#endif
public:
static already_AddRefed<WorkerThread>
Create(const WorkerThreadFriendKey& aKey);
void
SetWorker(const WorkerThreadFriendKey& aKey, WorkerPrivate* aWorkerPrivate);