Bug 1641231 - Use InitializedOnce for DirectoryLockImpl::mOpenListener; r=dom-workers-and-storage-reviewers,janv,sg

Differential Revision: https://phabricator.services.mozilla.com/D78066
This commit is contained in:
Tom Tung 2020-06-09 06:59:40 +00:00
Родитель 453b1fffec
Коммит deebd6c64d
1 изменённых файлов: 11 добавлений и 8 удалений

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

@ -666,8 +666,9 @@ class DirectoryLockImpl final : public DirectoryLock {
const nsCString mGroup; const nsCString mGroup;
const OriginScope mOriginScope; const OriginScope mOriginScope;
const Nullable<Client::Type> mClientType; const Nullable<Client::Type> mClientType;
// ToDo: Use InitializedOnce for this. LazyInitializedOnceEarlyDestructible<
RefPtr<OpenDirectoryListener> mOpenListener; const NotNull<RefPtr<OpenDirectoryListener>>>
mOpenListener;
nsTArray<NotNull<DirectoryLockImpl*>> mBlocking; nsTArray<NotNull<DirectoryLockImpl*>> mBlocking;
nsTArray<NotNull<DirectoryLockImpl*>> mBlockedOn; nsTArray<NotNull<DirectoryLockImpl*>> mBlockedOn;
@ -2869,7 +2870,6 @@ DirectoryLockImpl::DirectoryLockImpl(
mGroup(aGroup), mGroup(aGroup),
mOriginScope(aOriginScope), mOriginScope(aOriginScope),
mClientType(aClientType), mClientType(aClientType),
mOpenListener(std::move(aOpenListener)),
mId(aId), mId(aId),
mExclusive(aExclusive), mExclusive(aExclusive),
mInternal(aInternal), mInternal(aInternal),
@ -2884,7 +2884,11 @@ DirectoryLockImpl::DirectoryLockImpl(
MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin()); MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin());
MOZ_ASSERT_IF(!aInternal, !aClientType.IsNull()); MOZ_ASSERT_IF(!aInternal, !aClientType.IsNull());
MOZ_ASSERT_IF(!aInternal, aClientType.Value() < Client::TypeMax()); MOZ_ASSERT_IF(!aInternal, aClientType.Value() < Client::TypeMax());
MOZ_ASSERT_IF(!aInternal, mOpenListener); MOZ_ASSERT_IF(!aInternal, aOpenListener);
if (aOpenListener) {
mOpenListener.init(WrapNotNullUnchecked(std::move(aOpenListener)));
}
} }
DirectoryLockImpl::~DirectoryLockImpl() { DirectoryLockImpl::~DirectoryLockImpl() {
@ -2951,15 +2955,14 @@ bool DirectoryLockImpl::MustWaitFor(const DirectoryLockImpl& aLock) const {
void DirectoryLockImpl::NotifyOpenListener() { void DirectoryLockImpl::NotifyOpenListener() {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_ASSERT(mOpenListener);
if (mInvalidated) { if (mInvalidated) {
mOpenListener->DirectoryLockFailed(); (*mOpenListener)->DirectoryLockFailed();
} else { } else {
mOpenListener->DirectoryLockAcquired(this); (*mOpenListener)->DirectoryLockAcquired(this);
} }
mOpenListener = nullptr; mOpenListener.destroy();
mQuotaManager->RemovePendingDirectoryLock(this); mQuotaManager->RemovePendingDirectoryLock(this);
} }