Skip to content

Commit

Permalink
Bug 1259294: Part 2 - Use MOZ_ALWAYS_SUCCEEDS. r=froydnj
Browse files Browse the repository at this point in the history
  • Loading branch information
khuey committed Mar 28, 2016
1 parent 56b06b5 commit b464104
Show file tree
Hide file tree
Showing 81 changed files with 476 additions and 528 deletions.
8 changes: 3 additions & 5 deletions docshell/base/LoadContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ LoadContext::LoadContext(nsIPrincipal* aPrincipal,
return;
}

MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aOptionalBase->GetIsContent(&mIsContent)));
MOZ_ALWAYS_TRUE(
NS_SUCCEEDED(aOptionalBase->GetUsePrivateBrowsing(&mUsePrivateBrowsing)));
MOZ_ALWAYS_TRUE(
NS_SUCCEEDED(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs)));
MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetIsContent(&mIsContent));
MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetUsePrivateBrowsing(&mUsePrivateBrowsing));
MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs));
}

//-----------------------------------------------------------------------------
Expand Down
18 changes: 6 additions & 12 deletions dom/asmjscache/AsmJSCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ class ParentRunnable final
mState != eFinished);

mState = eFailing;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(mOwningThread->Dispatch(this,
NS_DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
}

void
Expand Down Expand Up @@ -916,8 +915,7 @@ ParentRunnable::Run()
}

mState = eWaitingToFinishInit;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));

return NS_OK;
}
Expand Down Expand Up @@ -959,15 +957,13 @@ ParentRunnable::Run()
rv = ReadMetadata();
if (NS_FAILED(rv)) {
mState = eFailedToReadMetadata;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
return NS_OK;
}

if (mOpenMode == eOpenForRead) {
mState = eSendingMetadataForRead;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));

return NS_OK;
}
Expand All @@ -979,8 +975,7 @@ ParentRunnable::Run()
}

mState = eSendingCacheFile;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
return NS_OK;
}

Expand Down Expand Up @@ -1022,8 +1017,7 @@ ParentRunnable::Run()
}

mState = eSendingCacheFile;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
return NS_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions dom/base/DOMRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class FireSuccessAsyncTask : public nsRunnable
{
RefPtr<FireSuccessAsyncTask> asyncTask =
new FireSuccessAsyncTask(aRequest, aResult);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToCurrentThread(asyncTask)));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThread(asyncTask));
return NS_OK;
}

Expand Down Expand Up @@ -368,7 +368,7 @@ DOMRequestService::FireErrorAsync(nsIDOMDOMRequest* aRequest,
NS_ENSURE_STATE(aRequest);
nsCOMPtr<nsIRunnable> asyncTask =
new FireErrorAsyncTask(static_cast<DOMRequest*>(aRequest), aError);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToCurrentThread(asyncTask)));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThread(asyncTask));
return NS_OK;
}

Expand Down
6 changes: 3 additions & 3 deletions dom/base/StructuredCloneHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ EnsureBlobForBackgroundManager(BlobImpl* aBlobImpl,
MOZ_ASSERT(NS_SUCCEEDED(blobImpl->GetMutable(&isMutable)));
MOZ_ASSERT(!isMutable);
} else {
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(blobImpl->SetMutable(false)));
MOZ_ALWAYS_SUCCEEDS(blobImpl->SetMutable(false));
}

return blobImpl.forget();
Expand Down Expand Up @@ -639,7 +639,7 @@ EnsureBlobForBackgroundManager(BlobImpl* aBlobImpl,
return nullptr;
}

MOZ_ALWAYS_TRUE(NS_SUCCEEDED(blobImpl->SetMutable(false)));
MOZ_ALWAYS_SUCCEEDS(blobImpl->SetMutable(false));
}

return blobImpl.forget();
Expand Down Expand Up @@ -698,7 +698,7 @@ WriteBlob(JSStructuredCloneWriter* aWriter,

MOZ_ASSERT(blobImpl);

MOZ_ALWAYS_TRUE(NS_SUCCEEDED(blobImpl->SetMutable(false)));
MOZ_ALWAYS_SUCCEEDS(blobImpl->SetMutable(false));

// We store the position of the blobImpl in the array as index.
if (JS_WriteUint32Pair(aWriter, SCTAG_DOM_BLOB,
Expand Down
12 changes: 6 additions & 6 deletions dom/base/nsContentIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,8 +1329,8 @@ nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
// we have a range that does not fully contain any node.

bool nodeBefore, nodeAfter;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
nsRange::CompareNodeToRange(firstCandidate, mRange, &nodeBefore, &nodeAfter)));
MOZ_ALWAYS_SUCCEEDS(
nsRange::CompareNodeToRange(firstCandidate, mRange, &nodeBefore, &nodeAfter));

if (nodeBefore || nodeAfter) {
MakeEmpty();
Expand Down Expand Up @@ -1373,8 +1373,8 @@ nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
// confirm that this last possible contained node is indeed contained. Else
// we have a range that does not fully contain any node.

MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
nsRange::CompareNodeToRange(lastCandidate, mRange, &nodeBefore, &nodeAfter)));
MOZ_ALWAYS_SUCCEEDS(
nsRange::CompareNodeToRange(lastCandidate, mRange, &nodeBefore, &nodeAfter));

if (nodeBefore || nodeAfter) {
MakeEmpty();
Expand Down Expand Up @@ -1526,8 +1526,8 @@ nsContentSubtreeIterator::GetTopAncestorInRange(nsINode* aNode)
if (!parent || !parent->GetParentNode()) {
return content;
}
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
nsRange::CompareNodeToRange(parent, mRange, &nodeBefore, &nodeAfter)));
MOZ_ALWAYS_SUCCEEDS(
nsRange::CompareNodeToRange(parent, mRange, &nodeBefore, &nodeAfter));

if (nodeBefore || nodeAfter) {
return content;
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8139,7 +8139,7 @@ nsContentUtils::InternalStorageAllowedForPrincipal(nsIPrincipal* aPrincipal,
nsresult rv = aPrincipal->GetURI(getter_AddRefs(uri));
if (NS_SUCCEEDED(rv) && uri) {
bool isAbout = false;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(uri->SchemeIs("about", &isAbout)));
MOZ_ALWAYS_SUCCEEDS(uri->SchemeIs("about", &isAbout));
if (isAbout) {
return access;
}
Expand Down
4 changes: 2 additions & 2 deletions dom/cache/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Connection::Connection(mozIStorageConnection* aBase)
Connection::~Connection()
{
NS_ASSERT_OWNINGTHREAD(Connection);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(Close()));
MOZ_ALWAYS_SUCCEEDS(Close());
}

NS_IMETHODIMP
Expand All @@ -43,7 +43,7 @@ Connection::Close()

// If we are closing here, then Cache must not have a transaction
// open anywhere else. This should be guaranteed to succeed.
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(db::IncrementalVacuum(this)));
MOZ_ALWAYS_SUCCEEDS(db::IncrementalVacuum(this));

return mBase->Close();
}
Expand Down
36 changes: 18 additions & 18 deletions dom/cache/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ class Context::QuotaInitRunnable final : public nsIRunnable
mResult = aResult;

mState = STATE_COMPLETING;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mInitiatingThread->Dispatch(this, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mInitiatingThread->Dispatch(this, nsIThread::DISPATCH_NORMAL));
}

void Clear()
Expand Down Expand Up @@ -386,8 +386,8 @@ Context::QuotaInitRunnable::Run()
}

mState = STATE_CREATE_QUOTA_MANAGER;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mInitiatingThread->Dispatch(this, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mInitiatingThread->Dispatch(this, nsIThread::DISPATCH_NORMAL));
break;
}
// ----------------------------------
Expand Down Expand Up @@ -446,8 +446,8 @@ Context::QuotaInitRunnable::Run()

mState = STATE_RUN_ON_TARGET;

MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL));
break;
}
// -------------------
Expand All @@ -468,7 +468,7 @@ Context::QuotaInitRunnable::Run()
// the marker file. If it wasn't opened successfully, then no need to
// create a marker file anyway.
if (NS_SUCCEEDED(resolver->Result())) {
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(CreateMarkerFile(mQuotaInfo)));
MOZ_ALWAYS_SUCCEEDS(CreateMarkerFile(mQuotaInfo));
}

break;
Expand Down Expand Up @@ -579,8 +579,8 @@ class Context::ActionRunnable final : public nsIRunnable

// Otherwise we are in an asynchronous resolve. And must perform a thread
// bounce to run on the target thread again.
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL));
}

private:
Expand Down Expand Up @@ -704,8 +704,8 @@ Context::ActionRunnable::Run()
mState = STATE_COMPLETING;
// Shutdown must be delayed until all Contexts are destroyed. Crash
// for this invariant violation.
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mInitiatingThread->Dispatch(this, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mInitiatingThread->Dispatch(this, nsIThread::DISPATCH_NORMAL));
break;
}
// -------------------
Expand Down Expand Up @@ -741,8 +741,8 @@ Context::ThreadsafeHandle::AllowToClose()
// all Contexts have been destroyed.
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &ThreadsafeHandle::AllowToCloseOnOwningThread);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
}

void
Expand All @@ -757,8 +757,8 @@ Context::ThreadsafeHandle::InvalidateAndAllowToClose()
// all Contexts have been destroyed.
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
}

Context::ThreadsafeHandle::ThreadsafeHandle(Context* aContext)
Expand All @@ -782,8 +782,8 @@ Context::ThreadsafeHandle::~ThreadsafeHandle()
// all Contexts have been destroyed.
nsCOMPtr<nsIRunnable> runnable =
NS_NewNonOwningRunnableMethod(mStrongRef.forget().take(), &Context::Release);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
}

void
Expand Down Expand Up @@ -965,7 +965,7 @@ Context::~Context()
mManager->RemoveContext(this);

if (mQuotaInfo.mDir && !mOrphanedData) {
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(DeleteMarkerFile(mQuotaInfo)));
MOZ_ALWAYS_SUCCEEDS(DeleteMarkerFile(mQuotaInfo));
}

if (mNextContext) {
Expand Down
6 changes: 3 additions & 3 deletions dom/cache/Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,8 @@ class Manager::CachePutAllAction final : public DBAction
// CompleteOnInitiatingThread is called.
nsCOMPtr<nsIRunnable> runnable = NS_NewNonOwningRunnableMethodWithArgs<nsresult>(
this, &CachePutAllAction::OnAsyncCopyComplete, aRv);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mTargetThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mTargetThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
}

void
Expand Down Expand Up @@ -1763,7 +1763,7 @@ Manager::~Manager()
// shutdown. Defer this to the main thread, instead.
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(ioThread, &nsIThread::Shutdown);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(runnable)));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable));
}

void
Expand Down
2 changes: 1 addition & 1 deletion dom/cache/PrincipalVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PrincipalVerifier::CreateAndDispatch(Listener* aListener,
aActor,
aPrincipalInfo);

MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(verifier)));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(verifier));

return verifier.forget();
}
Expand Down
8 changes: 4 additions & 4 deletions dom/cache/ReadStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ ReadStream::Inner::NoteClosed()
}

nsCOMPtr<nsIRunnable> runnable = new NoteClosedRunnable(this);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
}

void
Expand All @@ -376,8 +376,8 @@ ReadStream::Inner::Forget()
}

nsCOMPtr<nsIRunnable> runnable = new ForgetRunnable(this);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)));
MOZ_ALWAYS_SUCCEEDS(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
}

void
Expand Down
2 changes: 1 addition & 1 deletion dom/fetch/Fetch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ FetchRequest(nsIGlobalObject* aGlobal, const RequestOrUSVString& aInput,
}

RefPtr<MainThreadFetchRunnable> run = new MainThreadFetchRunnable(resolver, r);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(run)));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(run));
}

return p.forget();
Expand Down
10 changes: 5 additions & 5 deletions dom/fetch/InternalRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ InternalRequest::MapChannelToRequestMode(nsIChannel* aChannel)
MOZ_ASSERT(aChannel);

nsCOMPtr<nsILoadInfo> loadInfo;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aChannel->GetLoadInfo(getter_AddRefs(loadInfo))));
MOZ_ALWAYS_SUCCEEDS(aChannel->GetLoadInfo(getter_AddRefs(loadInfo)));

nsContentPolicyType contentPolicy = loadInfo->InternalContentPolicyType();
if (IsNavigationContentPolicy(contentPolicy)) {
Expand All @@ -288,7 +288,7 @@ InternalRequest::MapChannelToRequestMode(nsIChannel* aChannel)
}

uint32_t securityMode;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(loadInfo->GetSecurityMode(&securityMode)));
MOZ_ALWAYS_SUCCEEDS(loadInfo->GetSecurityMode(&securityMode));

switch(securityMode) {
case nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS:
Expand All @@ -311,7 +311,7 @@ InternalRequest::MapChannelToRequestMode(nsIChannel* aChannel)
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(aChannel);

uint32_t corsMode;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(httpChannel->GetCorsMode(&corsMode)));
MOZ_ALWAYS_SUCCEEDS(httpChannel->GetCorsMode(&corsMode));
MOZ_ASSERT(corsMode != nsIHttpChannelInternal::CORS_MODE_NAVIGATE);

// This cast is valid due to static asserts in ServiceWorkerManager.cpp.
Expand All @@ -325,10 +325,10 @@ InternalRequest::MapChannelToRequestCredentials(nsIChannel* aChannel)
MOZ_ASSERT(aChannel);

nsCOMPtr<nsILoadInfo> loadInfo;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aChannel->GetLoadInfo(getter_AddRefs(loadInfo))));
MOZ_ALWAYS_SUCCEEDS(aChannel->GetLoadInfo(getter_AddRefs(loadInfo)));

uint32_t securityMode;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(loadInfo->GetSecurityMode(&securityMode)));
MOZ_ALWAYS_SUCCEEDS(loadInfo->GetSecurityMode(&securityMode));

// TODO: Remove following code after stylesheet and image support cookie policy
if (securityMode == nsILoadInfo::SEC_NORMAL) {
Expand Down
Loading

0 comments on commit b464104

Please sign in to comment.