2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2006-05-10 17:30:15 +00:00
|
|
|
/* vim:set ts=4 sw=4 sts=4 ci et: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-05-18 21:43:13 +00:00
|
|
|
|
2009-10-21 23:01:16 +00:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2013-07-20 03:14:34 +00:00
|
|
|
#include "mozilla/Atomics.h"
|
2013-05-07 18:48:59 +00:00
|
|
|
#include "mozilla/Poison.h"
|
2009-05-18 18:15:05 +00:00
|
|
|
#include "mozilla/XPCOM.h"
|
2009-08-28 23:16:19 +00:00
|
|
|
#include "nsXULAppAPI.h"
|
2009-05-18 18:15:05 +00:00
|
|
|
|
2001-12-07 19:54:16 +00:00
|
|
|
#include "nsXPCOMPrivate.h"
|
2006-05-10 17:30:15 +00:00
|
|
|
#include "nsXPCOMCIDInternal.h"
|
2009-05-18 18:15:05 +00:00
|
|
|
|
2014-04-16 00:48:02 +00:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2014-05-07 09:06:19 +00:00
|
|
|
#include "mozilla/layers/AsyncTransactionTracker.h"
|
|
|
|
#include "mozilla/layers/SharedBufferManagerChild.h"
|
|
|
|
|
|
|
|
#include "prlink.h"
|
2014-04-16 00:48:02 +00:00
|
|
|
|
2013-04-30 17:41:22 +00:00
|
|
|
#include "nsCycleCollector.h"
|
2001-03-03 01:24:36 +00:00
|
|
|
#include "nsObserverList.h"
|
2001-10-22 22:01:27 +00:00
|
|
|
#include "nsObserverService.h"
|
1999-05-18 21:43:13 +00:00
|
|
|
#include "nsProperties.h"
|
2000-01-05 09:29:25 +00:00
|
|
|
#include "nsPersistentProperties.h"
|
1999-12-04 20:31:38 +00:00
|
|
|
#include "nsScriptableInputStream.h"
|
2003-03-13 21:23:18 +00:00
|
|
|
#include "nsBinaryStream.h"
|
2004-03-02 01:11:06 +00:00
|
|
|
#include "nsStorageStream.h"
|
2005-07-18 23:39:56 +00:00
|
|
|
#include "nsPipe.h"
|
2011-06-08 18:08:31 +00:00
|
|
|
#include "nsScriptableBase64Encoder.h"
|
1999-05-18 21:43:13 +00:00
|
|
|
|
2000-06-03 09:46:12 +00:00
|
|
|
#include "nsMemoryImpl.h"
|
2003-07-07 22:11:36 +00:00
|
|
|
#include "nsDebugImpl.h"
|
2014-02-26 21:36:36 +00:00
|
|
|
#include "nsTraceRefcnt.h"
|
2000-07-22 05:48:04 +00:00
|
|
|
#include "nsErrorService.h"
|
2001-12-07 19:54:16 +00:00
|
|
|
|
1999-05-18 21:43:13 +00:00
|
|
|
#include "nsSupportsArray.h"
|
2002-10-07 19:03:41 +00:00
|
|
|
#include "nsArray.h"
|
2005-10-04 17:19:14 +00:00
|
|
|
#include "nsINIParserImpl.h"
|
1999-08-04 07:08:58 +00:00
|
|
|
#include "nsSupportsPrimitives.h"
|
2000-04-18 02:34:54 +00:00
|
|
|
#include "nsConsoleService.h"
|
1999-05-18 21:43:13 +00:00
|
|
|
|
|
|
|
#include "nsComponentManager.h"
|
2002-09-23 21:46:25 +00:00
|
|
|
#include "nsCategoryManagerUtils.h"
|
1999-05-18 21:43:13 +00:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
|
2006-05-10 17:30:15 +00:00
|
|
|
#include "nsThreadManager.h"
|
|
|
|
#include "nsThreadPool.h"
|
1999-05-18 21:43:13 +00:00
|
|
|
|
1999-10-05 00:07:39 +00:00
|
|
|
#include "xptinfo.h"
|
2000-02-15 06:45:30 +00:00
|
|
|
#include "nsIInterfaceInfoManager.h"
|
2005-11-08 18:17:49 +00:00
|
|
|
#include "xptiprivate.h"
|
2013-03-09 02:54:10 +00:00
|
|
|
#include "mozilla/XPTInterfaceInfoManager.h"
|
1999-05-28 01:14:59 +00:00
|
|
|
|
2001-12-16 06:13:17 +00:00
|
|
|
#include "nsTimerImpl.h"
|
|
|
|
#include "TimerThread.h"
|
|
|
|
|
1999-10-01 23:30:06 +00:00
|
|
|
#include "nsThread.h"
|
2001-01-22 21:52:01 +00:00
|
|
|
#include "nsProcess.h"
|
2004-01-23 10:23:12 +00:00
|
|
|
#include "nsEnvironment.h"
|
2005-07-23 14:05:25 +00:00
|
|
|
#include "nsVersionComparatorImpl.h"
|
1999-10-01 23:30:06 +00:00
|
|
|
|
2012-06-06 02:08:30 +00:00
|
|
|
#include "nsIFile.h"
|
2000-01-24 21:28:28 +00:00
|
|
|
#include "nsLocalFile.h"
|
2014-02-10 22:57:01 +00:00
|
|
|
#if defined(XP_UNIX)
|
2002-06-10 18:50:11 +00:00
|
|
|
#include "nsNativeCharsetUtils.h"
|
2002-06-10 19:47:22 +00:00
|
|
|
#endif
|
2000-01-24 21:28:28 +00:00
|
|
|
#include "nsDirectoryService.h"
|
2000-08-11 20:31:57 +00:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2002-07-18 05:09:10 +00:00
|
|
|
#include "nsCategoryManager.h"
|
2000-02-06 02:02:24 +00:00
|
|
|
#include "nsICategoryManager.h"
|
2002-02-16 01:19:24 +00:00
|
|
|
#include "nsMultiplexInputStream.h"
|
1999-10-25 22:48:44 +00:00
|
|
|
|
2006-01-02 02:30:32 +00:00
|
|
|
#include "nsStringStream.h"
|
2014-08-13 18:45:37 +00:00
|
|
|
extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**);
|
2006-01-02 02:30:32 +00:00
|
|
|
|
2000-03-31 09:50:00 +00:00
|
|
|
#include "nsAtomService.h"
|
2001-10-20 23:19:07 +00:00
|
|
|
#include "nsAtomTable.h"
|
2014-02-26 21:36:35 +00:00
|
|
|
#include "nsISupportsImpl.h"
|
2000-03-31 09:50:00 +00:00
|
|
|
|
2004-11-24 23:21:14 +00:00
|
|
|
#include "nsHashPropertyBag.h"
|
|
|
|
|
2006-07-21 16:28:51 +00:00
|
|
|
#include "nsUnicharInputStream.h"
|
2001-10-31 23:35:07 +00:00
|
|
|
#include "nsVariant.h"
|
|
|
|
|
2005-11-21 21:01:45 +00:00
|
|
|
#include "nsUUIDGenerator.h"
|
|
|
|
|
2009-05-07 19:21:54 +00:00
|
|
|
#include "nsIOUtil.h"
|
|
|
|
|
2003-03-15 01:04:32 +00:00
|
|
|
#include "SpecialSystemDirectory.h"
|
2002-09-27 13:07:01 +00:00
|
|
|
|
2008-10-09 03:51:54 +00:00
|
|
|
#if defined(XP_WIN)
|
2005-05-16 21:23:09 +00:00
|
|
|
#include "nsWindowsRegKey.h"
|
|
|
|
#endif
|
|
|
|
|
2010-04-27 12:57:34 +00:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2006-02-18 21:09:59 +00:00
|
|
|
#include "nsMacUtilsImpl.h"
|
2006-02-17 16:19:53 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-06 06:32:03 +00:00
|
|
|
#include "nsSystemInfo.h"
|
2008-03-06 01:28:25 +00:00
|
|
|
#include "nsMemoryReporterManager.h"
|
2012-10-30 00:41:14 +00:00
|
|
|
#include "nsMemoryInfoDumper.h"
|
2013-07-26 15:37:02 +00:00
|
|
|
#include "nsSecurityConsoleMessage.h"
|
2012-10-25 15:36:24 +00:00
|
|
|
#include "nsMessageLoop.h"
|
2006-07-06 06:32:03 +00:00
|
|
|
|
2014-03-20 02:52:11 +00:00
|
|
|
#include "nsStatusReporterManager.h"
|
|
|
|
|
2004-06-15 16:38:43 +00:00
|
|
|
#include <locale.h>
|
2010-04-02 18:38:25 +00:00
|
|
|
#include "mozilla/Services.h"
|
2010-08-10 22:08:06 +00:00
|
|
|
#include "mozilla/Omnijar.h"
|
2011-10-12 17:52:26 +00:00
|
|
|
#include "mozilla/HangMonitor.h"
|
2012-01-10 20:29:58 +00:00
|
|
|
#include "mozilla/Telemetry.h"
|
2013-11-22 19:17:29 +00:00
|
|
|
#include "mozilla/BackgroundHangMonitor.h"
|
2004-06-15 16:38:43 +00:00
|
|
|
|
2010-06-11 20:13:26 +00:00
|
|
|
#include "nsChromeRegistry.h"
|
|
|
|
#include "nsChromeProtocolHandler.h"
|
2014-03-14 22:27:21 +00:00
|
|
|
#include "mozilla/PoisonIOInterposer.h"
|
2013-11-05 12:45:20 +00:00
|
|
|
#include "mozilla/LateWriteChecks.h"
|
2010-06-11 20:13:26 +00:00
|
|
|
|
2010-08-12 19:37:44 +00:00
|
|
|
#include "mozilla/scache/StartupCache.h"
|
|
|
|
|
2009-07-29 21:11:42 +00:00
|
|
|
#include "base/at_exit.h"
|
|
|
|
#include "base/command_line.h"
|
|
|
|
#include "base/message_loop.h"
|
|
|
|
|
2010-02-03 22:17:09 +00:00
|
|
|
#include "mozilla/ipc/BrowserProcessSubThread.h"
|
2011-12-15 19:48:38 +00:00
|
|
|
#include "mozilla/AvailableMemoryTracker.h"
|
2012-01-26 20:54:03 +00:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2014-08-25 19:34:00 +00:00
|
|
|
#include "mozilla/CountingAllocatorBase.h"
|
2013-12-05 03:32:50 +00:00
|
|
|
#include "mozilla/SystemMemoryReporter.h"
|
2009-08-28 19:46:21 +00:00
|
|
|
|
2014-05-18 03:05:46 +00:00
|
|
|
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
|
|
|
|
2013-03-28 17:38:05 +00:00
|
|
|
#ifdef MOZ_VISUAL_EVENT_TRACER
|
2012-06-12 17:06:21 +00:00
|
|
|
#include "mozilla/VisualEventTracer.h"
|
2013-03-28 17:38:05 +00:00
|
|
|
#endif
|
2012-06-12 17:06:21 +00:00
|
|
|
|
2014-02-25 16:04:50 +00:00
|
|
|
#include "ogg/ogg.h"
|
2014-04-22 12:44:04 +00:00
|
|
|
#if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
|
2014-02-25 21:35:13 +00:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
|
|
|
#endif
|
2014-04-08 14:36:30 +00:00
|
|
|
#ifdef MOZ_WEBM
|
|
|
|
#include "nestegg/nestegg.h"
|
|
|
|
#endif
|
2014-02-25 16:04:50 +00:00
|
|
|
|
2013-03-18 14:25:50 +00:00
|
|
|
#include "GeckoProfiler.h"
|
2012-10-06 08:37:45 +00:00
|
|
|
|
2013-07-20 03:14:34 +00:00
|
|
|
#include "jsapi.h"
|
|
|
|
|
2014-06-06 13:51:24 +00:00
|
|
|
#include "gfxPlatform.h"
|
|
|
|
|
2013-03-09 02:54:10 +00:00
|
|
|
using namespace mozilla;
|
2009-07-29 21:11:42 +00:00
|
|
|
using base::AtExitManager;
|
2009-08-28 19:46:21 +00:00
|
|
|
using mozilla::ipc::BrowserProcessSubThread;
|
2013-03-28 17:38:05 +00:00
|
|
|
#ifdef MOZ_VISUAL_EVENT_TRACER
|
|
|
|
using mozilla::eventtracer::VisualEventTracer;
|
|
|
|
#endif
|
2009-07-29 21:11:42 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
static AtExitManager* sExitManager;
|
|
|
|
static MessageLoop* sMessageLoop;
|
|
|
|
static bool sCommandLineWasInitialized;
|
2009-08-28 19:46:21 +00:00
|
|
|
static BrowserProcessSubThread* sIOThread;
|
2014-01-14 16:33:31 +00:00
|
|
|
static BackgroundHangMonitor* sMainHangMonitor;
|
2009-07-29 21:11:42 +00:00
|
|
|
|
|
|
|
} /* anonymous namespace */
|
|
|
|
|
2002-06-14 21:33:05 +00:00
|
|
|
// Registry Factory creation function defined in nsRegistry.cpp
|
|
|
|
// We hook into this function locally to create and register the registry
|
|
|
|
// Since noone outside xpcom needs to know about this and nsRegistry.cpp
|
|
|
|
// does not have a local include file, we are putting this definition
|
|
|
|
// here rather than in nsIRegistry.h
|
2003-01-28 22:17:58 +00:00
|
|
|
extern nsresult NS_RegistryGetFactory(nsIFactory** aFactory);
|
2014-08-13 18:45:37 +00:00
|
|
|
extern nsresult NS_CategoryManagerGetFactory(nsIFactory**);
|
2002-06-14 21:33:05 +00:00
|
|
|
|
2010-10-16 19:58:20 +00:00
|
|
|
#ifdef XP_WIN
|
2012-09-25 00:50:30 +00:00
|
|
|
extern nsresult CreateAnonTempFileRemover();
|
2010-10-16 19:58:20 +00:00
|
|
|
#endif
|
|
|
|
|
2003-09-08 00:31:50 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsProcess)
|
2001-01-22 21:52:01 +00:00
|
|
|
|
1999-08-04 07:08:58 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsIDImpl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsStringImpl)
|
2002-08-06 01:32:51 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCStringImpl)
|
1999-08-04 07:08:58 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRBoolImpl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint8Impl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint16Impl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint32Impl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint64Impl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRTimeImpl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCharImpl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt16Impl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt32Impl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt64Impl)
|
1999-08-06 09:42:12 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsFloatImpl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsDoubleImpl)
|
1999-08-20 03:14:46 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsVoidImpl)
|
2001-04-11 00:10:39 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsInterfacePointerImpl)
|
1999-08-04 07:08:58 +00:00
|
|
|
|
2005-03-02 16:37:53 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsConsoleService, Init)
|
2003-09-08 00:31:50 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAtomService)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerImpl)
|
2003-03-13 21:23:18 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryOutputStream)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryInputStream)
|
2004-03-02 01:11:06 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsStorageStream)
|
2005-07-23 14:05:25 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVersionComparatorImpl)
|
2011-06-08 18:08:31 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableBase64Encoder)
|
2013-03-28 17:38:05 +00:00
|
|
|
#ifdef MOZ_VISUAL_EVENT_TRACER
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(VisualEventTracer)
|
|
|
|
#endif
|
2002-01-27 23:56:02 +00:00
|
|
|
|
2003-09-08 00:31:50 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariant)
|
2001-10-31 23:35:07 +00:00
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHashPropertyBag)
|
2004-11-24 23:21:14 +00:00
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
NS_GENERIC_AGGREGATED_CONSTRUCTOR(nsProperties)
|
2005-09-28 13:13:27 +00:00
|
|
|
|
2006-05-14 22:41:47 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUUIDGenerator, Init)
|
2005-11-21 21:01:45 +00:00
|
|
|
|
2010-04-27 12:57:34 +00:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2006-02-18 21:09:59 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl)
|
2006-02-17 16:19:53 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-06 06:32:03 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init)
|
|
|
|
|
2009-10-03 07:21:34 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMemoryReporterManager, Init)
|
2008-03-06 01:28:25 +00:00
|
|
|
|
2012-10-30 00:41:14 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMemoryInfoDumper)
|
|
|
|
|
2014-03-20 02:52:11 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStatusReporterManager, Init)
|
|
|
|
|
2009-05-07 19:21:54 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIOUtil)
|
|
|
|
|
2013-07-26 15:37:02 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSecurityConsoleMessage)
|
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
static nsresult
|
2014-08-13 18:45:37 +00:00
|
|
|
nsThreadManagerGetSingleton(nsISupports* aOuter,
|
2006-05-10 17:30:15 +00:00
|
|
|
const nsIID& aIID,
|
2014-08-13 18:45:37 +00:00
|
|
|
void** aInstancePtr)
|
2006-05-10 17:30:15 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_ASSERTION(aInstancePtr, "null outptr");
|
|
|
|
if (NS_WARN_IF(aOuter)) {
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
}
|
2006-05-10 17:30:15 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
return nsThreadManager::get()->QueryInterface(aIID, aInstancePtr);
|
2006-05-10 17:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThreadPool)
|
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
static nsresult
|
2014-08-13 18:45:37 +00:00
|
|
|
nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* aOuter,
|
2002-01-27 23:56:02 +00:00
|
|
|
const nsIID& aIID,
|
2014-08-13 18:45:37 +00:00
|
|
|
void** aInstancePtr)
|
2001-11-26 22:31:39 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_ASSERTION(aInstancePtr, "null outptr");
|
|
|
|
if (NS_WARN_IF(aOuter)) {
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
}
|
2002-01-27 23:56:02 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfoManager> iim(XPTInterfaceInfoManager::GetSingleton());
|
|
|
|
if (!iim) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-11-26 22:31:39 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
return iim->QueryInterface(aIID, aInstancePtr);
|
2001-11-26 22:31:39 +00:00
|
|
|
}
|
|
|
|
|
2013-10-10 20:41:00 +00:00
|
|
|
nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = nullptr;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool gXPCOMShuttingDown = false;
|
2013-07-07 20:23:43 +00:00
|
|
|
bool gXPCOMThreadsShutDown = false;
|
2014-07-17 15:15:09 +00:00
|
|
|
char16_t* gGREPath = nullptr;
|
1999-05-18 21:43:13 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
|
|
|
static NS_DEFINE_CID(kINIParserFactoryCID, NS_INIPARSERFACTORY_CID);
|
2014-08-13 18:45:37 +00:00
|
|
|
static NS_DEFINE_CID(kSimpleUnicharStreamFactoryCID,
|
|
|
|
NS_SIMPLE_UNICHAR_STREAM_FACTORY_CID);
|
2001-03-12 20:43:02 +00:00
|
|
|
|
2010-06-11 20:13:26 +00:00
|
|
|
NS_DEFINE_NAMED_CID(NS_CHROMEREGISTRY_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_CHROMEPROTOCOLHANDLER_CID);
|
|
|
|
|
2013-07-26 15:37:02 +00:00
|
|
|
NS_DEFINE_NAMED_CID(NS_SECURITY_CONSOLE_MESSAGE_CID);
|
|
|
|
|
2010-07-01 15:55:57 +00:00
|
|
|
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsChromeRegistry,
|
|
|
|
nsChromeRegistry::GetSingleton)
|
2010-06-11 20:13:26 +00:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeProtocolHandler)
|
|
|
|
|
2001-03-12 20:43:02 +00:00
|
|
|
#define NS_PERSISTENTPROPERTIES_CID NS_IPERSISTENTPROPERTIES_CID /* sigh */
|
2002-07-01 23:36:03 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
static already_AddRefed<nsIFactory>
|
2014-08-13 18:45:37 +00:00
|
|
|
CreateINIParserFactory(const mozilla::Module& aModule,
|
|
|
|
const mozilla::Module::CIDEntry& aEntry)
|
2010-06-10 18:11:11 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
nsCOMPtr<nsIFactory> f = new nsINIParserFactory();
|
|
|
|
return f.forget();
|
2010-06-10 18:11:11 +00:00
|
|
|
}
|
2005-11-21 21:01:45 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
static already_AddRefed<nsIFactory>
|
2014-08-13 18:45:37 +00:00
|
|
|
CreateUnicharStreamFactory(const mozilla::Module& aModule,
|
|
|
|
const mozilla::Module::CIDEntry& aEntry)
|
2010-06-10 18:11:11 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
return already_AddRefed<nsIFactory>(
|
|
|
|
nsSimpleUnicharStreamFactory::GetInstance());
|
2010-06-10 18:11:11 +00:00
|
|
|
}
|
2006-02-17 16:19:53 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
#define COMPONENT(NAME, Ctor) static NS_DEFINE_CID(kNS_##NAME##_CID, NS_##NAME##_CID);
|
|
|
|
#include "XPCOMModule.inc"
|
|
|
|
#undef COMPONENT
|
2006-07-06 06:32:03 +00:00
|
|
|
|
2013-10-10 20:41:00 +00:00
|
|
|
#define COMPONENT(NAME, Ctor) { &kNS_##NAME##_CID, false, nullptr, Ctor },
|
2010-06-10 18:11:11 +00:00
|
|
|
const mozilla::Module::CIDEntry kXPCOMCIDEntries[] = {
|
2014-08-13 18:45:37 +00:00
|
|
|
{ &kComponentManagerCID, true, nullptr, nsComponentManagerImpl::Create },
|
|
|
|
{ &kINIParserFactoryCID, false, CreateINIParserFactory },
|
|
|
|
{ &kSimpleUnicharStreamFactoryCID, false, CreateUnicharStreamFactory },
|
2010-06-10 18:11:11 +00:00
|
|
|
#include "XPCOMModule.inc"
|
2014-08-13 18:45:37 +00:00
|
|
|
{ &kNS_CHROMEREGISTRY_CID, false, nullptr, nsChromeRegistryConstructor },
|
|
|
|
{ &kNS_CHROMEPROTOCOLHANDLER_CID, false, nullptr, nsChromeProtocolHandlerConstructor },
|
|
|
|
{ &kNS_SECURITY_CONSOLE_MESSAGE_CID, false, nullptr, nsSecurityConsoleMessageConstructor },
|
|
|
|
{ nullptr }
|
2001-03-12 20:43:02 +00:00
|
|
|
};
|
2010-06-10 18:11:11 +00:00
|
|
|
#undef COMPONENT
|
2001-03-12 20:43:02 +00:00
|
|
|
|
2010-06-10 18:11:11 +00:00
|
|
|
#define COMPONENT(NAME, Ctor) { NS_##NAME##_CONTRACTID, &kNS_##NAME##_CID },
|
|
|
|
const mozilla::Module::ContractIDEntry kXPCOMContracts[] = {
|
|
|
|
#include "XPCOMModule.inc"
|
2014-08-13 18:45:37 +00:00
|
|
|
{ NS_CHROMEREGISTRY_CONTRACTID, &kNS_CHROMEREGISTRY_CID },
|
|
|
|
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "chrome", &kNS_CHROMEPROTOCOLHANDLER_CID },
|
|
|
|
{ NS_INIPARSERFACTORY_CONTRACTID, &kINIParserFactoryCID },
|
|
|
|
{ NS_SECURITY_CONSOLE_MESSAGE_CONTRACTID, &kNS_SECURITY_CONSOLE_MESSAGE_CID },
|
|
|
|
{ nullptr }
|
2010-06-10 18:11:11 +00:00
|
|
|
};
|
2001-03-12 20:43:02 +00:00
|
|
|
#undef COMPONENT
|
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
const mozilla::Module kXPCOMModule = {
|
|
|
|
mozilla::Module::kVersion, kXPCOMCIDEntries, kXPCOMContracts
|
|
|
|
};
|
2000-08-16 22:40:27 +00:00
|
|
|
|
2003-07-07 22:11:36 +00:00
|
|
|
// gDebug will be freed during shutdown.
|
2012-07-30 14:20:58 +00:00
|
|
|
static nsIDebug* gDebug = nullptr;
|
2005-11-08 18:17:49 +00:00
|
|
|
|
|
|
|
EXPORT_XPCOM_API(nsresult)
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_GetDebug(nsIDebug** aResult)
|
2003-07-07 22:11:36 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
return nsDebugImpl::Create(nullptr, NS_GET_IID(nsIDebug), (void**)aResult);
|
2003-07-07 22:11:36 +00:00
|
|
|
}
|
|
|
|
|
2005-11-08 18:17:49 +00:00
|
|
|
EXPORT_XPCOM_API(nsresult)
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_InitXPCOM(nsIServiceManager** aResult,
|
|
|
|
nsIFile* aBinDirectory)
|
2000-08-16 22:40:27 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
return NS_InitXPCOM2(aResult, aBinDirectory, nullptr);
|
2000-08-16 22:40:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
class ICUReporter MOZ_FINAL
|
|
|
|
: public nsIMemoryReporter
|
|
|
|
, public CountingAllocatorBase<ICUReporter>
|
2013-07-20 03:14:34 +00:00
|
|
|
{
|
2013-08-23 05:24:16 +00:00
|
|
|
public:
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2013-12-08 06:09:10 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
static void* Alloc(const void*, size_t aSize)
|
|
|
|
{
|
|
|
|
return CountingMalloc(aSize);
|
|
|
|
}
|
2013-08-23 05:24:16 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
static void* Realloc(const void*, void* aPtr, size_t aSize)
|
|
|
|
{
|
|
|
|
return CountingRealloc(aPtr, aSize);
|
|
|
|
}
|
2013-07-20 03:14:34 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
static void Free(const void*, void* aPtr)
|
|
|
|
{
|
|
|
|
return CountingFree(aPtr);
|
|
|
|
}
|
2013-07-20 03:14:34 +00:00
|
|
|
|
2013-08-23 05:24:16 +00:00
|
|
|
private:
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
|
|
|
bool aAnonymize)
|
|
|
|
{
|
|
|
|
return MOZ_COLLECT_REPORT(
|
|
|
|
"explicit/icu", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
|
|
|
"Memory used by ICU, a Unicode and globalization support library.");
|
|
|
|
}
|
|
|
|
|
|
|
|
~ICUReporter() {}
|
2013-08-23 05:24:16 +00:00
|
|
|
};
|
2013-07-20 03:14:34 +00:00
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(ICUReporter, nsIMemoryReporter)
|
2013-12-08 06:09:10 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
/* static */ template<> Atomic<size_t>
|
|
|
|
CountingAllocatorBase<ICUReporter>::sAmount(0);
|
2013-07-20 03:14:34 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
class OggReporter MOZ_FINAL
|
|
|
|
: public nsIMemoryReporter
|
|
|
|
, public CountingAllocatorBase<OggReporter>
|
2014-02-25 16:04:50 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2014-02-25 16:04:50 +00:00
|
|
|
|
|
|
|
private:
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
|
|
|
bool aAnonymize)
|
|
|
|
{
|
|
|
|
return MOZ_COLLECT_REPORT(
|
|
|
|
"explicit/media/libogg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
|
|
|
"Memory allocated through libogg for Ogg, Theora, and related media files.");
|
|
|
|
}
|
|
|
|
|
|
|
|
~OggReporter() {}
|
2014-02-25 16:04:50 +00:00
|
|
|
};
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(OggReporter, nsIMemoryReporter)
|
2014-02-25 16:04:50 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
/* static */ template<> Atomic<size_t>
|
|
|
|
CountingAllocatorBase<OggReporter>::sAmount(0);
|
2014-02-25 16:04:50 +00:00
|
|
|
|
2014-02-25 21:35:13 +00:00
|
|
|
#ifdef MOZ_VPX
|
2014-08-13 18:45:37 +00:00
|
|
|
class VPXReporter MOZ_FINAL
|
|
|
|
: public nsIMemoryReporter
|
|
|
|
, public CountingAllocatorBase<VPXReporter>
|
2014-02-25 21:35:13 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2014-02-25 21:35:13 +00:00
|
|
|
|
|
|
|
private:
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
|
|
|
bool aAnonymize)
|
|
|
|
{
|
|
|
|
return MOZ_COLLECT_REPORT(
|
|
|
|
"explicit/media/libvpx", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
|
|
|
"Memory allocated through libvpx for WebM media files.");
|
|
|
|
}
|
|
|
|
|
|
|
|
~VPXReporter() {}
|
2014-02-25 21:35:13 +00:00
|
|
|
};
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(VPXReporter, nsIMemoryReporter)
|
2014-02-25 21:35:13 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
/* static */ template<> Atomic<size_t>
|
|
|
|
CountingAllocatorBase<VPXReporter>::sAmount(0);
|
2014-02-25 21:35:13 +00:00
|
|
|
#endif /* MOZ_VPX */
|
|
|
|
|
2014-04-08 14:36:30 +00:00
|
|
|
#ifdef MOZ_WEBM
|
2014-08-25 19:17:15 +00:00
|
|
|
class NesteggReporter MOZ_FINAL
|
|
|
|
: public nsIMemoryReporter
|
|
|
|
, public CountingAllocatorBase<NesteggReporter>
|
2014-04-08 14:36:30 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2014-04-08 14:36:30 +00:00
|
|
|
|
|
|
|
private:
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
|
|
|
bool aAnonymize)
|
|
|
|
{
|
|
|
|
return MOZ_COLLECT_REPORT(
|
|
|
|
"explicit/media/libnestegg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
|
|
|
"Memory allocated through libnestegg for WebM media files.");
|
|
|
|
}
|
|
|
|
|
|
|
|
~NesteggReporter() {}
|
2014-04-08 14:36:30 +00:00
|
|
|
};
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(NesteggReporter, nsIMemoryReporter)
|
2014-04-08 14:36:30 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
/* static */ template<> Atomic<size_t>
|
|
|
|
CountingAllocatorBase<NesteggReporter>::sAmount(0);
|
2014-04-08 14:36:30 +00:00
|
|
|
#endif /* MOZ_WEBM */
|
|
|
|
|
2005-11-08 18:17:49 +00:00
|
|
|
EXPORT_XPCOM_API(nsresult)
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_InitXPCOM2(nsIServiceManager** aResult,
|
|
|
|
nsIFile* aBinDirectory,
|
|
|
|
nsIDirectoryServiceProvider* aAppFileLocationProvider)
|
1999-05-18 21:43:13 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
mozPoisonValueInit();
|
2013-05-07 18:48:59 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
char aLocal;
|
|
|
|
profiler_init(&aLocal);
|
|
|
|
nsresult rv = NS_OK;
|
1999-05-18 21:43:13 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// We are not shutting down
|
|
|
|
gXPCOMShuttingDown = false;
|
2002-06-11 19:26:04 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Initialize the available memory tracker before other threads have had a
|
|
|
|
// chance to start up, because the initialization is not thread-safe.
|
|
|
|
mozilla::AvailableMemoryTracker::Init();
|
2012-04-09 17:53:08 +00:00
|
|
|
|
2014-04-26 14:56:54 +00:00
|
|
|
#ifdef XP_UNIX
|
2014-08-13 18:45:37 +00:00
|
|
|
// Discover the current value of the umask, and save it where
|
|
|
|
// nsSystemInfo::Init can retrieve it when necessary. There is no way
|
|
|
|
// to read the umask without changing it, and the setting is process-
|
|
|
|
// global, so this must be done while we are still single-threaded; the
|
|
|
|
// nsSystemInfo object is typically created much later, when some piece
|
|
|
|
// of chrome JS wants it. The system call is specified as unable to fail.
|
|
|
|
nsSystemInfo::gUserUmask = ::umask(0777);
|
|
|
|
::umask(nsSystemInfo::gUserUmask);
|
2014-04-26 14:56:54 +00:00
|
|
|
#endif
|
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_LogInit();
|
2010-03-04 19:50:28 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Set up chromium libs
|
|
|
|
NS_ASSERTION(!sExitManager && !sMessageLoop, "Bad logic!");
|
2009-07-29 21:11:42 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
if (!AtExitManager::AlreadyRegistered()) {
|
|
|
|
sExitManager = new AtExitManager();
|
|
|
|
}
|
2009-08-28 19:46:21 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
if (!MessageLoop::current()) {
|
|
|
|
sMessageLoop = new MessageLoopForUI(MessageLoop::TYPE_MOZILLA_UI);
|
|
|
|
sMessageLoop->set_thread_name("Gecko");
|
|
|
|
// Set experimental values for main thread hangs:
|
|
|
|
// 512ms for transient hangs and 8192ms for permanent hangs
|
|
|
|
sMessageLoop->set_hang_timeouts(512, 8192);
|
|
|
|
}
|
2009-08-28 19:46:21 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Default &&
|
|
|
|
!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
|
|
|
|
scoped_ptr<BrowserProcessSubThread> ioThread(
|
|
|
|
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
|
2009-08-28 19:46:21 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
base::Thread::Options options;
|
|
|
|
options.message_loop_type = MessageLoop::TYPE_IO;
|
|
|
|
if (NS_WARN_IF(!ioThread->StartWithOptions(options))) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2009-08-28 19:46:21 +00:00
|
|
|
}
|
2009-07-29 21:11:42 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
sIOThread = ioThread.release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Establish the main thread here.
|
|
|
|
rv = nsThreadManager::get()->Init();
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
1999-10-30 01:52:55 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Set up the timer globals/timer thread
|
|
|
|
rv = nsTimerImpl::Startup();
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
2004-05-11 09:38:50 +00:00
|
|
|
|
2011-05-01 18:59:24 +00:00
|
|
|
#ifndef ANDROID
|
2014-08-13 18:45:37 +00:00
|
|
|
// If the locale hasn't already been setup by our embedder,
|
|
|
|
// get us out of the "C" locale and into the system
|
|
|
|
if (strcmp(setlocale(LC_ALL, nullptr), "C") == 0) {
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
}
|
2005-01-30 21:33:47 +00:00
|
|
|
#endif
|
2004-06-15 16:38:43 +00:00
|
|
|
|
2014-02-10 22:57:01 +00:00
|
|
|
#if defined(XP_UNIX)
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_StartupNativeCharsetUtils();
|
2002-06-10 19:44:07 +00:00
|
|
|
#endif
|
2010-08-10 22:08:06 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_StartupLocalFile();
|
2000-12-09 04:11:05 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
StartupSpecialSystemDirectory();
|
2001-02-19 03:09:57 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
nsDirectoryService::RealInit();
|
2002-01-27 23:56:02 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
bool value;
|
2011-07-21 07:57:07 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
if (aBinDirectory) {
|
|
|
|
rv = aBinDirectory->IsDirectory(&value);
|
2002-09-27 13:07:01 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && value) {
|
|
|
|
nsDirectoryService::gService->Set(NS_XPCOM_INIT_CURRENT_PROCESS_DIR,
|
|
|
|
aBinDirectory);
|
2006-05-01 03:47:02 +00:00
|
|
|
}
|
2014-08-13 18:45:37 +00:00
|
|
|
}
|
2011-07-21 07:57:07 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
if (aAppFileLocationProvider) {
|
|
|
|
rv = nsDirectoryService::gService->RegisterProvider(aAppFileLocationProvider);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
2006-05-01 03:47:02 +00:00
|
|
|
}
|
2014-08-13 18:45:37 +00:00
|
|
|
}
|
2002-01-27 23:56:02 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
nsCOMPtr<nsIFile> xpcomLib;
|
|
|
|
nsDirectoryService::gService->Get(NS_GRE_DIR,
|
|
|
|
NS_GET_IID(nsIFile),
|
|
|
|
getter_AddRefs(xpcomLib));
|
|
|
|
MOZ_ASSERT(xpcomLib);
|
2011-07-21 07:57:07 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// set gGREPath
|
|
|
|
nsAutoString path;
|
|
|
|
xpcomLib->GetPath(path);
|
|
|
|
gGREPath = ToNewUnicode(path);
|
2014-07-17 15:15:09 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
xpcomLib->AppendNative(nsDependentCString(XPCOM_DLL));
|
|
|
|
nsDirectoryService::gService->Set(NS_XPCOM_LIBRARY_FILE, xpcomLib);
|
2010-08-10 22:08:06 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
if (!mozilla::Omnijar::IsInitialized()) {
|
|
|
|
mozilla::Omnijar::Init();
|
|
|
|
}
|
2010-08-10 22:08:06 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
if ((sCommandLineWasInitialized = !CommandLine::IsInitialized())) {
|
2009-09-04 07:23:06 +00:00
|
|
|
#ifdef OS_WIN
|
2014-08-13 18:45:37 +00:00
|
|
|
CommandLine::Init(0, nullptr);
|
2009-09-04 07:23:06 +00:00
|
|
|
#else
|
2014-08-13 18:45:37 +00:00
|
|
|
nsCOMPtr<nsIFile> binaryFile;
|
|
|
|
nsDirectoryService::gService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
|
|
|
NS_GET_IID(nsIFile),
|
|
|
|
getter_AddRefs(binaryFile));
|
|
|
|
if (NS_WARN_IF(!binaryFile)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2009-09-04 07:23:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
rv = binaryFile->AppendNative(NS_LITERAL_CSTRING("nonexistent-executable"));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
2013-03-25 21:26:00 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
nsCString binaryPath;
|
|
|
|
rv = binaryFile->GetNativePath(binaryPath);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
2014-02-25 16:04:50 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
static char const* const argv = { strdup(binaryPath.get()) };
|
|
|
|
CommandLine::Init(1, &argv);
|
2014-02-25 21:35:13 +00:00
|
|
|
#endif
|
2014-08-13 18:45:37 +00:00
|
|
|
}
|
2014-02-25 21:35:13 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_ASSERTION(nsComponentManagerImpl::gComponentManager == nullptr,
|
|
|
|
"CompMgr not null at init");
|
2014-04-08 14:36:30 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Create the Component/Service Manager
|
|
|
|
nsComponentManagerImpl::gComponentManager = new nsComponentManagerImpl();
|
|
|
|
NS_ADDREF(nsComponentManagerImpl::gComponentManager);
|
2013-07-20 03:14:34 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Global cycle collector initialization.
|
|
|
|
if (!nsCycleCollector_init()) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2002-01-27 23:56:02 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// And start it up for this thread too.
|
|
|
|
nsCycleCollector_startup();
|
2000-06-03 09:46:12 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Register ICU memory functions. This really shouldn't be necessary: the
|
|
|
|
// JS engine should do this on its own inside JS_Init, and memory-reporting
|
|
|
|
// code should call a JSAPI function to observe ICU memory usage. But we
|
|
|
|
// can't define the alloc/free functions in the JS engine, because it can't
|
|
|
|
// depend on the XPCOM-based memory reporting goop. So for now, we have
|
|
|
|
// this oddness.
|
|
|
|
mozilla::SetICUMemoryFunctions();
|
2005-12-13 17:55:43 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Do the same for libogg.
|
|
|
|
ogg_set_mem_functions(OggReporter::CountingMalloc,
|
|
|
|
OggReporter::CountingCalloc,
|
|
|
|
OggReporter::CountingRealloc,
|
|
|
|
OggReporter::CountingFree);
|
2005-06-07 19:35:20 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
#if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
|
|
|
|
// And for VPX.
|
|
|
|
vpx_mem_set_functions(VPXReporter::CountingMalloc,
|
|
|
|
VPXReporter::CountingCalloc,
|
|
|
|
VPXReporter::CountingRealloc,
|
|
|
|
VPXReporter::CountingFree,
|
|
|
|
memcpy,
|
|
|
|
memset,
|
|
|
|
memmove);
|
|
|
|
#endif
|
2013-04-22 20:49:52 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
#ifdef MOZ_WEBM
|
|
|
|
// And for libnestegg.
|
2014-08-21 21:43:02 +00:00
|
|
|
// libnestegg expects that its realloc implementation will free
|
|
|
|
// the pointer argument when a size of 0 is passed in, so we need
|
|
|
|
// the special version of the counting realloc.
|
|
|
|
nestegg_set_halloc_func(NesteggReporter::CountingFreeingRealloc);
|
2014-08-13 18:45:37 +00:00
|
|
|
#endif
|
2011-12-15 19:48:38 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Initialize the JS engine.
|
|
|
|
if (!JS_Init()) {
|
|
|
|
NS_RUNTIMEABORT("JS_Init failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = nsComponentManagerImpl::gComponentManager->Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_RELEASE(nsComponentManagerImpl::gComponentManager);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aResult) {
|
|
|
|
NS_ADDREF(*aResult = nsComponentManagerImpl::gComponentManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The iimanager constructor searches and registers XPT files.
|
|
|
|
// (We trigger the singleton's lazy construction here to make that happen.)
|
|
|
|
(void)XPTInterfaceInfoManager::GetSingleton();
|
|
|
|
|
|
|
|
// After autoreg, but before we actually instantiate any components,
|
|
|
|
// add any services listed in the "xpcom-directory-providers" category
|
|
|
|
// to the directory service.
|
|
|
|
nsDirectoryService::gService->RegisterCategoryProviders();
|
|
|
|
|
|
|
|
// Force layout to spin up so that nsContentUtils is available for cx stack
|
|
|
|
// munging.
|
|
|
|
nsCOMPtr<nsISupports> componentLoader =
|
|
|
|
do_GetService("@mozilla.org/moz/jsloader;1");
|
|
|
|
|
|
|
|
mozilla::scache::StartupCache::GetSingleton();
|
|
|
|
mozilla::AvailableMemoryTracker::Activate();
|
|
|
|
|
|
|
|
// Notify observers of xpcom autoregistration start
|
|
|
|
NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_CATEGORY,
|
|
|
|
nullptr,
|
|
|
|
NS_XPCOM_STARTUP_OBSERVER_ID);
|
2010-10-16 19:58:20 +00:00
|
|
|
#ifdef XP_WIN
|
2014-08-13 18:45:37 +00:00
|
|
|
CreateAnonTempFileRemover();
|
2010-10-16 19:58:20 +00:00
|
|
|
#endif
|
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// We only want the SystemMemoryReporter running in one process, because it
|
|
|
|
// profiles the entire system. The main process is the obvious place for
|
|
|
|
// it.
|
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
|
|
|
mozilla::SystemMemoryReporter::Init();
|
|
|
|
}
|
2013-12-05 03:32:50 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// The memory reporter manager is up and running -- register our reporters.
|
|
|
|
RegisterStrongMemoryReporter(new ICUReporter());
|
|
|
|
RegisterStrongMemoryReporter(new OggReporter());
|
2014-02-25 21:35:13 +00:00
|
|
|
#ifdef MOZ_VPX
|
2014-08-13 18:45:37 +00:00
|
|
|
RegisterStrongMemoryReporter(new VPXReporter());
|
2014-02-25 21:35:13 +00:00
|
|
|
#endif
|
2014-04-08 14:36:30 +00:00
|
|
|
#ifdef MOZ_WEBM
|
2014-08-13 18:45:37 +00:00
|
|
|
RegisterStrongMemoryReporter(new NesteggReporter());
|
2014-04-08 14:36:30 +00:00
|
|
|
#endif
|
2013-07-20 03:14:34 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
mozilla::Telemetry::Init();
|
2012-01-10 20:29:58 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
mozilla::HangMonitor::Startup();
|
|
|
|
mozilla::BackgroundHangMonitor::Startup();
|
2012-08-31 19:20:20 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
const MessageLoop* const loop = MessageLoop::current();
|
|
|
|
sMainHangMonitor = new mozilla::BackgroundHangMonitor(
|
|
|
|
loop->thread_name().c_str(),
|
|
|
|
loop->transient_hang_timeout(),
|
|
|
|
loop->permanent_hang_timeout());
|
2014-01-14 16:33:31 +00:00
|
|
|
|
2013-03-28 17:38:05 +00:00
|
|
|
#ifdef MOZ_VISUAL_EVENT_TRACER
|
2014-08-13 18:45:37 +00:00
|
|
|
mozilla::eventtracer::Init();
|
2013-03-28 17:38:05 +00:00
|
|
|
#endif
|
2012-06-12 17:06:21 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
return NS_OK;
|
1999-05-18 21:43:13 +00:00
|
|
|
}
|
|
|
|
|
2002-08-12 22:09:25 +00:00
|
|
|
|
1999-07-31 00:07:31 +00:00
|
|
|
//
|
|
|
|
// NS_ShutdownXPCOM()
|
|
|
|
//
|
|
|
|
// The shutdown sequence for xpcom would be
|
|
|
|
//
|
2005-11-30 18:51:27 +00:00
|
|
|
// - Notify "xpcom-shutdown" for modules to release primary (root) references
|
2006-03-03 13:48:25 +00:00
|
|
|
// - Shutdown XPCOM timers
|
2005-11-30 18:51:27 +00:00
|
|
|
// - Notify "xpcom-shutdown-threads" for thread joins
|
2006-01-17 15:41:40 +00:00
|
|
|
// - Shutdown the event queues
|
1999-07-31 00:07:31 +00:00
|
|
|
// - Release the Global Service Manager
|
|
|
|
// - Release all service instances held by the global service manager
|
|
|
|
// - Release the Global Service Manager itself
|
|
|
|
// - Release the Component Manager
|
|
|
|
// - Release all factories cached by the Component Manager
|
2005-11-30 18:51:27 +00:00
|
|
|
// - Notify module loaders to shut down
|
1999-07-31 00:07:31 +00:00
|
|
|
// - Unload Libraries
|
2000-09-13 23:57:52 +00:00
|
|
|
// - Release Contractid Cache held by Component Manager
|
1999-07-31 00:07:31 +00:00
|
|
|
// - Release dll abstraction held by Component Manager
|
|
|
|
// - Release the Registry held by Component Manager
|
|
|
|
// - Finally, release the component manager itself
|
|
|
|
//
|
2005-11-08 18:17:49 +00:00
|
|
|
EXPORT_XPCOM_API(nsresult)
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_ShutdownXPCOM(nsIServiceManager* aServMgr)
|
2009-06-16 19:36:44 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
return mozilla::ShutdownXPCOM(aServMgr);
|
2009-06-16 19:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-02-11 06:35:32 +00:00
|
|
|
void
|
|
|
|
SetICUMemoryFunctions()
|
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
static bool sICUReporterInitialized = false;
|
|
|
|
if (!sICUReporterInitialized) {
|
|
|
|
if (!JS_SetICUMemoryFunctions(ICUReporter::Alloc, ICUReporter::Realloc,
|
|
|
|
ICUReporter::Free)) {
|
|
|
|
NS_RUNTIMEABORT("JS_SetICUMemoryFunctions failed.");
|
2014-02-11 06:35:32 +00:00
|
|
|
}
|
2014-08-13 18:45:37 +00:00
|
|
|
sICUReporterInitialized = true;
|
|
|
|
}
|
2014-02-11 06:35:32 +00:00
|
|
|
}
|
|
|
|
|
2009-06-16 19:36:44 +00:00
|
|
|
nsresult
|
2014-08-13 18:45:37 +00:00
|
|
|
ShutdownXPCOM(nsIServiceManager* aServMgr)
|
1999-07-28 07:57:39 +00:00
|
|
|
{
|
2014-08-13 18:45:37 +00:00
|
|
|
// Make sure the hang monitor is enabled for shutdown.
|
|
|
|
HangMonitor::NotifyActivity();
|
|
|
|
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NS_RUNTIMEABORT("Shutdown on wrong thread");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> moduleLoaders;
|
2011-10-12 17:52:26 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Notify observers of xpcom shutting down
|
|
|
|
{
|
|
|
|
// Block it so that the COMPtr will get deleted before we hit
|
|
|
|
// servicemanager shutdown
|
|
|
|
|
|
|
|
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
|
|
|
if (NS_WARN_IF(!thread)) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2013-11-19 21:27:37 +00:00
|
|
|
}
|
2005-11-30 18:51:27 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
nsRefPtr<nsObserverService> observerService;
|
|
|
|
CallGetService("@mozilla.org/observer-service;1",
|
2014-08-25 19:17:15 +00:00
|
|
|
(nsObserverService**)getter_AddRefs(observerService));
|
2014-08-13 18:45:37 +00:00
|
|
|
|
|
|
|
if (observerService) {
|
|
|
|
observerService->NotifyObservers(nullptr,
|
|
|
|
NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID,
|
|
|
|
nullptr);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIServiceManager> mgr;
|
|
|
|
rv = NS_GetServiceManager(getter_AddRefs(mgr));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
observerService->NotifyObservers(mgr, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
|
|
|
nullptr);
|
|
|
|
}
|
2005-11-23 20:21:46 +00:00
|
|
|
}
|
2005-11-30 18:51:27 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// This must happen after the shutdown of media and widgets, which
|
|
|
|
// are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification.
|
|
|
|
NS_ProcessPendingEvents(thread);
|
|
|
|
gfxPlatform::ShutdownLayersIPC();
|
2012-01-26 20:54:03 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
mozilla::scache::StartupCache::DeleteSingleton();
|
|
|
|
if (observerService)
|
|
|
|
observerService->NotifyObservers(nullptr,
|
|
|
|
NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID,
|
|
|
|
nullptr);
|
2000-01-10 21:26:56 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
gXPCOMThreadsShutDown = true;
|
|
|
|
NS_ProcessPendingEvents(thread);
|
|
|
|
|
|
|
|
// Shutdown the timer thread and all timers that might still be alive before
|
|
|
|
// shutting down the component manager
|
|
|
|
nsTimerImpl::Shutdown();
|
1999-12-08 02:03:25 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_ProcessPendingEvents(thread);
|
|
|
|
|
|
|
|
// Shutdown all remaining threads. This method does not return until
|
|
|
|
// all threads created using the thread manager (with the exception of
|
|
|
|
// the main thread) have exited.
|
|
|
|
nsThreadManager::get()->Shutdown();
|
|
|
|
|
|
|
|
NS_ProcessPendingEvents(thread);
|
|
|
|
|
|
|
|
HangMonitor::NotifyActivity();
|
|
|
|
|
|
|
|
// Late-write checks needs to find the profile directory, so it has to
|
|
|
|
// be initialized before mozilla::services::Shutdown or (because of
|
|
|
|
// xpcshell tests replacing the service) modules being unloaded.
|
|
|
|
mozilla::InitLateWriteChecks();
|
|
|
|
|
|
|
|
// We save the "xpcom-shutdown-loaders" observers to notify after
|
|
|
|
// the observerservice is gone.
|
|
|
|
if (observerService) {
|
|
|
|
observerService->EnumerateObservers(NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID,
|
|
|
|
getter_AddRefs(moduleLoaders));
|
|
|
|
|
|
|
|
observerService->Shutdown();
|
2005-12-13 17:55:43 +00:00
|
|
|
}
|
2014-08-13 18:45:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Free ClearOnShutdown()'ed smart pointers. This needs to happen *after*
|
|
|
|
// we've finished notifying observers of XPCOM shutdown, because shutdown
|
|
|
|
// observers themselves might call ClearOnShutdown().
|
|
|
|
mozilla::KillClearOnShutdown();
|
2005-12-13 17:55:43 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// XPCOM is officially in shutdown mode NOW
|
|
|
|
// Set this only after the observers have been notified as this
|
|
|
|
// will cause servicemanager to become inaccessible.
|
|
|
|
mozilla::services::Shutdown();
|
|
|
|
|
|
|
|
#ifdef DEBUG_dougt
|
|
|
|
fprintf(stderr, "* * * * XPCOM shutdown. Access will be denied * * * * \n");
|
|
|
|
#endif
|
|
|
|
// We may have AddRef'd for the caller of NS_InitXPCOM, so release it
|
|
|
|
// here again:
|
|
|
|
NS_IF_RELEASE(aServMgr);
|
|
|
|
|
|
|
|
// Shutdown global servicemanager
|
|
|
|
if (nsComponentManagerImpl::gComponentManager) {
|
|
|
|
nsComponentManagerImpl::gComponentManager->FreeServices();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Release the directory service
|
|
|
|
NS_IF_RELEASE(nsDirectoryService::gService);
|
|
|
|
|
|
|
|
NS_Free(gGREPath);
|
|
|
|
gGREPath = nullptr;
|
|
|
|
|
|
|
|
if (moduleLoaders) {
|
|
|
|
bool more;
|
|
|
|
nsCOMPtr<nsISupports> el;
|
|
|
|
while (NS_SUCCEEDED(moduleLoaders->HasMoreElements(&more)) && more) {
|
|
|
|
moduleLoaders->GetNext(getter_AddRefs(el));
|
|
|
|
|
|
|
|
// Don't worry about weak-reference observers here: there is
|
|
|
|
// no reason for weak-ref observers to register for
|
|
|
|
// xpcom-shutdown-loaders
|
|
|
|
|
|
|
|
// FIXME: This can cause harmless writes from sqlite committing
|
|
|
|
// log files. We have to ignore them before we can move
|
|
|
|
// the mozilla::PoisonWrite call before this point. See bug
|
|
|
|
// 834945 for the details.
|
|
|
|
nsCOMPtr<nsIObserver> obs(do_QueryInterface(el));
|
|
|
|
if (obs) {
|
|
|
|
obs->Observe(nullptr, NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, nullptr);
|
|
|
|
}
|
2005-11-30 18:51:27 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
moduleLoaders = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCycleCollector_shutdown();
|
2013-06-25 15:42:39 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
layers::AsyncTransactionTrackersHolder::Finalize();
|
2014-05-24 16:14:45 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
PROFILER_MARKER("Shutdown xpcom");
|
|
|
|
// If we are doing any shutdown checks, poison writes.
|
|
|
|
if (gShutdownChecks != SCM_NOTHING) {
|
2013-11-05 12:45:20 +00:00
|
|
|
#ifdef XP_MACOSX
|
2014-08-13 18:45:37 +00:00
|
|
|
mozilla::OnlyReportDirtyWrites();
|
2013-11-05 12:45:20 +00:00
|
|
|
#endif /* XP_MACOSX */
|
2014-08-13 18:45:37 +00:00
|
|
|
mozilla::BeginLateWriteChecks();
|
|
|
|
}
|
2013-03-06 21:04:58 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Shutdown nsLocalFile string conversion
|
|
|
|
NS_ShutdownLocalFile();
|
2002-06-10 19:44:07 +00:00
|
|
|
#ifdef XP_UNIX
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_ShutdownNativeCharsetUtils();
|
2002-06-10 19:44:07 +00:00
|
|
|
#endif
|
2000-12-09 04:11:05 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Shutdown xpcom. This will release all loaders and cause others holding
|
|
|
|
// a refcount to the component manager to release it.
|
|
|
|
if (nsComponentManagerImpl::gComponentManager) {
|
|
|
|
rv = (nsComponentManagerImpl::gComponentManager)->Shutdown();
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed.");
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Component Manager was never created ...");
|
|
|
|
}
|
2013-07-20 03:14:34 +00:00
|
|
|
|
2014-02-20 13:43:55 +00:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2014-08-13 18:45:37 +00:00
|
|
|
// In optimized builds we don't do shutdown collections by default, so
|
|
|
|
// uncollected (garbage) objects may keep the nsXPConnect singleton alive,
|
|
|
|
// and its XPCJSRuntime along with it. However, we still destroy various
|
|
|
|
// bits of state in JS_ShutDown(), so we need to make sure the profiler
|
|
|
|
// can't access them when it shuts down. This call nulls out the
|
|
|
|
// JS pseudo-stack's internal reference to the main thread JSRuntime,
|
|
|
|
// duplicating the call in XPCJSRuntime::~XPCJSRuntime() in case that
|
|
|
|
// never fired.
|
|
|
|
if (PseudoStack* stack = mozilla_get_pseudo_stack()) {
|
|
|
|
stack->sampleRuntime(nullptr);
|
|
|
|
}
|
2014-02-20 13:43:55 +00:00
|
|
|
#endif
|
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Shut down the JS engine.
|
|
|
|
JS_ShutDown();
|
1999-10-07 21:50:20 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Release our own singletons
|
|
|
|
// Do this _after_ shutting down the component manager, because the
|
|
|
|
// JS component loader will use XPConnect to call nsIModule::canUnload,
|
|
|
|
// and that will spin up the InterfaceInfoManager again -- bad mojo
|
|
|
|
XPTInterfaceInfoManager::FreeInterfaceInfoManager();
|
1999-10-05 00:07:39 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
// Finally, release the component manager last because it unloads the
|
|
|
|
// libraries:
|
|
|
|
if (nsComponentManagerImpl::gComponentManager) {
|
|
|
|
nsrefcnt cnt;
|
|
|
|
NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt);
|
|
|
|
NS_ASSERTION(cnt == 0, "Component Manager being held past XPCOM shutdown.");
|
|
|
|
}
|
|
|
|
nsComponentManagerImpl::gComponentManager = nullptr;
|
|
|
|
nsCategoryManager::Destroy();
|
2003-08-01 14:40:33 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_PurgeAtomTable();
|
2014-08-08 14:04:45 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_IF_RELEASE(gDebug);
|
2014-08-08 14:04:45 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
delete sIOThread;
|
|
|
|
sIOThread = nullptr;
|
|
|
|
|
|
|
|
delete sMessageLoop;
|
|
|
|
sMessageLoop = nullptr;
|
|
|
|
|
|
|
|
if (sCommandLineWasInitialized) {
|
|
|
|
CommandLine::Terminate();
|
|
|
|
sCommandLineWasInitialized = false;
|
|
|
|
}
|
2014-08-08 14:04:45 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
delete sExitManager;
|
|
|
|
sExitManager = nullptr;
|
2009-07-29 21:11:42 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
Omnijar::CleanUp();
|
2011-10-12 17:52:26 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
HangMonitor::Shutdown();
|
2014-01-14 16:33:31 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
delete sMainHangMonitor;
|
|
|
|
sMainHangMonitor = nullptr;
|
2014-08-08 14:04:45 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
BackgroundHangMonitor::Shutdown();
|
2010-08-10 22:08:06 +00:00
|
|
|
|
2013-03-28 17:38:05 +00:00
|
|
|
#ifdef MOZ_VISUAL_EVENT_TRACER
|
2014-08-13 18:45:37 +00:00
|
|
|
eventtracer::Shutdown();
|
2013-03-28 17:38:05 +00:00
|
|
|
#endif
|
2012-06-12 17:06:21 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
profiler_shutdown();
|
2013-04-18 15:34:49 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
NS_LogTerm();
|
2010-03-04 19:50:28 +00:00
|
|
|
|
2014-08-13 18:45:37 +00:00
|
|
|
return NS_OK;
|
1999-07-28 07:57:39 +00:00
|
|
|
}
|
2009-06-16 19:36:44 +00:00
|
|
|
|
|
|
|
} // namespace mozilla
|