Bug 1540401 - LSNG: Convert most of MOZ_ASSERT to MOZ_DIAGNOSTIC_ASSERT; r=asuth

Differential Revision: https://phabricator.services.mozilla.com/D25549
This commit is contained in:
Jan Varga 2019-04-01 01:18:10 +02:00
Родитель 270308cb07
Коммит 8838c839de
11 изменённых файлов: 756 добавлений и 726 удалений

Просмотреть файл

@ -21,7 +21,7 @@ namespace dom {
LSDatabaseChild::LSDatabaseChild(LSDatabase* aDatabase) : mDatabase(aDatabase) {
AssertIsOnOwningThread();
MOZ_ASSERT(aDatabase);
MOZ_DIAGNOSTIC_ASSERT(aDatabase);
MOZ_COUNT_CTOR(LSDatabaseChild);
}
@ -78,7 +78,7 @@ PBackgroundLSSnapshotChild* LSDatabaseChild::AllocPBackgroundLSSnapshotChild(
bool LSDatabaseChild::DeallocPBackgroundLSSnapshotChild(
PBackgroundLSSnapshotChild* aActor) {
MOZ_ASSERT(aActor);
MOZ_DIAGNOSTIC_ASSERT(aActor);
delete aActor;
return true;
@ -90,7 +90,7 @@ bool LSDatabaseChild::DeallocPBackgroundLSSnapshotChild(
LSObserverChild::LSObserverChild(LSObserver* aObserver) : mObserver(aObserver) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObserver);
MOZ_DIAGNOSTIC_ASSERT(aObserver);
MOZ_COUNT_CTOR(LSObserverChild);
}
@ -179,7 +179,7 @@ void LSRequestChild::ActorDestroy(ActorDestroyReason aWhy) {
mozilla::ipc::IPCResult LSRequestChild::Recv__delete__(
const LSRequestResponse& aResponse) {
AssertIsOnOwningThread();
MOZ_ASSERT(mCallback);
MOZ_DIAGNOSTIC_ASSERT(mCallback);
mCallback->OnResponse(aResponse);
@ -204,7 +204,7 @@ LSSimpleRequestChild::LSSimpleRequestChild(
LSSimpleRequestChildCallback* aCallback)
: mCallback(aCallback) {
AssertIsOnOwningThread();
MOZ_ASSERT(aCallback);
MOZ_DIAGNOSTIC_ASSERT(aCallback);
MOZ_COUNT_CTOR(LSSimpleRequestChild);
}
@ -234,7 +234,7 @@ mozilla::ipc::IPCResult LSSimpleRequestChild::Recv__delete__(
LSSnapshotChild::LSSnapshotChild(LSSnapshot* aSnapshot) : mSnapshot(aSnapshot) {
AssertIsOnOwningThread();
MOZ_ASSERT(aSnapshot);
MOZ_DIAGNOSTIC_ASSERT(aSnapshot);
MOZ_COUNT_CTOR(LSSnapshotChild);
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -45,24 +45,24 @@ LSDatabase::LSDatabase(const nsACString& aOrigin)
if (!gLSDatabases) {
gLSDatabases = new LSDatabaseHashtable();
MOZ_ASSERT(!sObserver);
MOZ_DIAGNOSTIC_ASSERT(!sObserver);
sObserver = new Observer();
nsCOMPtr<nsIObserverService> obsSvc = GetObserverService();
MOZ_ASSERT(obsSvc);
MOZ_DIAGNOSTIC_ASSERT(obsSvc);
MOZ_ALWAYS_SUCCEEDS(
obsSvc->AddObserver(sObserver, XPCOM_SHUTDOWN_OBSERVER_TOPIC, false));
}
MOZ_ASSERT(!gLSDatabases->Get(mOrigin));
MOZ_DIAGNOSTIC_ASSERT(!gLSDatabases->Get(mOrigin));
gLSDatabases->Put(mOrigin, this);
}
LSDatabase::~LSDatabase() {
AssertIsOnOwningThread();
MOZ_ASSERT(!mSnapshot);
MOZ_DIAGNOSTIC_ASSERT(!mSnapshot);
if (!mAllowedToClose) {
AllowToClose();
@ -70,7 +70,7 @@ LSDatabase::~LSDatabase() {
if (mActor) {
mActor->SendDeleteMeInternal();
MOZ_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
MOZ_DIAGNOSTIC_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
}
}
@ -81,8 +81,8 @@ LSDatabase* LSDatabase::Get(const nsACString& aOrigin) {
void LSDatabase::SetActor(LSDatabaseChild* aActor) {
AssertIsOnOwningThread();
MOZ_ASSERT(aActor);
MOZ_ASSERT(!mActor);
MOZ_DIAGNOSTIC_ASSERT(aActor);
MOZ_DIAGNOSTIC_ASSERT(!mActor);
mActor = aActor;
}
@ -105,7 +105,7 @@ void LSDatabase::RequestAllowToClose() {
void LSDatabase::NoteFinishedSnapshot(LSSnapshot* aSnapshot) {
AssertIsOnOwningThread();
MOZ_ASSERT(aSnapshot == mSnapshot);
MOZ_DIAGNOSTIC_ASSERT(aSnapshot == mSnapshot);
mSnapshot = nullptr;
@ -116,9 +116,9 @@ void LSDatabase::NoteFinishedSnapshot(LSSnapshot* aSnapshot) {
nsresult LSDatabase::GetLength(LSObject* aObject, uint32_t* aResult) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
nsresult rv = EnsureSnapshot(aObject);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -136,9 +136,9 @@ nsresult LSDatabase::GetLength(LSObject* aObject, uint32_t* aResult) {
nsresult LSDatabase::GetKey(LSObject* aObject, uint32_t aIndex,
nsAString& aResult) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
nsresult rv = EnsureSnapshot(aObject);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -156,9 +156,9 @@ nsresult LSDatabase::GetKey(LSObject* aObject, uint32_t aIndex,
nsresult LSDatabase::GetItem(LSObject* aObject, const nsAString& aKey,
nsAString& aResult) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
nsresult rv = EnsureSnapshot(aObject);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -175,9 +175,9 @@ nsresult LSDatabase::GetItem(LSObject* aObject, const nsAString& aKey,
nsresult LSDatabase::GetKeys(LSObject* aObject, nsTArray<nsString>& aKeys) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
nsresult rv = EnsureSnapshot(aObject);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -196,9 +196,9 @@ nsresult LSDatabase::SetItem(LSObject* aObject, const nsAString& aKey,
const nsAString& aValue,
LSNotifyInfo& aNotifyInfo) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
nsresult rv = EnsureSnapshot(aObject);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -216,9 +216,9 @@ nsresult LSDatabase::SetItem(LSObject* aObject, const nsAString& aKey,
nsresult LSDatabase::RemoveItem(LSObject* aObject, const nsAString& aKey,
LSNotifyInfo& aNotifyInfo) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
nsresult rv = EnsureSnapshot(aObject);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -235,9 +235,9 @@ nsresult LSDatabase::RemoveItem(LSObject* aObject, const nsAString& aKey,
nsresult LSDatabase::Clear(LSObject* aObject, LSNotifyInfo& aNotifyInfo) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
nsresult rv = EnsureSnapshot(aObject);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -254,9 +254,9 @@ nsresult LSDatabase::Clear(LSObject* aObject, LSNotifyInfo& aNotifyInfo) {
nsresult LSDatabase::BeginExplicitSnapshot(LSObject* aObject) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
if (mSnapshot) {
return NS_ERROR_ALREADY_INITIALIZED;
@ -272,15 +272,15 @@ nsresult LSDatabase::BeginExplicitSnapshot(LSObject* aObject) {
nsresult LSDatabase::EndExplicitSnapshot(LSObject* aObject) {
AssertIsOnOwningThread();
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
if (!mSnapshot) {
return NS_ERROR_NOT_INITIALIZED;
}
MOZ_ASSERT(mSnapshot->Explicit());
MOZ_DIAGNOSTIC_ASSERT(mSnapshot->Explicit());
nsresult rv = mSnapshot->End();
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -291,10 +291,10 @@ nsresult LSDatabase::EndExplicitSnapshot(LSObject* aObject) {
}
nsresult LSDatabase::EnsureSnapshot(LSObject* aObject, bool aExplicit) {
MOZ_ASSERT(aObject);
MOZ_ASSERT(mActor);
MOZ_ASSERT_IF(mSnapshot, !aExplicit);
MOZ_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT_IF(mSnapshot, !aExplicit);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
if (mSnapshot) {
return NS_OK;
@ -330,8 +330,8 @@ nsresult LSDatabase::EnsureSnapshot(LSObject* aObject, bool aExplicit) {
void LSDatabase::AllowToClose() {
AssertIsOnOwningThread();
MOZ_ASSERT(!mAllowedToClose);
MOZ_ASSERT(!mSnapshot);
MOZ_DIAGNOSTIC_ASSERT(!mAllowedToClose);
MOZ_DIAGNOSTIC_ASSERT(!mSnapshot);
mAllowedToClose = true;
@ -339,17 +339,17 @@ void LSDatabase::AllowToClose() {
mActor->SendAllowToClose();
}
MOZ_ASSERT(gLSDatabases);
MOZ_ASSERT(gLSDatabases->Get(mOrigin));
MOZ_DIAGNOSTIC_ASSERT(gLSDatabases);
MOZ_DIAGNOSTIC_ASSERT(gLSDatabases->Get(mOrigin));
gLSDatabases->Remove(mOrigin);
if (!gLSDatabases->Count()) {
gLSDatabases = nullptr;
MOZ_ASSERT(sObserver);
MOZ_DIAGNOSTIC_ASSERT(sObserver);
nsCOMPtr<nsIObserverService> obsSvc = GetObserverService();
MOZ_ASSERT(obsSvc);
MOZ_DIAGNOSTIC_ASSERT(obsSvc);
MOZ_ALWAYS_SUCCEEDS(
obsSvc->RemoveObserver(sObserver, XPCOM_SHUTDOWN_OBSERVER_TOPIC));
@ -364,14 +364,14 @@ NS_IMETHODIMP
LSDatabase::Observer::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!strcmp(aTopic, XPCOM_SHUTDOWN_OBSERVER_TOPIC));
MOZ_ASSERT(gLSDatabases);
MOZ_DIAGNOSTIC_ASSERT(!strcmp(aTopic, XPCOM_SHUTDOWN_OBSERVER_TOPIC));
MOZ_DIAGNOSTIC_ASSERT(gLSDatabases);
nsTArray<RefPtr<LSDatabase>> databases;
for (auto iter = gLSDatabases->ConstIter(); !iter.Done(); iter.Next()) {
LSDatabase* database = iter.Data();
MOZ_ASSERT(database);
MOZ_DIAGNOSTIC_ASSERT(database);
databases.AppendElement(database);
}

Просмотреть файл

@ -40,7 +40,7 @@ class LSDatabase final {
void ClearActor() {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
mActor = nullptr;
}

Просмотреть файл

@ -164,7 +164,7 @@ class RequestHelper final : public Runnable, public LSRequestChildCallback {
mCancelled(false) {}
bool IsOnOwningThread() const {
MOZ_ASSERT(mOwningEventTarget);
MOZ_DIAGNOSTIC_ASSERT(mOwningEventTarget);
bool current;
return NS_SUCCEEDED(mOwningEventTarget->IsOnCurrentThread(&current)) &&
@ -200,7 +200,7 @@ LSObject::LSObject(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
mPrivateBrowsingId(0),
mInExplicitSnapshot(false) {
AssertIsOnOwningThread();
MOZ_ASSERT(NextGenLocalStorageEnabled());
MOZ_DIAGNOSTIC_ASSERT(NextGenLocalStorageEnabled());
}
LSObject::~LSObject() {
@ -241,14 +241,14 @@ void LSObject::Initialize() {
nsresult LSObject::CreateForWindow(nsPIDOMWindowInner* aWindow,
Storage** aStorage) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aStorage);
MOZ_ASSERT(NextGenLocalStorageEnabled());
MOZ_ASSERT(nsContentUtils::StorageAllowedForWindow(aWindow) >
nsContentUtils::StorageAccess::eDeny);
MOZ_DIAGNOSTIC_ASSERT(aWindow);
MOZ_DIAGNOSTIC_ASSERT(aStorage);
MOZ_DIAGNOSTIC_ASSERT(NextGenLocalStorageEnabled());
MOZ_DIAGNOSTIC_ASSERT(nsContentUtils::StorageAllowedForWindow(aWindow) >
nsContentUtils::StorageAccess::eDeny);
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aWindow);
MOZ_ASSERT(sop);
MOZ_DIAGNOSTIC_ASSERT(sop);
nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
if (NS_WARN_IF(!principal)) {
@ -275,7 +275,8 @@ nsresult LSObject::CreateForWindow(nsPIDOMWindowInner* aWindow,
return rv;
}
MOZ_ASSERT(principalInfo->type() == PrincipalInfo::TContentPrincipalInfo);
MOZ_DIAGNOSTIC_ASSERT(principalInfo->type() ==
PrincipalInfo::TContentPrincipalInfo);
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(*principalInfo))) {
return NS_ERROR_FAILURE;
@ -288,7 +289,7 @@ nsresult LSObject::CreateForWindow(nsPIDOMWindowInner* aWindow,
return rv;
}
MOZ_ASSERT(originAttrSuffix == suffix);
MOZ_DIAGNOSTIC_ASSERT(originAttrSuffix == suffix);
uint32_t privateBrowsingId;
rv = principal->GetPrivateBrowsingId(&privateBrowsingId);
@ -329,8 +330,8 @@ nsresult LSObject::CreateForPrincipal(nsPIDOMWindowInner* aWindow,
const nsAString& aDocumentURI,
bool aPrivate, LSObject** aObject) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(aObject);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(aObject);
nsCString originAttrSuffix;
nsCString originKey;
@ -345,8 +346,9 @@ nsresult LSObject::CreateForPrincipal(nsPIDOMWindowInner* aWindow,
return rv;
}
MOZ_ASSERT(principalInfo->type() == PrincipalInfo::TContentPrincipalInfo ||
principalInfo->type() == PrincipalInfo::TSystemPrincipalInfo);
MOZ_DIAGNOSTIC_ASSERT(
principalInfo->type() == PrincipalInfo::TContentPrincipalInfo ||
principalInfo->type() == PrincipalInfo::TSystemPrincipalInfo);
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(*principalInfo))) {
return NS_ERROR_FAILURE;
@ -365,7 +367,7 @@ nsresult LSObject::CreateForPrincipal(nsPIDOMWindowInner* aWindow,
}
}
MOZ_ASSERT(originAttrSuffix == suffix);
MOZ_DIAGNOSTIC_ASSERT(originAttrSuffix == suffix);
Maybe<nsID> clientId;
if (aWindow) {
@ -456,7 +458,7 @@ Storage::StorageType LSObject::Type() const {
bool LSObject::IsForkOf(const Storage* aStorage) const {
AssertIsOnOwningThread();
MOZ_ASSERT(aStorage);
MOZ_DIAGNOSTIC_ASSERT(aStorage);
if (aStorage->Type() != eLocalStorage) {
return false;
@ -796,7 +798,7 @@ nsresult LSObject::EnsureDatabase() {
mDatabase = LSDatabase::Get(mOrigin);
if (mDatabase) {
MOZ_ASSERT(!mDatabase->IsAllowedToClose());
MOZ_DIAGNOSTIC_ASSERT(!mDatabase->IsAllowedToClose());
return NS_OK;
}
@ -824,8 +826,8 @@ nsresult LSObject::EnsureDatabase() {
return rv;
}
MOZ_ASSERT(response.type() ==
LSRequestResponse::TLSRequestPrepareDatastoreResponse);
MOZ_DIAGNOSTIC_ASSERT(response.type() ==
LSRequestResponse::TLSRequestPrepareDatastoreResponse);
const LSRequestPrepareDatastoreResponse& prepareDatastoreResponse =
response.get_LSRequestPrepareDatastoreResponse();
@ -888,8 +890,8 @@ nsresult LSObject::EnsureObserver() {
return rv;
}
MOZ_ASSERT(response.type() ==
LSRequestResponse::TLSRequestPrepareObserverResponse);
MOZ_DIAGNOSTIC_ASSERT(response.type() ==
LSRequestResponse::TLSRequestPrepareObserverResponse);
const LSRequestPrepareObserverResponse& prepareObserverResponse =
response.get_LSRequestPrepareObserverResponse();
@ -904,7 +906,7 @@ nsresult LSObject::EnsureObserver() {
// strong reference to the observer.
PBackgroundChild* backgroundActor = BackgroundChild::GetForCurrentThread();
MOZ_ASSERT(backgroundActor);
MOZ_DIAGNOSTIC_ASSERT(backgroundActor);
RefPtr<LSObserver> observer = new LSObserver(mOrigin);
@ -943,20 +945,20 @@ nsresult LSObject::EndExplicitSnapshotInternal() {
// Can be only called if the mInExplicitSnapshot flag is true.
// An explicit snapshot must have been created.
MOZ_ASSERT(mInExplicitSnapshot);
MOZ_DIAGNOSTIC_ASSERT(mInExplicitSnapshot);
// If an explicit snapshot have been created then mDatabase must be not null.
// DropDatabase could be called in the meatime, but that would set
// mInExplicitSnapshot to false. EnsureDatabase could be called in the
// meantime too, but that can't set mDatabase to null or to a new value. See
// the comment below.
MOZ_ASSERT(mDatabase);
MOZ_DIAGNOSTIC_ASSERT(mDatabase);
// Existence of a snapshot prevents the database from allowing to close. See
// LSDatabase::RequestAllowToClose and LSDatabase::NoteFinishedSnapshot.
// If the database is not allowed to close then mDatabase could not have been
// nulled out or set to a new value. See EnsureDatabase.
MOZ_ASSERT(!mDatabase->IsAllowedToClose());
MOZ_DIAGNOSTIC_ASSERT(!mDatabase->IsAllowedToClose());
nsresult rv = mDatabase->EndExplicitSnapshot(this);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -994,7 +996,7 @@ NestedEventTargetWrapper::IsOnCurrentThread(bool* aResult) {
NS_IMETHODIMP
NestedEventTargetWrapper::Dispatch(already_AddRefed<nsIRunnable> aEvent,
uint32_t aFlags) {
MOZ_ASSERT(mNestedEventTarget);
MOZ_DIAGNOSTIC_ASSERT(mNestedEventTarget);
if (mDisconnected) {
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(std::move(aEvent), aFlags));
@ -1057,7 +1059,7 @@ nsresult RequestHelper::StartAndReturnResponse(LSRequestResponse& aResponse) {
const nsLocalExecutionGuard localExecution(thread->EnterLocalExecution());
mNestedEventTarget = localExecution.GetEventTarget();
MOZ_ASSERT(mNestedEventTarget);
MOZ_DIAGNOSTIC_ASSERT(mNestedEventTarget);
mNestedEventTargetWrapper =
new NestedEventTargetWrapper(mNestedEventTarget);
@ -1179,7 +1181,7 @@ nsresult RequestHelper::StartAndReturnResponse(LSRequestResponse& aResponse) {
nsresult RequestHelper::Start() {
AssertIsOnDOMFileThread();
MOZ_ASSERT(mState == State::Initial);
MOZ_DIAGNOSTIC_ASSERT(mState == State::Initial);
mState = State::ResponsePending;
@ -1196,7 +1198,7 @@ nsresult RequestHelper::Start() {
void RequestHelper::Finish() {
AssertIsOnOwningThread();
MOZ_ASSERT(mState == State::Finishing);
MOZ_DIAGNOSTIC_ASSERT(mState == State::Finishing);
mObject = nullptr;
@ -1244,7 +1246,7 @@ RequestHelper::Run() {
void RequestHelper::OnResponse(const LSRequestResponse& aResponse) {
AssertIsOnDOMFileThread();
MOZ_ASSERT(mState == State::ResponsePending);
MOZ_DIAGNOSTIC_ASSERT(mState == State::ResponsePending);
mActor = nullptr;

Просмотреть файл

@ -31,7 +31,7 @@ LSObserver::LSObserver(const nsACString& aOrigin)
gLSObservers = new LSObserverHashtable();
}
MOZ_ASSERT(!gLSObservers->Get(mOrigin));
MOZ_DIAGNOSTIC_ASSERT(!gLSObservers->Get(mOrigin));
gLSObservers->Put(mOrigin, this);
}
@ -40,11 +40,11 @@ LSObserver::~LSObserver() {
if (mActor) {
mActor->SendDeleteMeInternal();
MOZ_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
MOZ_DIAGNOSTIC_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
}
MOZ_ASSERT(gLSObservers);
MOZ_ASSERT(gLSObservers->Get(mOrigin));
MOZ_DIAGNOSTIC_ASSERT(gLSObservers);
MOZ_DIAGNOSTIC_ASSERT(gLSObservers->Get(mOrigin));
gLSObservers->Remove(mOrigin);
if (!gLSObservers->Count()) {
@ -59,8 +59,8 @@ LSObserver* LSObserver::Get(const nsACString& aOrigin) {
void LSObserver::SetActor(LSObserverChild* aActor) {
AssertIsOnOwningThread();
MOZ_ASSERT(aActor);
MOZ_ASSERT(!mActor);
MOZ_DIAGNOSTIC_ASSERT(aActor);
MOZ_DIAGNOSTIC_ASSERT(!mActor);
mActor = aActor;
}

Просмотреть файл

@ -48,7 +48,7 @@ class LSObserver final {
void ClearActor() {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
mActor = nullptr;
}

Просмотреть файл

@ -29,7 +29,7 @@ LSSnapshot::LSSnapshot(LSDatabase* aDatabase)
mHasPendingStableStateCallback(false),
mHasPendingTimerCallback(false),
mDirty(false)
#ifdef DEBUG
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
,
mInitialized(false),
mSentFinish(false)
@ -40,32 +40,32 @@ LSSnapshot::LSSnapshot(LSDatabase* aDatabase)
LSSnapshot::~LSSnapshot() {
AssertIsOnOwningThread();
MOZ_ASSERT(mDatabase);
MOZ_ASSERT(!mHasPendingStableStateCallback);
MOZ_ASSERT(!mHasPendingTimerCallback);
MOZ_ASSERT_IF(mInitialized, mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mDatabase);
MOZ_DIAGNOSTIC_ASSERT(!mHasPendingStableStateCallback);
MOZ_DIAGNOSTIC_ASSERT(!mHasPendingTimerCallback);
MOZ_DIAGNOSTIC_ASSERT_IF(mInitialized, mSentFinish);
if (mActor) {
mActor->SendDeleteMeInternal();
MOZ_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
MOZ_DIAGNOSTIC_ASSERT(!mActor, "SendDeleteMeInternal should have cleared!");
}
}
void LSSnapshot::SetActor(LSSnapshotChild* aActor) {
AssertIsOnOwningThread();
MOZ_ASSERT(aActor);
MOZ_ASSERT(!mActor);
MOZ_DIAGNOSTIC_ASSERT(aActor);
MOZ_DIAGNOSTIC_ASSERT(!mActor);
mActor = aActor;
}
nsresult LSSnapshot::Init(const LSSnapshotInitInfo& aInitInfo, bool aExplicit) {
AssertIsOnOwningThread();
MOZ_ASSERT(!mSelfRef);
MOZ_ASSERT(mActor);
MOZ_ASSERT(mLoadState == LoadState::Initial);
MOZ_ASSERT(!mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(!mSelfRef);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mLoadState == LoadState::Initial);
MOZ_DIAGNOSTIC_ASSERT(!mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
mSelfRef = this;
@ -90,7 +90,7 @@ nsresult LSSnapshot::Init(const LSSnapshotInitInfo& aInitInfo, bool aExplicit) {
} else if (loadState == LoadState::AllOrderedKeys) {
mInitLength = aInitInfo.totalLength();
} else {
MOZ_ASSERT(loadState == LoadState::AllOrderedItems);
MOZ_DIAGNOSTIC_ASSERT(loadState == LoadState::AllOrderedItems);
}
mExactUsage = aInitInfo.initialUsage();
@ -100,13 +100,13 @@ nsresult LSSnapshot::Init(const LSSnapshotInitInfo& aInitInfo, bool aExplicit) {
mExplicit = aExplicit;
#ifdef DEBUG
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
mInitialized = true;
#endif
if (!mExplicit) {
mTimer = NS_NewTimer();
MOZ_ASSERT(mTimer);
MOZ_DIAGNOSTIC_ASSERT(mTimer);
ScheduleStableStateCallback();
}
@ -116,9 +116,9 @@ nsresult LSSnapshot::Init(const LSSnapshotInitInfo& aInitInfo, bool aExplicit) {
nsresult LSSnapshot::GetLength(uint32_t* aResult) {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MaybeScheduleStableStateCallback();
@ -133,9 +133,9 @@ nsresult LSSnapshot::GetLength(uint32_t* aResult) {
nsresult LSSnapshot::GetKey(uint32_t aIndex, nsAString& aResult) {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MaybeScheduleStableStateCallback();
@ -158,9 +158,9 @@ nsresult LSSnapshot::GetKey(uint32_t aIndex, nsAString& aResult) {
nsresult LSSnapshot::GetItem(const nsAString& aKey, nsAString& aResult) {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MaybeScheduleStableStateCallback();
@ -176,9 +176,9 @@ nsresult LSSnapshot::GetItem(const nsAString& aKey, nsAString& aResult) {
nsresult LSSnapshot::GetKeys(nsTArray<nsString>& aKeys) {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MaybeScheduleStableStateCallback();
@ -197,9 +197,9 @@ nsresult LSSnapshot::GetKeys(nsTArray<nsString>& aKeys) {
nsresult LSSnapshot::SetItem(const nsAString& aKey, const nsAString& aValue,
LSNotifyInfo& aNotifyInfo) {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MaybeScheduleStableStateCallback();
@ -254,9 +254,9 @@ nsresult LSSnapshot::SetItem(const nsAString& aKey, const nsAString& aValue,
nsresult LSSnapshot::RemoveItem(const nsAString& aKey,
LSNotifyInfo& aNotifyInfo) {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MaybeScheduleStableStateCallback();
@ -276,8 +276,12 @@ nsresult LSSnapshot::RemoveItem(const nsAString& aKey,
int64_t delta = -(static_cast<int64_t>(aKey.Length()) +
static_cast<int64_t>(oldValue.Length()));
DebugOnly<nsresult> rv = UpdateUsage(delta);
MOZ_ASSERT(NS_SUCCEEDED(rv));
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
nsresult rv = UpdateUsage(delta);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
#else
UpdateUsage(delta);
#endif
if (mLoadState == LoadState::Partial) {
mLength--;
@ -298,16 +302,16 @@ nsresult LSSnapshot::RemoveItem(const nsAString& aKey,
nsresult LSSnapshot::Clear(LSNotifyInfo& aNotifyInfo) {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MaybeScheduleStableStateCallback();
uint32_t length;
if (mLoadState == LoadState::Partial) {
length = mLength;
MOZ_ASSERT(length);
MOZ_DIAGNOSTIC_ASSERT(length);
MOZ_ALWAYS_TRUE(mActor->SendLoaded());
@ -325,8 +329,12 @@ nsresult LSSnapshot::Clear(LSNotifyInfo& aNotifyInfo) {
} else {
changed = true;
DebugOnly<nsresult> rv = UpdateUsage(-mExactUsage);
MOZ_ASSERT(NS_SUCCEEDED(rv));
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
nsresult rv = UpdateUsage(-mExactUsage);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
#else
UpdateUsage(-mExactUsage);
#endif
mValues.Clear();
@ -342,9 +350,9 @@ nsresult LSSnapshot::Clear(LSNotifyInfo& aNotifyInfo) {
void LSSnapshot::MarkDirty() {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
if (mDirty) {
return;
@ -359,18 +367,18 @@ void LSSnapshot::MarkDirty() {
MOZ_ALWAYS_SUCCEEDS(Finish());
} else {
MOZ_ASSERT(!mHasPendingTimerCallback);
MOZ_DIAGNOSTIC_ASSERT(!mHasPendingTimerCallback);
}
}
nsresult LSSnapshot::End() {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mExplicit);
MOZ_ASSERT(!mHasPendingStableStateCallback);
MOZ_ASSERT(!mHasPendingTimerCallback);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mExplicit);
MOZ_DIAGNOSTIC_ASSERT(!mHasPendingStableStateCallback);
MOZ_DIAGNOSTIC_ASSERT(!mHasPendingTimerCallback);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
nsresult rv = Checkpoint();
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -393,9 +401,9 @@ nsresult LSSnapshot::End() {
void LSSnapshot::ScheduleStableStateCallback() {
AssertIsOnOwningThread();
MOZ_ASSERT(mTimer);
MOZ_ASSERT(!mExplicit);
MOZ_ASSERT(!mHasPendingStableStateCallback);
MOZ_DIAGNOSTIC_ASSERT(mTimer);
MOZ_DIAGNOSTIC_ASSERT(!mExplicit);
MOZ_DIAGNOSTIC_ASSERT(!mHasPendingStableStateCallback);
CancelTimer();
@ -411,7 +419,7 @@ void LSSnapshot::MaybeScheduleStableStateCallback() {
if (!mExplicit && !mHasPendingStableStateCallback) {
ScheduleStableStateCallback();
} else {
MOZ_ASSERT(!mHasPendingTimerCallback);
MOZ_DIAGNOSTIC_ASSERT(!mHasPendingTimerCallback);
}
}
@ -419,16 +427,16 @@ nsresult LSSnapshot::GetItemInternal(const nsAString& aKey,
const Optional<nsString>& aValue,
nsAString& aResult) {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
nsString result;
switch (mLoadState) {
case LoadState::Partial: {
if (mValues.Get(aKey, &result)) {
MOZ_ASSERT(!result.IsVoid());
MOZ_DIAGNOSTIC_ASSERT(!result.IsVoid());
} else if (mLoadedItems.GetEntry(aKey) || mUnknownItems.GetEntry(aKey)) {
result.SetIsVoid(true);
} else {
@ -470,14 +478,14 @@ nsresult LSSnapshot::GetItemInternal(const nsAString& aKey,
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(!result.IsVoid());
MOZ_DIAGNOSTIC_ASSERT(!result.IsVoid());
mLoadedItems.PutEntry(aKey);
mValues.Put(aKey, result);
if (mLoadedItems.Count() == mInitLength) {
mLoadedItems.Clear();
MOZ_ASSERT(mLength == 0);
MOZ_DIAGNOSTIC_ASSERT(mLength == 0);
mLoadState = LoadState::AllOrderedItems;
}
}
@ -513,7 +521,7 @@ nsresult LSSnapshot::GetItemInternal(const nsAString& aKey,
} else {
if (auto entry = mValues.Lookup(aKey)) {
result = entry.Data();
MOZ_ASSERT(!result.IsVoid());
MOZ_DIAGNOSTIC_ASSERT(!result.IsVoid());
entry.Remove();
} else {
result.SetIsVoid(true);
@ -521,7 +529,7 @@ nsresult LSSnapshot::GetItemInternal(const nsAString& aKey,
}
} else {
if (mValues.Get(aKey, &result)) {
MOZ_ASSERT(!result.IsVoid());
MOZ_DIAGNOSTIC_ASSERT(!result.IsVoid());
} else {
result.SetIsVoid(true);
}
@ -540,10 +548,10 @@ nsresult LSSnapshot::GetItemInternal(const nsAString& aKey,
nsresult LSSnapshot::EnsureAllKeys() {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_ASSERT(mLoadState != LoadState::Initial);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mLoadState != LoadState::Initial);
if (mLoadState == LoadState::AllOrderedKeys ||
mLoadState == LoadState::AllOrderedItems) {
@ -583,8 +591,8 @@ nsresult LSSnapshot::EnsureAllKeys() {
}
}
MOZ_ASSERT_IF(mLoadState == LoadState::AllUnorderedItems,
newValues.Count() == mValues.Count());
MOZ_DIAGNOSTIC_ASSERT_IF(mLoadState == LoadState::AllUnorderedItems,
newValues.Count() == mValues.Count());
for (auto iter = newValues.Iter(); !iter.Done(); iter.Next()) {
nsString value;
@ -600,10 +608,10 @@ nsresult LSSnapshot::EnsureAllKeys() {
mLength = 0;
mLoadState = LoadState::AllOrderedKeys;
} else {
MOZ_ASSERT(mLoadState == LoadState::AllUnorderedItems);
MOZ_DIAGNOSTIC_ASSERT(mLoadState == LoadState::AllUnorderedItems);
MOZ_ASSERT(mUnknownItems.Count() == 0);
MOZ_ASSERT(mLength == 0);
MOZ_DIAGNOSTIC_ASSERT(mUnknownItems.Count() == 0);
MOZ_DIAGNOSTIC_ASSERT(mLength == 0);
mLoadState = LoadState::AllOrderedItems;
}
@ -612,11 +620,11 @@ nsresult LSSnapshot::EnsureAllKeys() {
nsresult LSSnapshot::UpdateUsage(int64_t aDelta) {
AssertIsOnOwningThread();
MOZ_ASSERT(mDatabase);
MOZ_ASSERT(mActor);
MOZ_ASSERT(mPeakUsage >= mExactUsage);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mDatabase);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mPeakUsage >= mExactUsage);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
int64_t newExactUsage = mExactUsage + aDelta;
if (newExactUsage > mPeakUsage) {
@ -628,7 +636,7 @@ nsresult LSSnapshot::UpdateUsage(int64_t aDelta) {
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(size >= 0);
MOZ_DIAGNOSTIC_ASSERT(size >= 0);
if (size == 0) {
return NS_ERROR_FILE_NO_DEVICE_SPACE;
@ -643,9 +651,9 @@ nsresult LSSnapshot::UpdateUsage(int64_t aDelta) {
nsresult LSSnapshot::Checkpoint() {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
if (!mWriteInfos.IsEmpty()) {
MOZ_ALWAYS_TRUE(mActor->SendCheckpoint(mWriteInfos));
@ -658,21 +666,21 @@ nsresult LSSnapshot::Checkpoint() {
nsresult LSSnapshot::Finish() {
AssertIsOnOwningThread();
MOZ_ASSERT(mDatabase);
MOZ_ASSERT(mActor);
MOZ_ASSERT(mInitialized);
MOZ_ASSERT(!mSentFinish);
MOZ_DIAGNOSTIC_ASSERT(mDatabase);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mInitialized);
MOZ_DIAGNOSTIC_ASSERT(!mSentFinish);
MOZ_ALWAYS_TRUE(mActor->SendFinish());
mDatabase->NoteFinishedSnapshot(this);
#ifdef DEBUG
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
mSentFinish = true;
#endif
// Clear the self reference added in Init method.
MOZ_ASSERT(mSelfRef);
MOZ_DIAGNOSTIC_ASSERT(mSelfRef);
mSelfRef = nullptr;
return NS_OK;
@ -680,7 +688,7 @@ nsresult LSSnapshot::Finish() {
void LSSnapshot::CancelTimer() {
AssertIsOnOwningThread();
MOZ_ASSERT(mTimer);
MOZ_DIAGNOSTIC_ASSERT(mTimer);
if (mHasPendingTimerCallback) {
MOZ_ALWAYS_SUCCEEDS(mTimer->Cancel());
@ -690,14 +698,14 @@ void LSSnapshot::CancelTimer() {
// static
void LSSnapshot::TimerCallback(nsITimer* aTimer, void* aClosure) {
MOZ_ASSERT(aTimer);
MOZ_DIAGNOSTIC_ASSERT(aTimer);
auto* self = static_cast<LSSnapshot*>(aClosure);
MOZ_ASSERT(self);
MOZ_ASSERT(self->mTimer);
MOZ_ASSERT(SameCOMIdentity(self->mTimer, aTimer));
MOZ_ASSERT(!self->mHasPendingStableStateCallback);
MOZ_ASSERT(self->mHasPendingTimerCallback);
MOZ_DIAGNOSTIC_ASSERT(self);
MOZ_DIAGNOSTIC_ASSERT(self->mTimer);
MOZ_DIAGNOSTIC_ASSERT(SameCOMIdentity(self->mTimer, aTimer));
MOZ_DIAGNOSTIC_ASSERT(!self->mHasPendingStableStateCallback);
MOZ_DIAGNOSTIC_ASSERT(self->mHasPendingTimerCallback);
self->mHasPendingTimerCallback = false;
@ -709,9 +717,9 @@ NS_IMPL_ISUPPORTS(LSSnapshot, nsIRunnable)
NS_IMETHODIMP
LSSnapshot::Run() {
AssertIsOnOwningThread();
MOZ_ASSERT(!mExplicit);
MOZ_ASSERT(mHasPendingStableStateCallback);
MOZ_ASSERT(!mHasPendingTimerCallback);
MOZ_DIAGNOSTIC_ASSERT(!mExplicit);
MOZ_DIAGNOSTIC_ASSERT(mHasPendingStableStateCallback);
MOZ_DIAGNOSTIC_ASSERT(!mHasPendingTimerCallback);
mHasPendingStableStateCallback = false;
@ -720,7 +728,7 @@ LSSnapshot::Run() {
if (mDirty || !Preferences::GetBool("dom.storage.snapshot_reusing")) {
MOZ_ALWAYS_SUCCEEDS(Finish());
} else if (!mExplicit) {
MOZ_ASSERT(mTimer);
MOZ_DIAGNOSTIC_ASSERT(mTimer);
MOZ_ALWAYS_SUCCEEDS(mTimer->InitWithNamedFuncCallback(
TimerCallback, this, kSnapshotTimeoutMs, nsITimer::TYPE_ONE_SHOT,

Просмотреть файл

@ -91,7 +91,7 @@ class LSSnapshot final : public nsIRunnable {
bool mHasPendingTimerCallback;
bool mDirty;
#ifdef DEBUG
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
bool mInitialized;
bool mSentFinish;
#endif
@ -105,7 +105,7 @@ class LSSnapshot final : public nsIRunnable {
void ClearActor() {
AssertIsOnOwningThread();
MOZ_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mActor);
mActor = nullptr;
}

Просмотреть файл

@ -47,7 +47,7 @@ bool NextGenLocalStorageEnabled() {
}
bool CachedNextGenLocalStorageEnabled() {
MOZ_ASSERT(gNextGenLocalStorageEnabled != -1);
MOZ_DIAGNOSTIC_ASSERT(gNextGenLocalStorageEnabled != -1);
return !!gNextGenLocalStorageEnabled;
}

Просмотреть файл

@ -54,7 +54,7 @@ class SimpleRequestResolver final : public LSSimpleRequestChildCallback {
nsresult CreatePromise(JSContext* aContext, Promise** aPromise) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aContext);
MOZ_DIAGNOSTIC_ASSERT(aContext);
nsIGlobalObject* global =
xpc::NativeGlobal(JS::CurrentGlobalOrNull(aContext));
@ -75,7 +75,7 @@ nsresult CreatePromise(JSContext* aContext, Promise** aPromise) {
nsresult CheckedPrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
PrincipalInfo& aPrincipalInfo) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
nsresult rv = PrincipalToPrincipalInfo(aPrincipal, &aPrincipalInfo);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -98,7 +98,7 @@ nsresult CheckedPrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
LocalStorageManager2::LocalStorageManager2() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(NextGenLocalStorageEnabled());
MOZ_DIAGNOSTIC_ASSERT(NextGenLocalStorageEnabled());
}
LocalStorageManager2::~LocalStorageManager2() { MOZ_ASSERT(NS_IsMainThread()); }
@ -110,8 +110,8 @@ NS_IMETHODIMP
LocalStorageManager2::PrecacheStorage(nsIPrincipal* aPrincipal,
Storage** _retval) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(_retval);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(_retval);
// This method was created as part of the e10s-ification of the old LS
// implementation to perform a preload in the content/current process. That's
@ -127,8 +127,8 @@ LocalStorageManager2::CreateStorage(mozIDOMWindow* aWindow,
const nsAString& aDocumentURI,
bool aPrivate, Storage** _retval) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(_retval);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(_retval);
nsCOMPtr<nsPIDOMWindowInner> inner = nsPIDOMWindowInner::From(aWindow);
@ -148,8 +148,8 @@ LocalStorageManager2::GetStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal, bool aPrivate,
Storage** _retval) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(_retval);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(_retval);
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -157,7 +157,7 @@ LocalStorageManager2::GetStorage(mozIDOMWindow* aWindow,
NS_IMETHODIMP
LocalStorageManager2::CloneStorage(Storage* aStorageToCloneFrom) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aStorageToCloneFrom);
MOZ_DIAGNOSTIC_ASSERT(aStorageToCloneFrom);
// Cloning is specific to sessionStorage; state is forked when a new tab is
// opened from an existing tab.
@ -168,9 +168,9 @@ NS_IMETHODIMP
LocalStorageManager2::CheckStorage(nsIPrincipal* aPrincipal, Storage* aStorage,
bool* _retval) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(aStorage);
MOZ_ASSERT(_retval);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(aStorage);
MOZ_DIAGNOSTIC_ASSERT(_retval);
// Only used by sessionStorage.
return NS_ERROR_NOT_IMPLEMENTED;
@ -179,7 +179,7 @@ LocalStorageManager2::CheckStorage(nsIPrincipal* aPrincipal, Storage* aStorage,
NS_IMETHODIMP
LocalStorageManager2::GetNextGenLocalStorageEnabled(bool* aResult) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aResult);
MOZ_DIAGNOSTIC_ASSERT(aResult);
*aResult = NextGenLocalStorageEnabled();
return NS_OK;
@ -189,8 +189,8 @@ NS_IMETHODIMP
LocalStorageManager2::Preload(nsIPrincipal* aPrincipal, JSContext* aContext,
nsISupports** _retval) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(_retval);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(_retval);
nsCString originAttrSuffix;
nsCString originKey;
@ -233,8 +233,8 @@ NS_IMETHODIMP
LocalStorageManager2::IsPreloaded(nsIPrincipal* aPrincipal, JSContext* aContext,
nsISupports** _retval) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(_retval);
MOZ_DIAGNOSTIC_ASSERT(aPrincipal);
MOZ_DIAGNOSTIC_ASSERT(_retval);
RefPtr<Promise> promise;
nsresult rv = CreatePromise(aContext, getter_AddRefs(promise));
@ -282,7 +282,7 @@ nsresult LocalStorageManager2::StartRequest(Promise* aPromise,
nsresult LocalStorageManager2::StartSimpleRequest(
Promise* aPromise, const LSSimpleRequestParams& aParams) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPromise);
MOZ_DIAGNOSTIC_ASSERT(aPromise);
PBackgroundChild* backgroundActor =
BackgroundChild::GetOrCreateForCurrentThread();
@ -340,14 +340,14 @@ void RequestResolver::OnResponse(const LSRequestResponse& aResponse) {
void SimpleRequestResolver::HandleResponse(nsresult aResponse) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mPromise);
MOZ_DIAGNOSTIC_ASSERT(mPromise);
mPromise->MaybeReject(aResponse);
}
void SimpleRequestResolver::HandleResponse(bool aResponse) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mPromise);
MOZ_DIAGNOSTIC_ASSERT(mPromise);
mPromise->MaybeResolve(aResponse);
}