Bug 1226443 P5 Always use first scheduled update timer instead of rescheduling on new events. r=ehsan
☠☠ backed out by c873567c2898 ☠ ☠
authorBen Kelly <ben@wanderview.com>
Thu, 10 Dec 2015 18:08:14 -0500
changeset 276143 d518261eb3b17f3e6b11fdb6d55ec1b7d4b11901
parent 276142 a7def186c1d3f25cf8c8fb150487849af0a2b6ae
child 276144 f24cb2c2ddf0c91eafe64ee868f78b40d9c6901f
push id69058
push userbkelly@mozilla.com
push dateThu, 10 Dec 2015 23:08:27 +0000
treeherdermozilla-inbound@d518261eb3b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1226443
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1226443 P5 Always use first scheduled update timer instead of rescheduling on new events. r=ehsan
dom/workers/ServiceWorkerManager.cpp
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -4849,23 +4849,26 @@ ServiceWorkerManager::ScheduleUpdateTime
 
   RegistrationDataPerPrincipal* data;
   if (!mRegistrationInfos.Get(scopeKey, &data)) {
     return;
   }
 
   nsCOMPtr<nsITimer> 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<nsITimerCallback> callback = new UpdateTimerCallback(aPrincipal,
                                                                 aScope);
 
   const uint32_t UPDATE_DELAY_MS = 1000;
 
   rv = timer->InitWithCallback(callback, UPDATE_DELAY_MS,