From 4c714c7843388e1ea5afdcc8029e8ef98812a1cf Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Fri, 11 Dec 2015 14:53:11 -0500 Subject: [PATCH] Bug 1226443 P5 Always use first scheduled update timer instead of rescheduling on new events. r=ehsan --- dom/workers/ServiceWorkerManager.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index d3761bc0915..cfc73d64ef3 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -4854,13 +4854,16 @@ ServiceWorkerManager::ScheduleUpdateTimer(nsIPrincipal* aPrincipal, nsCOMPtr timer = data->mUpdateTimers.Get(aScope); if (timer) { - timer->Cancel(); - data->mUpdateTimers.Remove(aScope); - } else { - timer = do_CreateInstance("@mozilla.org/timer;1", &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } + // There is already a timer scheduled. In this case just use the original + // schedule time. We don't want to push it out to a later time since that + // could allow updates to be starved forever if events are continuously + // fired. + return; + } + + timer = do_CreateInstance("@mozilla.org/timer;1", &rv); + if (NS_WARN_IF(NS_FAILED(rv))) { + return; } nsCOMPtr callback = new UpdateTimerCallback(aPrincipal,