Bug 1647112 - P2. Remove static method. r=mattwoodrow

Allows to remove the dance around the compositor thread just to perform the assertion.
The use of an in-line lambda avoid all ambiguity on which thread this is called.

Differential Revision: https://phabricator.services.mozilla.com/D80635
This commit is contained in:
Jean-Yves Avenard 2020-07-02 00:29:53 +00:00
Родитель 28c6755d49
Коммит 9356971435
2 изменённых файлов: 8 добавлений и 20 удалений

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

@ -69,22 +69,6 @@ already_AddRefed<CanvasThreadHolder> CanvasThreadHolder::EnsureCanvasThread() {
return do_AddRef(lockedCanvasThreadHolder.ref());
}
/* static */
void CanvasThreadHolder::StaticRelease(
already_AddRefed<CanvasThreadHolder> aCanvasThreadHolder) {
RefPtr<CanvasThreadHolder> threadHolder = aCanvasThreadHolder;
// Note we can't just use NS_IsInCompositorThread() here because
// sCompositorThreadHolder might have already gone.
MOZ_ASSERT(threadHolder->mCompositorThreadKeepAlive->GetCompositorThread()
->IsOnCurrentThread());
threadHolder = nullptr;
auto lockedCanvasThreadHolder = sCanvasThreadHolder.Lock();
if (lockedCanvasThreadHolder.ref()->mRefCnt == 1) {
lockedCanvasThreadHolder.ref() = nullptr;
}
}
/* static */
void CanvasThreadHolder::ReleaseOnCompositorThread(
already_AddRefed<CanvasThreadHolder> aCanvasThreadHolder) {
@ -95,7 +79,14 @@ void CanvasThreadHolder::ReleaseOnCompositorThread(
->Dispatch(NS_NewRunnableFunction(
"CanvasThreadHolder::StaticRelease",
[canvasThreadHolder = std::move(canvasThreadHolder)]() mutable {
CanvasThreadHolder::StaticRelease(canvasThreadHolder.forget());
RefPtr<CanvasThreadHolder> threadHolder =
canvasThreadHolder.forget();
threadHolder = nullptr;
auto lockedCanvasThreadHolder = sCanvasThreadHolder.Lock();
if (lockedCanvasThreadHolder.ref()->mRefCnt == 1) {
lockedCanvasThreadHolder.ref() = nullptr;
}
}));
}

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

@ -77,9 +77,6 @@ class CanvasThreadHolder final {
already_AddRefed<TaskQueue> CreateWorkerTaskQueue();
private:
static void StaticRelease(
already_AddRefed<CanvasThreadHolder> aCanvasThreadHolder);
static StaticDataMutex<StaticRefPtr<CanvasThreadHolder>> sCanvasThreadHolder;
CanvasThreadHolder(already_AddRefed<nsISerialEventTarget> aCanvasThread,