Bug 1339588 - Part 1: Simplify nsTimerEvent::Cancel, since there's no need to release the nsTimerImpl itself. r=froydnj, a=dveditz

This commit is contained in:
roytam1 2021-12-14 22:58:22 +08:00
commit c72a393b93

View file

@ -140,11 +140,7 @@ public:
nsresult Cancel() override
{
// Since nsTimerImpl is not thread-safe, we should release |mTimer|
// here in the target thread to avoid race condition. Otherwise,
// ~nsTimerEvent() which calls nsTimerImpl::Release() could run in the
// timer thread and result in race condition.
mTimer = nullptr;
mTimer->Cancel();
return NS_OK;
}
@ -269,11 +265,6 @@ nsTimerEvent::DeleteAllocatorIfNeeded()
NS_IMETHODIMP
nsTimerEvent::Run()
{
if (!mTimer) {
MOZ_ASSERT(false);
return NS_OK;
}
if (MOZ_LOG_TEST(GetTimerLog(), LogLevel::Debug)) {
TimeStamp now = TimeStamp::Now();
MOZ_LOG(GetTimerLog(), LogLevel::Debug,
@ -283,9 +274,7 @@ nsTimerEvent::Run()
mTimer->Fire(mGeneration);
// We call Cancel() to correctly release mTimer.
// Read more in the Cancel() implementation.
return Cancel();
return NS_OK;
}
nsresult