Backout c4b249ca469b & 5bd90df027d0 (bug 779298) for assertions on OS X
authorEd Morley <emorley@mozilla.com>
Thu, 16 Aug 2012 17:00:10 +0100
changeset 102544 4392d5928cf148fe29ace861fe84d9997f60fffa
parent 102543 76d7daeaa6240ccf2a7f46a62c7167242be23aa5
child 102545 6a85b6cd56ffc13fd0efa08bb3292d8f889835d8
push id13514
push useremorley@mozilla.com
push dateThu, 16 Aug 2012 16:00:28 +0000
treeherdermozilla-inbound@4392d5928cf1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs779298
milestone17.0a1
backs outc4b249ca469be37c79a609bc4e4e1b78bef27016
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
Backout c4b249ca469b & 5bd90df027d0 (bug 779298) for assertions on OS X
toolkit/components/startup/nsAppStartup.cpp
toolkit/components/telemetry/TelemetryPing.js
toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -135,19 +135,17 @@ public:
 nsAppStartup::nsAppStartup() :
   mConsiderQuitStopper(0),
   mRunning(false),
   mShuttingDown(false),
   mAttemptingQuit(false),
   mRestart(false),
   mInterrupted(false),
   mIsSafeModeNecessary(false),
-  mStartupCrashTrackingEnded(false),
-  mCachedShutdownTime(false),
-  mLastShutdownTime(0)
+  mStartupCrashTrackingEnded(false)
 { }
 
 
 nsresult
 nsAppStartup::Init()
 {
   NS_TIME_FUNCTION;
   nsresult rv;
@@ -286,17 +284,17 @@ static char *
 GetShutdownTimeFileName()
 {
   if (gAlreadyFreedShutdownTimeFileName) {
     return NULL;
   }
 
   if (!gRecordedShutdownTimeFileName) {
     nsCOMPtr<nsIFile> mozFile;
-    NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mozFile));
+    NS_GetSpecialDirectory(NS_APP_PREFS_50_DIR, getter_AddRefs(mozFile));
     if (!mozFile)
       return NULL;
 
     mozFile->AppendNative(NS_LITERAL_CSTRING("Telemetry.ShutdownTime.txt"));
     nsCAutoString nativePath;
     nsresult rv = mozFile->GetNativePath(nativePath);
     if (!NS_SUCCEEDED(rv))
       return NULL;
@@ -583,22 +581,22 @@ nsAppStartup::GetLastShutdownDuration(PR
     FILE *f = fopen(filename, "r");
     if (!f) {
       *aResult = 0;
       return NS_OK;
     }
 
     int shutdownTime;
     int r = fscanf(f, "%d\n", &shutdownTime);
-    fclose(f);
     if (r != 1) {
       *aResult = 0;
       return NS_OK;
     }
 
+    fclose(f);
     mLastShutdownTime = shutdownTime;
     mCachedShutdownTime = true;
   }
 
   *aResult = mLastShutdownTime;
   return NS_OK;
 }
 
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -131,17 +131,17 @@ function getSimpleMeasurements() {
   let isDebuggerAttached = debugService.isDebuggerAttached;
   gWasDebuggerAttached = gWasDebuggerAttached || isDebuggerAttached;
   ret.debuggerAttached = new Number(gWasDebuggerAttached);
 
   ret.js = Cc["@mozilla.org/js/xpc/XPConnect;1"]
            .getService(Ci.nsIJSEngineTelemetryStats)
            .telemetryValue;
 
-  let shutdownDuration = Services.startup.lastShutdownDuration;
+  let shutdownDuration = si.lastShutdownDuration;
   if (shutdownDuration)
     ret.shutdownDuration = shutdownDuration;
 
   return ret;
 }
 
 /**
  * Read the update channel from defaults only.  We do this to ensure that
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
@@ -21,23 +21,16 @@ Cu.import("resource://gre/modules/XPCOMU
 const PATH = "/submit/telemetry/test-ping";
 const SERVER = "http://localhost:4444";
 const IGNORE_HISTOGRAM = "test::ignore_me";
 const IGNORE_HISTOGRAM_TO_CLONE = "MEMORY_HEAP_ALLOCATED";
 const IGNORE_CLONED_HISTOGRAM = "test::ignore_me_also";
 const ADDON_NAME = "Telemetry test addon";
 const ADDON_HISTOGRAM = "addon-histogram";
 const FLASH_VERSION = "1.1.1.1";
-const SHUTDOWN_TIME = 10000;
-
-// Constants from prio.h for nsIFileOutputStream.init
-const PR_WRONLY = 0x2;
-const PR_CREATE_FILE = 0x8;
-const PR_TRUNCATE = 0x20;
-const RW_OWNER = 0600;
 
 const BinaryInputStream = Components.Constructor(
   "@mozilla.org/binaryinputstream;1",
   "nsIBinaryInputStream",
   "setInputStream");
 const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
 
 var httpserver = new HttpServer();
@@ -169,18 +162,16 @@ function checkPayloadInfo(payload, reaso
 
 function checkPayload(request, reason, successfulPings) {
   let payload = decodeRequestPayload(request);
 
   checkPayloadInfo(payload, reason);
   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);
-  do_check_eq(payload.simpleMeasurements.shutdownDuration, SHUTDOWN_TIME);
-
   var isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
   if (isWindows) {
     do_check_true(payload.simpleMeasurements.startupSessionRestoreReadBytes > 0);
     do_check_true(payload.simpleMeasurements.startupSessionRestoreWriteBytes > 0);
   }
 
   const TELEMETRY_PING = "TELEMETRY_PING";
   const TELEMETRY_SUCCESS = "TELEMETRY_SUCCESS";
@@ -377,46 +368,28 @@ const PLUGINHOST_CONTRACTID = "@mozilla.
 const PLUGINHOST_CID = Components.ID("{2329e6ea-1f15-4cbe-9ded-6e98e842de0e}");
 
 function registerFakePluginHost() {
   var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
   registrar.registerFactory(PLUGINHOST_CID, "Fake Plugin Host",
                             PLUGINHOST_CONTRACTID, PluginHostFactory);
 }
 
-function write_fake_shutdown_file() {
-  let profileDirectory = Services.dirsvc.get("ProfD", Ci.nsIFile);
-  let file = profileDirectory.clone();
-  file.append("Telemetry.ShutdownTime.txt");
-  let contents = "" + SHUTDOWN_TIME;
-  let ostream = Cc["@mozilla.org/network/safe-file-output-stream;1"]
-                .createInstance(Ci.nsIFileOutputStream);
-  ostream.init(file, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
-	       RW_OWNER, ostream.DEFER_OPEN);
-  ostream.write(contents, contents.length);
-  ostream.QueryInterface(Ci.nsISafeOutputStream).finish();
-  ostream.close();
-}
-
 function run_test() {
   try {
     var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfoDebug);
     gfxInfo.spoofVendorID("0xabcd");
     gfxInfo.spoofDeviceID("0x1234");
   } catch (x) {
     // If we can't test gfxInfo, that's fine, we'll note it later.
   }
 
   // Addon manager needs a profile directory
   do_get_profile();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
-  // Make it look like we've shutdown before.
-  write_fake_shutdown_file();
-  
   // try to make LightweightThemeManager do stuff
   let gInternalManager = Cc["@mozilla.org/addons/integration;1"]
                          .getService(Ci.nsIObserver)
                          .QueryInterface(Ci.nsITimerCallback);
 
   gInternalManager.observe(null, "addons-startup", null);
   LightweightThemeManager.currentTheme = dummyTheme("1234");