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;
};
// A initializer to initialize histogram collection
StatisticsRecorder gStatisticsRecorder;
// Hardcoded probes
struct TelemetryHistogram {
uint32_t min;

View File

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