Bug 1252604 - Change logic in alarms observer to return immediately if the alarm has been cancelled, r=kmag
authorbsilverberg <bsilverberg@mozilla.com>
Wed, 16 Mar 2016 16:01:12 +0100
changeset 289196 77258bd00fa310a72fc0de17c9b51cf9a2f96fd2
parent 289195 64f3b9dc2c817bfce599a97fdc2e27f99385a1c3
child 289197 fa585cc009027eca4483d18dfe7826627cc169fe
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1252604
milestone48.0a1
Bug 1252604 - Change logic in alarms observer to return immediately if the alarm has been cancelled, r=kmag MozReview-Commit-ID: LahP6ESDTGd
toolkit/components/extensions/ext-alarms.js
--- a/toolkit/components/extensions/ext-alarms.js
+++ b/toolkit/components/extensions/ext-alarms.js
@@ -44,22 +44,23 @@ function Alarm(extension, name, alarmInf
 Alarm.prototype = {
   clear() {
     this.timer.cancel();
     alarmsMap.get(this.extension).delete(this.name);
     this.canceled = true;
   },
 
   observe(subject, topic, data) {
+    if (this.canceled) {
+      return;
+    }
+
     for (let callback of alarmCallbacksMap.get(this.extension)) {
       callback(this);
     }
-    if (this.canceled) {
-      return;
-    }
 
     if (!this.periodInMinutes) {
       this.clear();
       return;
     }
 
     let delay = this.periodInMinutes * 60 * 1000;
     this.scheduledTime = Date.now() + delay;