Bug 1515216, ensure IdleTaskRunners are added only once to RefreshDriver's idle runnable list, r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D27424

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Olli Pettay 2019-04-15 15:41:15 +00:00
Родитель 29d439a983
Коммит b024b00b94
3 изменённых файлов: 11 добавлений и 5 удалений

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

@ -1713,10 +1713,16 @@ struct RunnableWithDelay {
static AutoTArray<RunnableWithDelay, 8>* sPendingIdleRunnables = nullptr;
void nsRefreshDriver::DispatchIdleRunnableAfterTick(nsIRunnable* aRunnable,
uint32_t aDelay) {
void nsRefreshDriver::DispatchIdleRunnableAfterTickUnlessExists(
nsIRunnable* aRunnable, uint32_t aDelay) {
if (!sPendingIdleRunnables) {
sPendingIdleRunnables = new AutoTArray<RunnableWithDelay, 8>();
} else {
for (uint32_t i = 0; i < sPendingIdleRunnables->Length(); ++i) {
if ((*sPendingIdleRunnables)[i].mRunnable == aRunnable) {
return;
}
}
}
RunnableWithDelay rwd = {aRunnable, aDelay};

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

@ -415,8 +415,8 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
*/
static mozilla::Maybe<mozilla::TimeStamp> GetNextTickHint();
static void DispatchIdleRunnableAfterTick(nsIRunnable* aRunnable,
uint32_t aDelay);
static void DispatchIdleRunnableAfterTickUnlessExists(nsIRunnable* aRunnable,
uint32_t aDelay);
static void CancelIdleRunnable(nsIRunnable* aRunnable);
void NotifyDOMContentLoaded();

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

@ -119,7 +119,7 @@ void IdleTaskRunner::Schedule(bool aAllowIdleDispatch) {
TimeStamp hint = nsRefreshDriver::GetIdleDeadlineHint(now);
if (hint != now) {
// RefreshDriver is ticking, let it schedule the idle dispatch.
nsRefreshDriver::DispatchIdleRunnableAfterTick(this, mDelay);
nsRefreshDriver::DispatchIdleRunnableAfterTickUnlessExists(this, mDelay);
// Ensure we get called at some point, even if RefreshDriver is stopped.
SetTimerInternal(mDelay);
} else {