Bug 822812 - Fix usage of nsITimer. r=vladan.
authorRafael Ávila de Espíndola <respindola@mozilla.org>
Tue, 18 Dec 2012 17:43:40 -0500
changeset 125560 be10b073bb11d3d58f5273ec3f253c82116da2a5
parent 125559 1ac81b33e4923a7fa51f266a42fb59d449f9662d
child 125561 22f9cf3cc575164c40c83f3e4a0283adbb2c99d7
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan
bugs822812
milestone20.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 822812 - Fix usage of nsITimer. r=vladan.
toolkit/components/telemetry/TelemetryPing.js
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -70,18 +70,16 @@ const MEM_HISTOGRAMS = {
   "ghost-windows": "GHOST_WINDOWS"
 };
 
 // Seconds of idle time before pinging.
 // On idle-daily a gather-telemetry notification is fired, during it probes can
 // start asynchronous tasks to gather data.  On the next idle the data is sent.
 const IDLE_TIMEOUT_SECONDS = 5 * 60;
 
-const SHUTDOWN_TIME_READ_DELAY_MS = 5413;
-
 var gLastMemoryPoll = null;
 
 let gWasDebuggerAttached = false;
 
 function getLocale() {
   return Cc["@mozilla.org/chrome/chrome-registry;1"].
          getService(Ci.nsIXULChromeRegistry).
          getSelectedLocale('global');
@@ -738,16 +736,19 @@ TelemetryPing.prototype = {
     // Delay full telemetry initialization to give the browser time to
     // run various late initializers. Otherwise our gathered memory
     // footprint and other numbers would be too optimistic.
     this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     function timerCallback() {
       this._initialized = true;
       this.attachObservers();
       this.gatherMemory();
+
+      Telemetry.asyncReadShutdownTime(function () {
+      });
       delete this._timer;
     }
     this._timer.initWithCallback(timerCallback.bind(this), TELEMETRY_DELAY,
                                  Ci.nsITimer.TYPE_ONE_SHOT);
     this.loadSavedPings(false);
   },
 
   verifyPingChecksum: function verifyPingChecksum(ping) {
@@ -1022,22 +1023,16 @@ TelemetryPing.prototype = {
       if (aData == "enter") {
         this.detachObservers()
       } else {
         this.attachObservers()
       }
       break;
     case "xul-window-visible":
       Services.obs.removeObserver(this, "xul-window-visible");
-
-      let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-      timer.initWithCallback(function() {
-        Telemetry.asyncReadShutdownTime(function () {
-        });
-      }, SHUTDOWN_TIME_READ_DELAY_MS, Ci.nsITimer.TYPE_ONE_SHOT);
       this._hasXulWindowVisibleObserver = false;   
       var counters = processInfo.getCounters();
       if (counters) {
         [this._startupIO.startupWindowVisibleReadBytes, 
           this._startupIO.startupWindowVisibleWriteBytes] = counters;
       }
       break;
     case "sessionstore-windows-restored":