Bug 1065258 (part 2) - Rename some variables. r=jld.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 10 Sep 2014 00:30:17 -0700
changeset 204733 2019276e57d6586f73cf3ed9bb8a99d62de90545
parent 204732 40e1a85a139ec405779b527c994f65313b37d409
child 204734 dd2f3e9c31066fb3c219dda9423d90bcada360f6
push id48990
push usernnethercote@mozilla.com
push dateThu, 11 Sep 2014 05:23:46 +0000
treeherdermozilla-inbound@ef537d9428fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1065258
milestone35.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 1065258 (part 2) - Rename some variables. r=jld.
xpcom/base/nsMemoryInfoDumper.cpp
--- a/xpcom/base/nsMemoryInfoDumper.cpp
+++ b/xpcom/base/nsMemoryInfoDumper.cpp
@@ -577,106 +577,109 @@ DumpFooter(nsIGZFileWriter* aWriter)
   return NS_OK;
 }
 
 class TempDirMemoryFinishCallback MOZ_FINAL : public nsIFinishReportingCallback
 {
 public:
   NS_DECL_ISUPPORTS
 
-  TempDirMemoryFinishCallback(nsGZFileWriter* aWriter,
-                              nsIFile* aTmpFile,
-                              const nsCString& aFilename,
+  TempDirMemoryFinishCallback(nsGZFileWriter* aReportsWriter,
+                              nsIFile* aReportsTmpFile,
+                              const nsCString& aReportsFinalFilename,
                               const nsString& aIdentifier)
-    : mrWriter(aWriter)
-    , mrTmpFile(aTmpFile)
-    , mrFilename(aFilename)
+    : mReportsWriter(aReportsWriter)
+    , mReportsTmpFile(aReportsTmpFile)
+    , mReportsFilename(aReportsFinalFilename)
     , mIdentifier(aIdentifier)
   {
   }
 
   NS_IMETHOD Callback(nsISupports* aData)
   {
-    nsresult rv = DumpFooter(mrWriter);
+    nsresult rv = DumpFooter(mReportsWriter);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    // The call to Finish() deallocates the memory allocated by mrWriter's first
-    // DUMP() call (within DumpProcessMemoryReportsToGZFileWriter()).  Because
-    // that memory was live while the memory reporters ran and thus measured by
-    // them -- by "heap-allocated" if nothing else -- we want DMD to see it as
-    // well.  So we deliberately don't call Finish() until after DMD finishes.
-    rv = mrWriter->Finish();
+    // The call to Finish() deallocates the memory allocated by mReportsWriter's
+    // first DUMP() call (within DumpProcessMemoryReportsToGZFileWriter()).
+    // Because that memory was live while the memory reporters ran and thus
+    // measured by them -- by "heap-allocated" if nothing else -- we want DMD to
+    // see it as well.  So we deliberately don't call Finish() until after DMD
+    // finishes.
+    rv = mReportsWriter->Finish();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     // Rename the memory reports file, now that we're done writing all the
     // files. Its final name is "memory-report<-identifier>-<pid>.json.gz".
 
-    nsCOMPtr<nsIFile> mrFinalFile;
-    rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mrFinalFile));
+    nsCOMPtr<nsIFile> reportsFinalFile;
+    rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR,
+                                getter_AddRefs(reportsFinalFile));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
   #ifdef ANDROID
-    rv = mrFinalFile->AppendNative(NS_LITERAL_CSTRING("memory-reports"));
+    rv = reportsFinalFile->AppendNative(NS_LITERAL_CSTRING("memory-reports"));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   #endif
 
-    rv = mrFinalFile->AppendNative(mrFilename);
+    rv = reportsFinalFile->AppendNative(mReportsFilename);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    rv = mrFinalFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
+    rv = reportsFinalFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    nsAutoString mrActualFinalFilename;
-    rv = mrFinalFile->GetLeafName(mrActualFinalFilename);
+    nsAutoString reportsFinalFilename;
+    rv = reportsFinalFile->GetLeafName(reportsFinalFilename);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    rv = mrTmpFile->MoveTo(/* directory */ nullptr, mrActualFinalFilename);
+    rv = mReportsTmpFile->MoveTo(/* directory */ nullptr,
+                                 reportsFinalFilename);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     // Write a message to the console.
 
     nsCOMPtr<nsIConsoleService> cs =
       do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     nsString path;
-    mrTmpFile->GetPath(path);
+    mReportsTmpFile->GetPath(path);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     nsString msg = NS_LITERAL_STRING("nsIMemoryInfoDumper dumped reports to ");
     msg.Append(path);
     return cs->LogStringMessage(msg.get());
   }
 
 private:
   ~TempDirMemoryFinishCallback() {}
 
-  nsRefPtr<nsGZFileWriter> mrWriter;
-  nsCOMPtr<nsIFile> mrTmpFile;
-  nsCString mrFilename;
+  nsRefPtr<nsGZFileWriter> mReportsWriter;
+  nsCOMPtr<nsIFile> mReportsTmpFile;
+  nsCString mReportsFilename;
   nsString mIdentifier;
 };
 
 NS_IMPL_ISUPPORTS(TempDirMemoryFinishCallback, nsIFinishReportingCallback)
 
 NS_IMETHODIMP
 nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
                                             bool aAnonymize,
@@ -691,58 +694,58 @@ nsMemoryInfoDumper::DumpMemoryInfoToTemp
   //
   // in NS_OS_TEMP_DIR for writing.  When we're finished writing the report,
   // we'll rename this file and get rid of the "incomplete-" prefix.
   //
   // We do this because we don't want scripts which poll the filesystem
   // looking for memory report dumps to grab a file before we're finished
   // writing to it.
 
-  // Note that |mrFilename| is missing the "incomplete-" prefix; we'll tack
-  // that on in a moment.
-  nsCString mrFilename;
+  nsCString reportsFinalFilename;
   // The "unified" indicates that we merge the memory reports from all
   // processes and write out one file, rather than a separate file for
   // each process as was the case before bug 946407.  This is so that
   // the get_about_memory.py script in the B2G repository can
   // determine when it's done waiting for files to appear.
   MakeFilename("unified-memory-report", identifier, getpid(), "json.gz",
-               mrFilename);
+               reportsFinalFilename);
 
-  nsCOMPtr<nsIFile> mrTmpFile;
+  nsCOMPtr<nsIFile> reportsTmpFile;
   nsresult rv;
   // In Android case, this function will open a file named aFilename under
   // specific folder (/data/local/tmp/memory-reports). Otherwise, it will
   // open a file named aFilename under "NS_OS_TEMP_DIR".
   rv = nsDumpUtils::OpenTempFile(NS_LITERAL_CSTRING("incomplete-") +
-                                 mrFilename,
-                                 getter_AddRefs(mrTmpFile),
+                                 reportsFinalFilename,
+                                 getter_AddRefs(reportsTmpFile),
                                  NS_LITERAL_CSTRING("memory-reports"));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
-  rv = mrWriter->Init(mrTmpFile);
+  nsRefPtr<nsGZFileWriter> reportsWriter = new nsGZFileWriter();
+  rv = reportsWriter->Init(reportsTmpFile);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Dump the memory reports to the file.
-  rv = DumpHeader(mrWriter);
+  rv = DumpHeader(reportsWriter);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Process reporters.
   nsCOMPtr<nsIMemoryReporterManager> mgr =
     do_GetService("@mozilla.org/memory-reporter-manager;1");
-  nsRefPtr<DumpReportCallback> dumpReport = new DumpReportCallback(mrWriter);
+  nsRefPtr<DumpReportCallback> dumpReport =
+    new DumpReportCallback(reportsWriter);
   nsRefPtr<nsIFinishReportingCallback> finishReport =
-    new TempDirMemoryFinishCallback(mrWriter, mrTmpFile, mrFilename, identifier);
+    new TempDirMemoryFinishCallback(reportsWriter, reportsTmpFile,
+                                    reportsFinalFilename, identifier);
   rv = mgr->GetReportsExtended(dumpReport, nullptr,
                                finishReport, nullptr,
                                aAnonymize,
                                aMinimizeMemoryUsage,
                                /* DMDident = */ identifier);
   return rv;
 }
 
@@ -855,56 +858,57 @@ nsMemoryInfoDumper::DumpMemoryReportsToN
   nsIFinishDumpingCallback* aFinishDumping,
   nsISupports* aFinishDumpingData,
   bool aAnonymize)
 {
   MOZ_ASSERT(!aFilename.IsEmpty());
 
   // Create the file.
 
-  nsCOMPtr<nsIFile> mrFile;
-  nsresult rv = NS_NewLocalFile(aFilename, false, getter_AddRefs(mrFile));
+  nsCOMPtr<nsIFile> reportsFile;
+  nsresult rv = NS_NewLocalFile(aFilename, false, getter_AddRefs(reportsFile));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  mrFile->InitWithPath(aFilename);
+  reportsFile->InitWithPath(aFilename);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   bool exists;
-  rv = mrFile->Exists(&exists);
+  rv = reportsFile->Exists(&exists);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (!exists) {
-    rv = mrFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
+    rv = reportsFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   // Write the memory reports to the file.
 
-  nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
-  rv = mrWriter->Init(mrFile);
+  nsRefPtr<nsGZFileWriter> reportsWriter = new nsGZFileWriter();
+  rv = reportsWriter->Init(reportsFile);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  rv = DumpHeader(mrWriter);
+  rv = DumpHeader(reportsWriter);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Process reports and finish up.
   nsCOMPtr<nsIMemoryReporterManager> mgr =
     do_GetService("@mozilla.org/memory-reporter-manager;1");
-  nsRefPtr<DumpReportCallback> dumpReport = new DumpReportCallback(mrWriter);
+  nsRefPtr<DumpReportCallback> dumpReport =
+    new DumpReportCallback(reportsWriter);
   nsRefPtr<FinishReportingCallback> finishReporting =
     new FinishReportingCallback(aFinishDumping, aFinishDumpingData);
-  return mgr->GetReports(dumpReport, nullptr, finishReporting, mrWriter,
+  return mgr->GetReports(dumpReport, nullptr, finishReporting, reportsWriter,
                          aAnonymize);
 }
 
 #undef DUMP