Bug 1680724 - Use ToMaybeRef or SafeRefPtr::maybeDeref where possible. r=dom-workers-and-storage-reviewers,janv

Differential Revision: https://phabricator.services.mozilla.com/D98784
This commit is contained in:
Simon Giesecke 2020-12-08 17:49:30 +00:00
parent 8c5c02b43d
commit b2d834a030
5 changed files with 6 additions and 8 deletions

View File

@ -252,7 +252,7 @@ class Manager::Factory {
// cleaning up. We need to tell the new manager about this so
// that it won't actually start until the old manager is done.
SafeRefPtr<Manager> oldManager = Acquire(*aManagerId, Closing);
ref->Init(oldManager ? SomeRef(*oldManager) : Nothing());
ref->Init(oldManager.maybeDeref());
MOZ_ASSERT(!sFactory->mManagerList.Contains(ref));
sFactory->mManagerList.AppendElement(ref.unsafeGetRawPtr());

View File

@ -573,8 +573,8 @@ void SetResultAndDispatchSuccessEvent(
const NotNull<RefPtr<IDBRequest>>& aRequest,
const SafeRefPtr<IDBTransaction>& aTransaction, T& aPtr,
RefPtr<Event> aEvent) {
const auto autoTransaction = AutoSetCurrentTransaction{
aTransaction ? SomeRef(*aTransaction) : Nothing()};
const auto autoTransaction =
AutoSetCurrentTransaction{aTransaction.maybeDeref()};
AUTO_PROFILER_LABEL("IndexedDB:SetResultAndDispatchSuccessEvent", DOM);

View File

@ -487,7 +487,7 @@ auto MatchMetadataNameOrId(const Enumerable& aEnumerable,
(aName && *aName == value->mCommonMetadata.name()));
});
return it != aEnumerable.cend() ? SomeRef(*it->GetData()) : Nothing();
return ToMaybeRef(it != aEnumerable.cend() ? it->GetData().get() : nullptr);
}
/*******************************************************************************

View File

@ -188,7 +188,7 @@ class IDBRequest : public DOMEventTargetHelper {
Maybe<IDBTransaction&> MaybeTransactionRef() const {
AssertIsOnOwningThread();
return mTransaction ? SomeRef(*mTransaction) : Nothing();
return mTransaction.maybeDeref();
}
IDBTransaction& MutableTransactionRef() const {

View File

@ -262,9 +262,7 @@ class MOZ_IS_REFPTR MOZ_TRIVIAL_ABI SafeRefPtr {
return mRawPtr;
}
Maybe<T&> maybeDeref() const {
return mRawPtr ? SomeRef(*mRawPtr) : Nothing();
}
Maybe<T&> maybeDeref() const { return ToMaybeRef(mRawPtr); }
T* unsafeGetRawPtr() const { return mRawPtr; }