Bug 1100501 - Avoid a late shutdown of chromium's StatisticsRecorder. r=georg

This commit is contained in:
Jim Mathies 2015-04-09 15:41:53 -05:00
parent 12a663da50
commit 6d8e5c2488
2 changed files with 18 additions and 20 deletions

View File

@ -823,9 +823,6 @@ private:
const uint32_t mBucketCount; const uint32_t mBucketCount;
}; };
// A initializer to initialize histogram collection
StatisticsRecorder gStatisticsRecorder;
// Hardcoded probes // Hardcoded probes
struct TelemetryHistogram { struct TelemetryHistogram {
uint32_t min; uint32_t min;

View File

@ -86,6 +86,8 @@
#include "mozilla/scache/StartupCache.h" #include "mozilla/scache/StartupCache.h"
#include "nsIGfxInfo.h" #include "nsIGfxInfo.h"
#include "base/histogram.h"
#include "mozilla/unused.h" #include "mozilla/unused.h"
#ifdef XP_WIN #ifdef XP_WIN
@ -2929,9 +2931,7 @@ class XREMain
{ {
public: public:
XREMain() : XREMain() :
mScopedXPCOM(nullptr) mStartOffline(false)
, mAppData(nullptr)
, mStartOffline(false)
, mShuttingDown(false) , mShuttingDown(false)
#ifdef MOZ_ENABLE_XREMOTE #ifdef MOZ_ENABLE_XREMOTE
, mDisableRemote(false) , mDisableRemote(false)
@ -2942,13 +2942,9 @@ public:
{}; {};
~XREMain() { ~XREMain() {
if (mAppData) { mScopedXPCOM = nullptr;
delete mAppData; mStatisticsRecorder = nullptr;
} mAppData = nullptr;
if (mScopedXPCOM) {
NS_WARNING("Scoped xpcom should have been deleted!");
delete mScopedXPCOM;
}
} }
int XRE_main(int argc, char* argv[], const nsXREAppData* aAppData); int XRE_main(int argc, char* argv[], const nsXREAppData* aAppData);
@ -2965,8 +2961,10 @@ public:
nsCOMPtr<nsIRemoteService> mRemoteService; nsCOMPtr<nsIRemoteService> mRemoteService;
#endif #endif
ScopedXPCOMStartup* mScopedXPCOM; UniquePtr<ScopedXPCOMStartup> mScopedXPCOM;
ScopedAppData* mAppData; UniquePtr<base::StatisticsRecorder> mStatisticsRecorder;
nsAutoPtr<mozilla::ScopedAppData> mAppData;
nsXREDirProvider mDirProvider; nsXREDirProvider mDirProvider;
nsAutoCString mProfileName; nsAutoCString mProfileName;
nsAutoCString mDesktopStartupID; nsAutoCString mDesktopStartupID;
@ -3085,7 +3083,7 @@ XREMain::XRE_mainInit(bool* aExitFlag)
return 1; return 1;
} }
rv = XRE_ParseAppData(overrideLF, mAppData); rv = XRE_ParseAppData(overrideLF, mAppData.get());
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
Output(true, "Couldn't read override.ini"); Output(true, "Couldn't read override.ini");
return 1; return 1;
@ -4201,6 +4199,10 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
NS_ENSURE_TRUE(aAppData, 2); NS_ENSURE_TRUE(aAppData, 2);
// A initializer to initialize histogram collection, a chromium
// thing used by Telemetry.
mStatisticsRecorder = MakeUnique<base::StatisticsRecorder>();
mAppData = new ScopedAppData(aAppData); mAppData = new ScopedAppData(aAppData);
if (!mAppData) if (!mAppData)
return 1; return 1;
@ -4238,7 +4240,7 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
bool appInitiatedRestart = false; bool appInitiatedRestart = false;
// Start the real application // Start the real application
mScopedXPCOM = new ScopedXPCOMStartup(); mScopedXPCOM = MakeUnique<ScopedXPCOMStartup>();
if (!mScopedXPCOM) if (!mScopedXPCOM)
return 1; return 1;
@ -4273,8 +4275,8 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
#endif /* MOZ_ENABLE_XREMOTE */ #endif /* MOZ_ENABLE_XREMOTE */
} }
delete mScopedXPCOM;
mScopedXPCOM = nullptr; mScopedXPCOM = nullptr;
mStatisticsRecorder = nullptr;
// unlock the profile after ScopedXPCOMStartup object (xpcom) // unlock the profile after ScopedXPCOMStartup object (xpcom)
// has gone out of scope. see bug #386739 for more details // has gone out of scope. see bug #386739 for more details
@ -4352,7 +4354,7 @@ XRE_metroStartup(bool runXREMain)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// Start the real application // Start the real application
xreMainPtr->mScopedXPCOM = new ScopedXPCOMStartup(); xreMainPtr->mScopedXPCOM = MakeUnique<ScopedXPCOMStartup>();
if (!xreMainPtr->mScopedXPCOM) if (!xreMainPtr->mScopedXPCOM)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -4369,7 +4371,6 @@ XRE_metroStartup(bool runXREMain)
void void
XRE_metroShutdown() XRE_metroShutdown()
{ {
delete xreMainPtr->mScopedXPCOM;
xreMainPtr->mScopedXPCOM = nullptr; xreMainPtr->mScopedXPCOM = nullptr;
#ifdef MOZ_INSTRUMENT_EVENT_LOOP #ifdef MOZ_INSTRUMENT_EVENT_LOOP