Bug 1226443 P5 Always use first scheduled update timer instead of rescheduling on new events. r=ehsan
authorBen Kelly <ben@wanderview.com>
Fri, 11 Dec 2015 14:53:11 -0500
changeset 276244 5be379df35f17161d004bd830c4e616f89f2984c
parent 276243 9234f07a413ae38bcae7c51708733ae8f79eb328
child 276245 412e32773fbf36ba8f6ccca4247890204bf7880a
push id69085
push userbkelly@mozilla.com
push dateFri, 11 Dec 2015 19:53:22 +0000
treeherdermozilla-inbound@412e32773fbf [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,