Bug 758585 - Fix all creations of nsITimer that are locally-scoped, module: calendar. r=MakeMyDay
authorJean-Luc Bonnafoux <jeanluc.bonnafoux@wanadoo.fr>
Sat, 11 Feb 2017 21:48:27 +0100
changeset 29252 ad44eb6ab134472e1399e1f4cd6de6e0f94dd478
parent 29251 9c51e042d2393b706a07ae1dab53af663ed82787
child 29253 1da1c3eb9cf9cdd5ebb5aa72cdabbe97c9f7f040
push id2068
push userclokep@gmail.com
push dateMon, 13 Nov 2017 19:02:14 +0000
treeherdercomm-beta@9c7e7ce8672b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay
bugs758585
Bug 758585 - Fix all creations of nsITimer that are locally-scoped, module: calendar. r=MakeMyDay
calendar/base/modules/calProviderUtils.jsm
calendar/providers/caldav/calDavRequestHandlers.js
--- a/calendar/base/modules/calProviderUtils.jsm
+++ b/calendar/base/modules/calProviderUtils.jsm
@@ -145,16 +145,17 @@ cal.InterfaceRequestor_getInterface = fu
  * Bad Certificate Handler for Network Requests. Shows the Network Exception
  * Dialog if a certificate Problem occurs.
  */
 cal.BadCertHandler = function(thisProvider) {
     this.thisProvider = thisProvider;
 };
 cal.BadCertHandler.prototype = {
     QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIBadCertListener2]),
+    timer: null,
 
     notifyCertProblem: function(socketInfo, status, targetSite) {
         // Unfortunately we can't pass js objects using the window watcher, so
         // we'll just take the first available calendar window. We also need to
         // do this on a timer so that the modal window doesn't block the
         // network request.
         let calWindow = cal.getCalendarWindow();
 
@@ -174,21 +175,23 @@ cal.BadCertHandler.prototype = {
                 if (this.thisProvider.canRefresh &&
                     params.exceptionAdded) {
                     // Refresh the provider if the
                     // exception certificate was added
                     this.thisProvider.refresh();
                 }
             }
         };
-        let timer = Components.classes["@mozilla.org/timer;1"]
-                    .createInstance(Components.interfaces.nsITimer);
-        timer.initWithCallback(timerCallback,
-                               0,
-                               Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+        this.timer = Components.classes["@mozilla.org/timer;1"]
+                               .createInstance(Components.interfaces.nsITimer);
+        this.timer.initWithCallback(
+            timerCallback,
+            0,
+            Components.interfaces.nsITimer.TYPE_ONE_SHOT
+        );
         return true;
     }
 };
 
 /**
  * Freebusy interval implementation. All parameters are optional.
  *
  * @param aCalId         The calendar id to set up with.
--- a/calendar/providers/caldav/calDavRequestHandlers.js
+++ b/calendar/providers/caldav/calDavRequestHandlers.js
@@ -673,16 +673,17 @@ multigetSyncHandler.prototype = {
     baseUri: null,
     newSyncToken: null,
     listener: null,
     changeLogListener: null,
     logXML: null,
     unhandledErrors: 0,
     itemsNeedFetching: null,
     additionalSyncNeeded: false,
+    timer: null,
 
     QueryInterface: XPCOMUtils.generateQI([
         Components.interfaces.nsISAXContentHandler,
         Components.interfaces.nsISAXErrorHandler,
         Components.interfaces.nsIRequestObserver,
         Components.interfaces.nsIStreamListener
     ]),
 
@@ -804,21 +805,23 @@ multigetSyncHandler.prototype = {
             this._reader.parseAsync(null);
             let timerCallback = {
                 requestHandler: this,
                 notify: function(timer) {
                     // Call multiget again to get another batch
                     this.requestHandler.doMultiGet();
                 }
             };
-            let timer = Components.classes["@mozilla.org/timer;1"]
-                        .createInstance(Components.interfaces.nsITimer);
-            timer.initWithCallback(timerCallback,
-                                   0,
-                                   Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+            this.timer = Components.classes["@mozilla.org/timer;1"]
+                                   .createInstance(Components.interfaces.nsITimer);
+            this.timer.initWithCallback(
+                timerCallback,
+                0,
+                Components.interfaces.nsITimer.TYPE_ONE_SHOT
+            );
         }
     },
 
     onDataAvailable: function(request, context, inputStream, offset, count) {
         if (this._reader) {
             // No reader means request error
             this._reader.onDataAvailable(request, context, inputStream, offset, count);
         }