Bug 901597, part 1 - Move CC logging logic into nsCCParams. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Thu, 20 Feb 2014 14:27:03 -0800
changeset 170127 9c987f52f70ffde9a6ee78c0799836ee02e4f007
parent 170126 8991d3139e4064448de5c9c870b7aa7500912354
child 170128 08b5793ca20e4ad3a8c95f7cdac2ebc5ac01f699
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssmaug
bugs901597
milestone30.0a1
Bug 901597, part 1 - Move CC logging logic into nsCCParams. r=smaug
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -232,16 +232,21 @@ struct nsCycleCollectorParams
     bool mAllTracesAtShutdown;
 
     nsCycleCollectorParams() :
         mLogAll      (PR_GetEnv("MOZ_CC_LOG_ALL") != nullptr),
         mLogShutdown (PR_GetEnv("MOZ_CC_LOG_SHUTDOWN") != nullptr),
         mAllTracesAtShutdown (PR_GetEnv("MOZ_CC_ALL_TRACES_AT_SHUTDOWN") != nullptr)
     {
     }
+
+    bool LogThisCC(bool aIsShutdown)
+    {
+        return mLogAll || (aIsShutdown && mLogShutdown);
+    }
 };
 
 #ifdef COLLECT_TIME_DEBUG
 class TimeLog
 {
 public:
     TimeLog() : mLastCheckpoint(TimeStamp::Now()) {}
 
@@ -3301,24 +3306,22 @@ nsCycleCollector::BeginCollection(ccType
 
     bool isShutdown = (aCCType == ShutdownCC);
 
     // Set up the listener for this CC.
     MOZ_ASSERT_IF(isShutdown, !aManualListener);
     MOZ_ASSERT(!mListener, "Forgot to clear a previous listener?");
     mListener = aManualListener;
     aManualListener = nullptr;
-    if (!mListener) {
-        if (mParams.mLogAll || (isShutdown && mParams.mLogShutdown)) {
-            nsRefPtr<nsCycleCollectorLogger> logger = new nsCycleCollectorLogger();
-            if (isShutdown && mParams.mAllTracesAtShutdown) {
-                logger->SetAllTraces();
-            }
-            mListener = logger.forget();
+    if (!mListener && mParams.LogThisCC(isShutdown)) {
+        nsRefPtr<nsCycleCollectorLogger> logger = new nsCycleCollectorLogger();
+        if (isShutdown && mParams.mAllTracesAtShutdown) {
+            logger->SetAllTraces();
         }
+        mListener = logger.forget();
     }
 
     bool forceGC = isShutdown;
     if (!forceGC && mListener) {
         // On a WantAllTraces CC, force a synchronous global GC to prevent
         // hijinks from ForgetSkippable and compartmental GCs.
         mListener->GetWantAllTraces(&forceGC);
     }