Bug 690585 - Report startup interruptions r=glandium
authorTaras Glek <tglek@mozilla.com>
Mon, 24 Oct 2011 14:38:39 -0700
changeset 79804 38ec795c60651a31424231b74bfa8df7a25e89cc
parent 79803 aedc89b90ba58e6396ed89fc05d4fdff1da6f5db
child 79805 10b1706610031fd0bae830bd0b2fef9170653f17
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs690585
milestone10.0a1
Bug 690585 - Report startup interruptions r=glandium
toolkit/components/telemetry/TelemetryPing.js
toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -186,31 +186,31 @@ function getMetadata(reason) {
 
 /**
  * Gets a series of simple measurements (counters). At the moment, this
  * only returns startup data from nsIAppStartup.getStartupInfo().
  * 
  * @return simple measurements as a dictionary.
  */
 function getSimpleMeasurements() {
-  let si = Cc["@mozilla.org/toolkit/app-startup;1"].
-           getService(Ci.nsIAppStartup).getStartupInfo();
+  let si = Services.startup.getStartupInfo();
 
   var ret = {
     // uptime in minutes
     uptime: Math.round((new Date() - si.process) / 60000)
   }
 
   if (si.process) {
     for each (let field in ["main", "firstPaint", "sessionRestored"]) {
       if (!(field in si))
         continue;
       ret[field] = si[field] - si.process
     }
   }
+  ret.startupInterrupted = new Number(Services.startup.interrupted);
 
   ret.js = Cc["@mozilla.org/js/xpc/XPConnect;1"]
            .getService(Ci.nsIJSEngineTelemetryStats)
            .telemetryValue;
 
   return ret;
 }
 
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
@@ -38,16 +38,17 @@ function nonexistentServerObserver(aSubj
   telemetry_ping();
 }
 
 function telemetryObserver(aSubject, aTopic, aData) {
   Services.obs.removeObserver(telemetryObserver, aTopic);
   httpserver.registerPathHandler(PATH, checkHistograms);
   const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
   Telemetry.newHistogram(IGNORE_HISTOGRAM, 1, 2, 3, Telemetry.HISTOGRAM_BOOLEAN);
+  Services.startup.interrupted = true;
   telemetry_ping();
 }
 
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   Services.obs.addObserver(nonexistentServerObserver, "telemetry-test-xhr-complete", false);
   telemetry_ping();
   // spin the event loop
@@ -65,17 +66,17 @@ function checkHistograms(request, respon
   // do not need the http server anymore
   httpserver.stop(do_test_finished);
   let s = request.bodyInputStream
   let payload = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON)
                                              .decode(readBytesFromInputStream(s))
 
   do_check_eq(request.getHeader("content-type"), "application/json; charset=UTF-8");
   do_check_true(payload.simpleMeasurements.uptime >= 0)
-
+  do_check_true(payload.simpleMeasurements.startupInterrupted === 1);
   // get rid of the non-deterministic field
   const expected_info = {
     reason: "test-ping",
     OS: "XPCShell", 
     appID: "xpcshell@tests.mozilla.org", 
     appVersion: "1", 
     appName: "XPCShell", 
     appBuildID: "2007010101",