зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1307350: Compensate for repeating timers that have not been appropriately cancelled. r=froydnj
MozReview-Commit-ID: 20VpLbgSjh4 --HG-- extra : rebase_source : b5b38c69c228b750e986cc502db1a6c2242919b4
This commit is contained in:
Родитель
ae2f7c64fc
Коммит
70c2bbb4dc
|
@ -570,6 +570,10 @@ TimerThread::AddTimer(nsTimerImpl* aTimer)
|
|||
{
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
|
||||
if (!aTimer->mEventTarget) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
// Add the timer to our list.
|
||||
int32_t i = AddTimerInternal(aTimer);
|
||||
if (i < 0) {
|
||||
|
@ -586,7 +590,7 @@ TimerThread::AddTimer(nsTimerImpl* aTimer)
|
|||
}
|
||||
|
||||
nsresult
|
||||
TimerThread::RemoveTimer(nsTimerImpl* aTimer)
|
||||
TimerThread::RemoveTimer(nsTimerImpl* aTimer, bool aDisable)
|
||||
{
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
|
||||
|
@ -597,6 +601,10 @@ TimerThread::RemoveTimer(nsTimerImpl* aTimer)
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (aDisable) {
|
||||
aTimer->mEventTarget = nullptr;
|
||||
}
|
||||
|
||||
// Awaken the timer thread.
|
||||
if (mWaiting) {
|
||||
mNotified = true;
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
nsresult Shutdown();
|
||||
|
||||
nsresult AddTimer(nsTimerImpl* aTimer);
|
||||
nsresult RemoveTimer(nsTimerImpl* aTimer);
|
||||
nsresult RemoveTimer(nsTimerImpl* aTimer, bool aDisable=false);
|
||||
|
||||
void DoBeforeSleep();
|
||||
void DoAfterSleep();
|
||||
|
|
|
@ -326,17 +326,14 @@ void
|
|||
nsTimerImpl::Neuter()
|
||||
{
|
||||
if (gThread) {
|
||||
gThread->RemoveTimer(this);
|
||||
gThread->RemoveTimer(this, true);
|
||||
}
|
||||
|
||||
// If invoked on the target thread, guarantees that the timer doesn't pop.
|
||||
// If invoked anywhere else, it might prevent the timer from popping, but
|
||||
// no guarantees.
|
||||
// no guarantees. In any case, the above RemoveTimer call will prevent it
|
||||
// from being rescheduled.
|
||||
++mGeneration;
|
||||
|
||||
// Breaks cycles when TimerEvents are in the queue of a thread that is no
|
||||
// longer running.
|
||||
mEventTarget = nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
Загрузка…
Ссылка в новой задаче