Backed out changeset 69e0bdbd4f36 for incorrect commit message. r=me
authorScott Johnson <sjohnson@mozilla.com>
Thu, 31 Jan 2013 15:09:09 -0600
changeset 130382 4df72bf4cd1c1b323ca0c91842f178f866a4bcab
parent 130381 743071f62e677477f8e21210a13ca88ad7d71824
child 130383 4d956c4b8279f44482835f9e69183cedfbd276b2
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
milestone21.0a1
backs out69e0bdbd4f36268dcf99dfd5e7f49eb3e7fc8360
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
Backed out changeset 69e0bdbd4f36 for incorrect commit message. r=me
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/Telemetry.h
toolkit/components/telemetry/TelemetryPing.js
toolkit/components/telemetry/nsITelemetry.idl
toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -26,27 +26,24 @@
 #include "nsIXPConnect.h"
 #include "mozilla/Services.h"
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "js/GCAPI.h"
 #include "nsStringGlue.h"
 #include "nsITelemetry.h"
 #include "nsIFile.h"
-#include "nsIFileStreams.h"
 #include "nsIMemoryReporter.h"
-#include "nsISeekableStream.h"
 #include "Telemetry.h" 
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include "nsBaseHashtable.h"
 #include "nsXULAppAPI.h"
 #include "nsThreadUtils.h"
 #include "nsNetCID.h"
-#include "nsNetUtil.h"
 #include "plstr.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "mozilla/ProcessedStack.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/mozPoisonWrite.h"
 
@@ -332,17 +329,16 @@ private:
   Mutex mHashMutex;
   HangReports mHangReports;
   Mutex mHangReportsMutex;
   nsIMemoryReporter *mMemoryReporter;
 
   CombinedStacks mLateWritesStacks; // This is collected out of the main thread.
   bool mCachedTelemetryData;
   uint32_t mLastShutdownTime;
-  uint32_t mFailedLockCount;
   nsCOMArray<nsIFetchTelemetryDataCallback> mCallbacks;
   friend class nsFetchTelemetryData;
 };
 
 TelemetryImpl*  TelemetryImpl::sTelemetry = NULL;
 
 NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(TelemetryMallocSizeOf)
 
@@ -725,106 +721,45 @@ ReadLastShutdownDuration(const char *fil
   fclose(f);
   if (r != 1) {
     return 0;
   }
 
   return shutdownTime;
 }
 
-const int32_t kMaxFailedProfileLockFileSize = 10;
-
-bool
-GetFailedLockCount(nsIInputStream* inStream, uint32_t aCount,
-                   unsigned int& result)
-{
-  nsAutoCString bufStr;
-  nsresult rv;
-  rv = NS_ReadInputStreamToString(inStream, bufStr, aCount);
-  NS_ENSURE_SUCCESS(rv, false);
-  result = bufStr.ToInteger(&rv);
-  return NS_SUCCEEDED(rv) && result > 0;
-}
-
-nsresult
-GetFailedProfileLockFile(nsIFile* *aFile, nsIFile* aProfileDir = nullptr)
-{
-  nsresult rv;
-  if (aProfileDir) {
-    rv = aProfileDir->Clone(aFile);
-  } else {
-    rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, aFile);
-  }
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  (*aFile)->AppendNative(NS_LITERAL_CSTRING("Telemetry.FailedProfileLocks.txt"));
-  return NS_OK;
-}
-
 class nsFetchTelemetryData : public nsRunnable
 {
 public:
-  nsFetchTelemetryData(const char* aShutdownTimeFilename,
-                       nsIFile* aFailedProfileLockFile)
-    : mShutdownTimeFilename(aShutdownTimeFilename),
-      mFailedProfileLockFile(aFailedProfileLockFile),
-      mTelemetry(TelemetryImpl::sTelemetry)
-  {
+  nsFetchTelemetryData(const char *aFilename) :
+    mFilename(aFilename), mTelemetry(TelemetryImpl::sTelemetry) {
   }
 
 private:
-  const char* mShutdownTimeFilename;
-  nsCOMPtr<nsIFile> mFailedProfileLockFile;
+  const char *mFilename;
   nsCOMPtr<TelemetryImpl> mTelemetry;
 
 public:
   void MainThread() {
     mTelemetry->mCachedTelemetryData = true;
     for (unsigned int i = 0, n = mTelemetry->mCallbacks.Count(); i < n; ++i) {
       mTelemetry->mCallbacks[i]->Complete();
     }
     mTelemetry->mCallbacks.Clear();
   }
 
   NS_IMETHOD Run() {
-    LoadFailedLockCount(mTelemetry->mFailedLockCount);
-    mTelemetry->mLastShutdownTime = 
-      ReadLastShutdownDuration(mShutdownTimeFilename);
+    mTelemetry->mLastShutdownTime = ReadLastShutdownDuration(mFilename);
     mTelemetry->ReadLateWritesStacks();
     nsCOMPtr<nsIRunnable> e =
       NS_NewRunnableMethod(this, &nsFetchTelemetryData::MainThread);
     NS_ENSURE_STATE(e);
     NS_DispatchToMainThread(e, NS_DISPATCH_NORMAL);
     return NS_OK;
   }
-
-private:
-  nsresult
-  LoadFailedLockCount(uint32_t& failedLockCount)
-  {
-    failedLockCount = 0;
-    int64_t fileSize = 0;
-    nsresult rv = mFailedProfileLockFile->GetFileSize(&fileSize);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    NS_ENSURE_TRUE(fileSize <= kMaxFailedProfileLockFileSize,
-                   NS_ERROR_UNEXPECTED);
-    nsCOMPtr<nsIInputStream> inStream;
-    rv = NS_NewLocalFileInputStream(getter_AddRefs(inStream),
-                                    mFailedProfileLockFile,
-                                    PR_RDONLY);
-    NS_ENSURE_SUCCESS(rv, rv);
-    NS_ENSURE_TRUE(GetFailedLockCount(inStream, fileSize, failedLockCount),
-                   NS_ERROR_UNEXPECTED);
-    inStream->Close();
-
-    mFailedProfileLockFile->Remove(false);
-    return NS_OK;
-  }
 };
 
 static TimeStamp gRecordedShutdownStartTime;
 static bool gAlreadyFreedShutdownTimeFileName = false;
 static char *gRecordedShutdownTimeFileName = nullptr;
 
 static char *
 GetShutdownTimeFileName()
@@ -862,31 +797,16 @@ TelemetryImpl::GetLastShutdownDuration(u
     return NS_OK;
   }
 
   *aResult = mLastShutdownTime;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-TelemetryImpl::GetFailedProfileLockCount(uint32_t* aResult)
-{
-  // The user must call AsyncFetchTelemetryData first. We return zero instead of
-  // reporting a failure so that the rest of telemetry can uniformly handle
-  // the read not being available yet.
-  if (!mCachedTelemetryData) {
-    *aResult = 0;
-    return NS_OK;
-  }
-
-  *aResult = mFailedLockCount;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 TelemetryImpl::AsyncFetchTelemetryData(nsIFetchTelemetryDataCallback *aCallback)
 {
   // We have finished reading the data already, just call the callback.
   if (mCachedTelemetryData) {
     aCallback->Complete();
     return NS_OK;
   }
 
@@ -911,47 +831,37 @@ TelemetryImpl::AsyncFetchTelemetryData(n
     do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
   if (!targetThread) {
     mCachedTelemetryData = true;
     aCallback->Complete();
     return NS_OK;
   }
 
   // We have to get the filename from the main thread.
-  const char *shutdownTimeFilename = GetShutdownTimeFileName();
-  if (!shutdownTimeFilename) {
-    mCachedTelemetryData = true;
-    aCallback->Complete();
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsIFile> failedProfileLockFile;
-  nsresult rv = GetFailedProfileLockFile(getter_AddRefs(failedProfileLockFile));
-  if (NS_FAILED(rv)) {
+  const char *filename = GetShutdownTimeFileName();
+  if (!filename) {
     mCachedTelemetryData = true;
     aCallback->Complete();
     return NS_OK;
   }
 
   mCallbacks.AppendObject(aCallback);
-  nsCOMPtr<nsIRunnable> event = new nsFetchTelemetryData(shutdownTimeFilename,
-                                                         failedProfileLockFile);
+  nsCOMPtr<nsIRunnable> event = new nsFetchTelemetryData(filename);
 
   targetThread->Dispatch(event, NS_DISPATCH_NORMAL);
   return NS_OK;
 }
 
 TelemetryImpl::TelemetryImpl():
 mHistogramMap(Telemetry::HistogramCount),
 mCanRecord(XRE_GetProcessType() == GeckoProcessType_Default),
 mHashMutex("Telemetry::mHashMutex"),
 mHangReportsMutex("Telemetry::mHangReportsMutex"),
 mCachedTelemetryData(false),
-mLastShutdownTime(0),
-mFailedLockCount(0)
+mLastShutdownTime(0)
 {
   // A whitelist to prevent Telemetry reporting on Addon & Thunderbird DBs
   const char *trackedDBs[] = {
     "addons.sqlite", "content-prefs.sqlite", "cookies.sqlite",
     "downloads.sqlite", "extensions.sqlite", "formhistory.sqlite",
     "index.sqlite", "healthreport.sqlite", "permissions.sqlite",
     "places.sqlite", "search.sqlite", "signons.sqlite", "urlclassifier3.sqlite",
     "webappsstore.sqlite"
@@ -2363,66 +2273,16 @@ GetStackAndModules(const std::vector<uin
     };
     Ret.AddModule(module);
   }
 #endif
 
   return Ret;
 }
 
-void
-WriteFailedProfileLock(nsIFile* aProfileDir)
-{
-  nsCOMPtr<nsIFile> file;
-  nsresult rv = GetFailedProfileLockFile(getter_AddRefs(file), aProfileDir);
-  NS_ENSURE_SUCCESS_VOID(rv);
-  int64_t fileSize = 0;
-  rv = file->GetFileSize(&fileSize);
-  // It's expected that the file might not exist yet
-  if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
-    return;
-  }
-  nsCOMPtr<nsIFileStream> fileStream;
-  rv = NS_NewLocalFileStream(getter_AddRefs(fileStream), file,
-                             PR_RDWR | PR_CREATE_FILE, 0640);
-  NS_ENSURE_SUCCESS_VOID(rv);
-  NS_ENSURE_TRUE_VOID(fileSize <= kMaxFailedProfileLockFileSize);
-  unsigned int failedLockCount = 0;
-  if (fileSize > 0) {
-    nsCOMPtr<nsIInputStream> inStream = do_QueryInterface(fileStream);
-    NS_ENSURE_TRUE_VOID(inStream);
-    if (!GetFailedLockCount(inStream, fileSize, failedLockCount)) {
-      failedLockCount = 0;
-    }
-  }
-  ++failedLockCount;
-  nsAutoCString bufStr;
-  bufStr.AppendInt(static_cast<int>(failedLockCount));
-  nsCOMPtr<nsISeekableStream> seekStream = do_QueryInterface(fileStream);
-  NS_ENSURE_TRUE_VOID(seekStream);
-  // If we read in an existing failed lock count, we need to reset the file ptr
-  if (fileSize > 0) {
-    rv = seekStream->Seek(nsISeekableStream::NS_SEEK_SET, 0);
-    NS_ENSURE_SUCCESS_VOID(rv);
-  }
-  nsCOMPtr<nsIOutputStream> outStream = do_QueryInterface(fileStream);
-  uint32_t bytesLeft = bufStr.Length();
-  const char* bytes = bufStr.get();
-  do {
-    uint32_t written = 0;
-    rv = outStream->Write(bytes, bytesLeft, &written);
-    if (NS_FAILED(rv)) {
-      break;
-    }
-    bytes += written;
-    bytesLeft -= written;
-  } while (bytesLeft > 0);
-  seekStream->SetEOF();
-}
-
 } // namespace Telemetry
 } // namespace mozilla
 
 NSMODULE_DEFN(nsTelemetryModule) = &kTelemetryModule;
 
 /**
  * The XRE_TelemetryAdd function is to be used by embedding applications
  * that can't use mozilla::Telemetry::Accumulate() directly.
--- a/toolkit/components/telemetry/Telemetry.h
+++ b/toolkit/components/telemetry/Telemetry.h
@@ -162,18 +162,11 @@ class ProcessedStack;
  * @param callStack - Array of PCs from the hung call stack
  * @param moduleMap - Array of info about modules in memory (for symbolication)
  */
 #if defined(MOZ_ENABLE_PROFILER_SPS)
 void RecordChromeHang(uint32_t duration,
                       ProcessedStack &aStack);
 #endif
 
-/**
- * Record a failed attempt at locking the user's profile.
- *
- * @param aProfileDir The profile directory whose lock attempt failed
- */
-void WriteFailedProfileLock(nsIFile* aProfileDir);
-
 } // namespace Telemetry
 } // namespace mozilla
 #endif // Telemetry_h__
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -146,20 +146,16 @@ function getSimpleMeasurements() {
   ret.js = Cc["@mozilla.org/js/xpc/XPConnect;1"]
            .getService(Ci.nsIJSEngineTelemetryStats)
            .telemetryValue;
 
   let shutdownDuration = Telemetry.lastShutdownDuration;
   if (shutdownDuration)
     ret.shutdownDuration = shutdownDuration;
 
-  let failedProfileLockCount = Telemetry.failedProfileLockCount;
-  if (failedProfileLockCount)
-    ret.failedProfileLockCount = failedProfileLockCount;
-
   return ret;
 }
 
 /**
  * Read current process I/O counters.
  */            
 let processInfo = {
   _initialized: false,
--- a/toolkit/components/telemetry/nsITelemetry.idl
+++ b/toolkit/components/telemetry/nsITelemetry.idl
@@ -7,17 +7,17 @@
 #include "nsIFile.idl"
 
 [scriptable,function, uuid(3d3b9075-5549-4244-9c08-b64fefa1dd60)]
 interface nsIFetchTelemetryDataCallback : nsISupports
 {
   void complete();
 };
 
-[scriptable, uuid(e70ba4cc-7ccd-41fe-a75c-e4042233a8cb)]
+[scriptable, uuid(23fdd971-8db1-48ef-b9b3-99dbf60f04dd)]
 interface nsITelemetry : nsISupports
 {
   /**
    * Histogram types:
    * HISTOGRAM_EXPONENTIAL - buckets increase exponentially
    * HISTOGRAM_LINEAR - buckets increase linearly
    * HISTOGRAM_BOOLEAN - For storing 0/1 values
    * HISTOGRAM_FLAG - For storing a single value; its count is always == 1.
@@ -43,22 +43,16 @@ interface nsITelemetry : nsISupports
   readonly attribute jsval histogramSnapshots;
 
   /**
    * The amount of time, in milliseconds, that the last session took
    * to shutdown.  Reads as 0 to indicate failure.
    */
   readonly attribute uint32_t lastShutdownDuration;
 
-  /**
-   * The number of failed profile lock attempts that have occurred prior to 
-   * successfully locking the profile
-   */
-  readonly attribute uint32_t failedProfileLockCount;
-
   /*
    * An object containing information about slow SQL statements.
    *
    * {
    *   mainThread: { "sqlString1": [<hit count>, <total time>], "sqlString2": [...], ... },
    *   otherThreads: { "sqlString3": [<hit count>, <total time>], "sqlString4": [...], ... }
    * }
    *
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
@@ -22,17 +22,16 @@ const PATH = "/submit/telemetry/test-pin
 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;
-const FAILED_PROFILE_LOCK_ATTEMPTS = 2;
 
 // 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(
@@ -178,24 +177,16 @@ function checkPayload(request, reason, s
 
   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);
   do_check_eq(payload.simpleMeasurements.savedPings, 1);
 
-  do_check_eq(payload.simpleMeasurements.failedProfileLockCount,
-              FAILED_PROFILE_LOCK_ATTEMPTS);
-  let profileDirectory = Services.dirsvc.get("ProfD", Ci.nsIFile);
-  let failedProfileLocksFile = profileDirectory.clone();
-  failedProfileLocksFile.append("Telemetry.FailedProfileLocks.txt");
-  do_check_true(!failedProfileLocksFile.exists());
-
-
   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";
@@ -443,41 +434,30 @@ function writeStringToFile(file, content
 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;
   writeStringToFile(file, contents);
 }
 
-function write_fake_failedprofilelocks_file() {
-  let profileDirectory = Services.dirsvc.get("ProfD", Ci.nsIFile);
-  let file = profileDirectory.clone();
-  file.append("Telemetry.FailedProfileLocks.txt");
-  let contents = "" + FAILED_PROFILE_LOCK_ATTEMPTS;
-  writeStringToFile(file, contents);
-}
-
 function run_test() {
   do_test_pending();
   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 previously failed to lock a profile a couple times.
-  write_fake_failedprofilelocks_file();
-
   // Make it look like we've shutdown before.
   write_fake_shutdown_file();
 
   Telemetry.asyncFetchTelemetryData(function () {
     actualTest();
   });
 }
 
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -21,17 +21,16 @@
 #endif // MOZ_WIDGET_QT
 
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentChild.h"
 
 #include "mozilla/Util.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Likely.h"
-#include "mozilla/Telemetry.h"
 
 #include "nsAppRunner.h"
 #include "mozilla/AppData.h"
 #include "nsUpdateDriver.h"
 #include "ProfileReset.h"
 
 #ifdef MOZ_INSTRUMENT_EVENT_LOOP
 #include "EventTracer.h"
@@ -1705,18 +1704,16 @@ ProfileLockedDialog(nsIFile* aProfileDir
                     nsINativeAppSupport* aNative, nsIProfileLock* *aResult)
 {
   nsresult rv;
 
   ScopedXPCOMStartup xpcom;
   rv = xpcom.Initialize();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  mozilla::Telemetry::WriteFailedProfileLock(aProfileDir);
-
   rv = xpcom.SetWindowCreator(aNative);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
   { //extra scoping is needed so we release these components before xpcom shutdown
     nsCOMPtr<nsIStringBundleService> sbs =
       mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);