2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2006-05-10 21:30:15 +04:00
|
|
|
/* vim:set ts=4 sw=4 sts=4 ci et: */
|
2001-09-29 00:14:13 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:21:17 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2002-01-28 02:56:02 +03:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2005-07-21 17:33:43 +04:00
|
|
|
* Benjamin Smedberg <benjamin@smedbergs.us>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:21:17 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:21:17 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:21:17 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2009-10-22 03:01:16 +04:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2009-05-18 22:15:05 +04:00
|
|
|
#include "mozilla/XPCOM.h"
|
2009-08-29 03:16:19 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2009-05-18 22:15:05 +04:00
|
|
|
|
2001-12-07 22:54:16 +03:00
|
|
|
#include "nsXPCOMPrivate.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsXPCOMCIDInternal.h"
|
2009-05-18 22:15:05 +04:00
|
|
|
|
2005-09-27 23:25:39 +04:00
|
|
|
#include "nsStaticComponents.h"
|
2002-07-02 00:37:17 +04:00
|
|
|
#include "prlink.h"
|
2009-05-18 22:15:05 +04:00
|
|
|
|
2001-03-03 04:24:36 +03:00
|
|
|
#include "nsObserverList.h"
|
2001-10-23 02:01:27 +04:00
|
|
|
#include "nsObserverService.h"
|
1999-05-19 01:43:13 +04:00
|
|
|
#include "nsProperties.h"
|
2000-01-05 12:29:25 +03:00
|
|
|
#include "nsPersistentProperties.h"
|
1999-12-04 23:31:38 +03:00
|
|
|
#include "nsScriptableInputStream.h"
|
2003-03-14 00:23:18 +03:00
|
|
|
#include "nsBinaryStream.h"
|
2004-03-02 04:11:06 +03:00
|
|
|
#include "nsStorageStream.h"
|
2005-07-19 03:39:56 +04:00
|
|
|
#include "nsPipe.h"
|
2011-06-08 22:08:31 +04:00
|
|
|
#include "nsScriptableBase64Encoder.h"
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
#include "nsMemoryImpl.h"
|
2003-07-08 02:11:36 +04:00
|
|
|
#include "nsDebugImpl.h"
|
2003-08-05 09:29:10 +04:00
|
|
|
#include "nsTraceRefcntImpl.h"
|
2000-07-22 09:48:04 +04:00
|
|
|
#include "nsErrorService.h"
|
1999-05-19 01:43:13 +04:00
|
|
|
#include "nsByteBuffer.h"
|
2001-12-07 22:54:16 +03:00
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
#include "nsSupportsArray.h"
|
2002-10-07 23:03:41 +04:00
|
|
|
#include "nsArray.h"
|
2005-10-04 21:19:14 +04:00
|
|
|
#include "nsINIParserImpl.h"
|
1999-08-04 11:08:58 +04:00
|
|
|
#include "nsSupportsPrimitives.h"
|
2000-04-18 06:34:54 +04:00
|
|
|
#include "nsConsoleService.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
#include "nsExceptionService.h"
|
1999-05-19 01:43:13 +04:00
|
|
|
|
|
|
|
#include "nsComponentManager.h"
|
2002-09-24 01:46:25 +04:00
|
|
|
#include "nsCategoryManagerUtils.h"
|
1999-05-19 01:43:13 +04:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsThreadManager.h"
|
|
|
|
#include "nsThreadPool.h"
|
1999-05-19 01:43:13 +04:00
|
|
|
|
1999-10-05 04:07:39 +04:00
|
|
|
#include "xptinfo.h"
|
2000-02-15 09:45:30 +03:00
|
|
|
#include "nsIInterfaceInfoManager.h"
|
2005-11-08 21:17:49 +03:00
|
|
|
#include "xptiprivate.h"
|
1999-05-28 05:14:59 +04:00
|
|
|
|
2001-12-16 09:13:17 +03:00
|
|
|
#include "nsTimerImpl.h"
|
|
|
|
#include "TimerThread.h"
|
|
|
|
|
1999-10-02 03:30:06 +04:00
|
|
|
#include "nsThread.h"
|
2001-01-23 00:52:01 +03:00
|
|
|
#include "nsProcess.h"
|
2004-01-23 13:23:12 +03:00
|
|
|
#include "nsEnvironment.h"
|
2005-07-23 18:05:25 +04:00
|
|
|
#include "nsVersionComparatorImpl.h"
|
1999-10-02 03:30:06 +04:00
|
|
|
|
2000-01-25 00:28:28 +03:00
|
|
|
#include "nsILocalFile.h"
|
|
|
|
#include "nsLocalFile.h"
|
2002-10-07 07:49:32 +04:00
|
|
|
#if defined(XP_UNIX) || defined(XP_OS2)
|
2002-06-10 22:50:11 +04:00
|
|
|
#include "nsNativeCharsetUtils.h"
|
2002-06-10 23:47:22 +04:00
|
|
|
#endif
|
2000-01-25 00:28:28 +03:00
|
|
|
#include "nsDirectoryService.h"
|
2000-08-12 00:31:57 +04:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2002-07-18 09:09:10 +04:00
|
|
|
#include "nsCategoryManager.h"
|
2000-02-06 05:02:24 +03:00
|
|
|
#include "nsICategoryManager.h"
|
2002-02-16 04:19:24 +03:00
|
|
|
#include "nsMultiplexInputStream.h"
|
1999-10-26 02:48:44 +04:00
|
|
|
|
2006-01-02 05:30:32 +03:00
|
|
|
#include "nsStringStream.h"
|
2010-06-10 22:11:11 +04:00
|
|
|
extern nsresult nsStringInputStreamConstructor(nsISupports *, REFNSIID, void **);
|
2006-01-02 05:30:32 +03:00
|
|
|
|
2000-03-31 13:50:00 +04:00
|
|
|
#include "nsAtomService.h"
|
2001-10-21 03:19:07 +04:00
|
|
|
#include "nsAtomTable.h"
|
2000-08-04 10:59:18 +04:00
|
|
|
#include "nsTraceRefcnt.h"
|
2000-03-31 13:50:00 +04:00
|
|
|
|
2004-11-25 02:21:14 +03:00
|
|
|
#include "nsHashPropertyBag.h"
|
|
|
|
|
2006-07-21 20:28:51 +04:00
|
|
|
#include "nsUnicharInputStream.h"
|
2001-11-01 02:35:07 +03:00
|
|
|
#include "nsVariant.h"
|
|
|
|
|
2005-11-22 00:01:45 +03:00
|
|
|
#include "nsUUIDGenerator.h"
|
|
|
|
|
2009-05-07 23:21:54 +04:00
|
|
|
#include "nsIOUtil.h"
|
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
#include "SpecialSystemDirectory.h"
|
2002-09-27 17:07:01 +04:00
|
|
|
|
2008-10-09 07:51:54 +04:00
|
|
|
#if defined(XP_WIN)
|
2005-05-17 01:23:09 +04:00
|
|
|
#include "nsWindowsRegKey.h"
|
|
|
|
#endif
|
|
|
|
|
2010-04-27 16:57:34 +04:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2006-02-19 00:09:59 +03:00
|
|
|
#include "nsMacUtilsImpl.h"
|
2006-02-17 19:19:53 +03:00
|
|
|
#endif
|
|
|
|
|
2006-07-06 10:32:03 +04:00
|
|
|
#include "nsSystemInfo.h"
|
2008-03-06 04:28:25 +03:00
|
|
|
#include "nsMemoryReporterManager.h"
|
2006-07-06 10:32:03 +04:00
|
|
|
|
2004-06-15 20:38:43 +04:00
|
|
|
#include <locale.h>
|
2010-04-02 22:38:25 +04:00
|
|
|
#include "mozilla/Services.h"
|
2010-05-20 03:22:19 +04:00
|
|
|
#include "mozilla/FunctionTimer.h"
|
2010-08-11 02:08:06 +04:00
|
|
|
#include "mozilla/Omnijar.h"
|
2011-10-12 21:52:26 +04:00
|
|
|
#include "mozilla/HangMonitor.h"
|
2012-01-11 00:29:58 +04:00
|
|
|
#include "mozilla/Telemetry.h"
|
2004-06-15 20:38:43 +04:00
|
|
|
|
2010-06-12 00:13:26 +04:00
|
|
|
#include "nsChromeRegistry.h"
|
|
|
|
#include "nsChromeProtocolHandler.h"
|
|
|
|
|
2010-08-12 23:37:44 +04:00
|
|
|
#include "mozilla/scache/StartupCache.h"
|
|
|
|
|
2009-07-30 01:11:42 +04:00
|
|
|
#include "base/at_exit.h"
|
|
|
|
#include "base/command_line.h"
|
|
|
|
#include "base/message_loop.h"
|
|
|
|
|
2010-02-04 01:17:09 +03:00
|
|
|
#include "mozilla/ipc/BrowserProcessSubThread.h"
|
2011-08-06 02:22:11 +04:00
|
|
|
#include "mozilla/MapsMemoryReporter.h"
|
2011-12-15 23:48:38 +04:00
|
|
|
#include "mozilla/AvailableMemoryTracker.h"
|
2012-01-27 00:54:03 +04:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2009-08-28 23:46:21 +04:00
|
|
|
|
2009-07-30 01:11:42 +04:00
|
|
|
using base::AtExitManager;
|
2009-08-28 23:46:21 +04:00
|
|
|
using mozilla::ipc::BrowserProcessSubThread;
|
2009-07-30 01:11:42 +04:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
static AtExitManager* sExitManager;
|
|
|
|
static MessageLoop* sMessageLoop;
|
|
|
|
static bool sCommandLineWasInitialized;
|
2009-08-28 23:46:21 +04:00
|
|
|
static BrowserProcessSubThread* sIOThread;
|
2009-07-30 01:11:42 +04:00
|
|
|
|
|
|
|
} /* anonymous namespace */
|
|
|
|
|
2002-06-15 01:33:05 +04: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-29 01:17:58 +03:00
|
|
|
extern nsresult NS_RegistryGetFactory(nsIFactory** aFactory);
|
2002-07-18 18:38:07 +04:00
|
|
|
extern nsresult NS_CategoryManagerGetFactory( nsIFactory** );
|
2002-06-15 01:33:05 +04:00
|
|
|
|
2010-10-16 23:58:20 +04:00
|
|
|
#ifdef XP_WIN
|
2010-11-08 09:43:25 +03:00
|
|
|
extern nsresult ScheduleMediaCacheRemover();
|
2010-10-16 23:58:20 +04:00
|
|
|
#endif
|
|
|
|
|
2003-09-08 04:31:50 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsProcess)
|
2001-01-23 00:52:01 +03:00
|
|
|
|
1999-08-04 11:08:58 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsIDImpl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsStringImpl)
|
2002-08-06 05:32:51 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCStringImpl)
|
1999-08-04 11:08:58 +04: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 13:42:12 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsFloatImpl)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsDoubleImpl)
|
1999-08-20 07:14:46 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsVoidImpl)
|
2001-04-11 04:10:39 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsInterfacePointerImpl)
|
1999-08-04 11:08:58 +04:00
|
|
|
|
2005-03-02 19:37:53 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsConsoleService, Init)
|
2003-09-08 04:31:50 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAtomService)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExceptionService)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerImpl)
|
2003-03-14 00:23:18 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryOutputStream)
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryInputStream)
|
2004-03-02 04:11:06 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsStorageStream)
|
2005-07-23 18:05:25 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVersionComparatorImpl)
|
2011-06-08 22:08:31 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableBase64Encoder)
|
2002-01-28 02:56:02 +03:00
|
|
|
|
2003-09-08 04:31:50 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariant)
|
2001-11-01 02:35:07 +03:00
|
|
|
|
2005-03-23 20:13:41 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHashPropertyBag, Init)
|
2004-11-25 02:21:14 +03:00
|
|
|
|
2005-09-28 17:13:27 +04:00
|
|
|
NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT(nsProperties, Init)
|
|
|
|
|
2006-05-15 02:41:47 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUUIDGenerator, Init)
|
2005-11-22 00:01:45 +03:00
|
|
|
|
2010-04-27 16:57:34 +04:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2006-02-19 00:09:59 +03:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl)
|
2006-02-17 19:19:53 +03:00
|
|
|
#endif
|
|
|
|
|
2006-07-06 10:32:03 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init)
|
|
|
|
|
2009-10-03 11:21:34 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMemoryReporterManager, Init)
|
2008-03-06 04:28:25 +03:00
|
|
|
|
2009-05-07 23:21:54 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIOUtil)
|
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
static nsresult
|
2006-05-10 21:30:15 +04:00
|
|
|
nsThreadManagerGetSingleton(nsISupports* outer,
|
|
|
|
const nsIID& aIID,
|
|
|
|
void* *aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aInstancePtr, "null outptr");
|
|
|
|
NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
|
|
|
|
|
|
|
|
return nsThreadManager::get()->QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThreadPool)
|
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
static nsresult
|
2002-01-28 02:56:02 +03:00
|
|
|
nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* outer,
|
|
|
|
const nsIID& aIID,
|
2001-11-27 01:31:39 +03:00
|
|
|
void* *aInstancePtr)
|
|
|
|
{
|
2005-11-08 21:17:49 +03:00
|
|
|
NS_ASSERTION(aInstancePtr, "null outptr");
|
2001-11-27 01:31:39 +03:00
|
|
|
NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
|
2002-01-28 02:56:02 +03:00
|
|
|
|
2005-11-08 21:17:49 +03:00
|
|
|
nsCOMPtr<nsIInterfaceInfoManager> iim
|
2010-06-10 20:51:29 +04:00
|
|
|
(xptiInterfaceInfoManager::GetSingleton());
|
2005-11-08 21:17:49 +03:00
|
|
|
if (!iim)
|
2001-11-27 01:31:39 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return iim->QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-10-16 07:35:52 +04:00
|
|
|
nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = NULL;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool gXPCOMShuttingDown = false;
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
|
|
|
static NS_DEFINE_CID(kINIParserFactoryCID, NS_INIPARSERFACTORY_CID);
|
|
|
|
static NS_DEFINE_CID(kSimpleUnicharStreamFactoryCID, NS_SIMPLE_UNICHAR_STREAM_FACTORY_CID);
|
2001-03-12 23:43:02 +03:00
|
|
|
|
2010-06-12 00:13:26 +04:00
|
|
|
NS_DEFINE_NAMED_CID(NS_CHROMEREGISTRY_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_CHROMEPROTOCOLHANDLER_CID);
|
|
|
|
|
2010-07-01 19:55:57 +04:00
|
|
|
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsChromeRegistry,
|
|
|
|
nsChromeRegistry::GetSingleton)
|
2010-06-12 00:13:26 +04:00
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeProtocolHandler)
|
|
|
|
|
2001-03-12 23:43:02 +03:00
|
|
|
#define NS_PERSISTENTPROPERTIES_CID NS_IPERSISTENTPROPERTIES_CID /* sigh */
|
2002-07-02 03:36:03 +04:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
static already_AddRefed<nsIFactory>
|
|
|
|
CreateINIParserFactory(const mozilla::Module& module,
|
|
|
|
const mozilla::Module::CIDEntry& entry)
|
|
|
|
{
|
|
|
|
nsIFactory* f = new nsINIParserFactory();
|
|
|
|
f->AddRef();
|
|
|
|
return f;
|
|
|
|
}
|
2005-11-22 00:01:45 +03:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
static already_AddRefed<nsIFactory>
|
|
|
|
CreateUnicharStreamFactory(const mozilla::Module& module,
|
|
|
|
const mozilla::Module::CIDEntry& entry)
|
|
|
|
{
|
|
|
|
return nsSimpleUnicharStreamFactory::GetInstance();
|
|
|
|
}
|
2006-02-17 19:19:53 +03:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
#define COMPONENT(NAME, Ctor) static NS_DEFINE_CID(kNS_##NAME##_CID, NS_##NAME##_CID);
|
|
|
|
#include "XPCOMModule.inc"
|
|
|
|
#undef COMPONENT
|
2006-07-06 10:32:03 +04:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
#define COMPONENT(NAME, Ctor) { &kNS_##NAME##_CID, false, NULL, Ctor },
|
|
|
|
const mozilla::Module::CIDEntry kXPCOMCIDEntries[] = {
|
|
|
|
{ &kComponentManagerCID, true, NULL, nsComponentManagerImpl::Create },
|
|
|
|
{ &kINIParserFactoryCID, false, CreateINIParserFactory },
|
|
|
|
{ &kSimpleUnicharStreamFactoryCID, false, CreateUnicharStreamFactory },
|
|
|
|
#include "XPCOMModule.inc"
|
2010-06-12 00:13:26 +04:00
|
|
|
{ &kNS_CHROMEREGISTRY_CID, false, NULL, nsChromeRegistryConstructor },
|
|
|
|
{ &kNS_CHROMEPROTOCOLHANDLER_CID, false, NULL, nsChromeProtocolHandlerConstructor },
|
2010-06-10 22:11:11 +04:00
|
|
|
{ NULL }
|
2001-03-12 23:43:02 +03:00
|
|
|
};
|
2010-06-10 22:11:11 +04:00
|
|
|
#undef COMPONENT
|
2001-03-12 23:43:02 +03:00
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
#define COMPONENT(NAME, Ctor) { NS_##NAME##_CONTRACTID, &kNS_##NAME##_CID },
|
|
|
|
const mozilla::Module::ContractIDEntry kXPCOMContracts[] = {
|
|
|
|
#include "XPCOMModule.inc"
|
2010-06-12 00:13:26 +04:00
|
|
|
{ NS_CHROMEREGISTRY_CONTRACTID, &kNS_CHROMEREGISTRY_CID },
|
|
|
|
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "chrome", &kNS_CHROMEPROTOCOLHANDLER_CID },
|
2010-06-26 06:17:31 +04:00
|
|
|
{ NS_INIPARSERFACTORY_CONTRACTID, &kINIParserFactoryCID },
|
2010-06-10 22:11:11 +04:00
|
|
|
{ NULL }
|
|
|
|
};
|
2001-03-12 23:43:02 +03:00
|
|
|
#undef COMPONENT
|
|
|
|
|
2010-06-10 22:11:11 +04:00
|
|
|
const mozilla::Module kXPCOMModule = { mozilla::Module::kVersion, kXPCOMCIDEntries, kXPCOMContracts };
|
2000-08-17 02:40:27 +04:00
|
|
|
|
2003-07-08 02:11:36 +04:00
|
|
|
// gDebug will be freed during shutdown.
|
|
|
|
static nsIDebug* gDebug = nsnull;
|
2005-11-08 21:17:49 +03:00
|
|
|
|
|
|
|
EXPORT_XPCOM_API(nsresult)
|
|
|
|
NS_GetDebug(nsIDebug** result)
|
2003-07-08 02:11:36 +04:00
|
|
|
{
|
2006-02-10 18:00:36 +03:00
|
|
|
return nsDebugImpl::Create(nsnull,
|
|
|
|
NS_GET_IID(nsIDebug),
|
|
|
|
(void**) result);
|
2003-07-08 02:11:36 +04:00
|
|
|
}
|
|
|
|
|
2005-11-08 21:17:49 +03:00
|
|
|
EXPORT_XPCOM_API(nsresult)
|
|
|
|
NS_GetTraceRefcnt(nsITraceRefcnt** result)
|
2003-08-05 09:29:10 +04:00
|
|
|
{
|
2006-02-10 18:00:36 +03:00
|
|
|
return nsTraceRefcntImpl::Create(nsnull,
|
|
|
|
NS_GET_IID(nsITraceRefcnt),
|
|
|
|
(void**) result);
|
2003-08-05 09:29:10 +04:00
|
|
|
}
|
2003-07-08 02:11:36 +04:00
|
|
|
|
2005-11-08 21:17:49 +03:00
|
|
|
EXPORT_XPCOM_API(nsresult)
|
|
|
|
NS_InitXPCOM(nsIServiceManager* *result,
|
2000-08-17 02:40:27 +04:00
|
|
|
nsIFile* binDirectory)
|
|
|
|
{
|
2010-06-10 22:11:11 +04:00
|
|
|
return NS_InitXPCOM2(result, binDirectory, nsnull);
|
2000-08-17 02:40:27 +04:00
|
|
|
}
|
|
|
|
|
2005-11-08 21:17:49 +03:00
|
|
|
EXPORT_XPCOM_API(nsresult)
|
|
|
|
NS_InitXPCOM2(nsIServiceManager* *result,
|
2010-06-10 22:11:11 +04:00
|
|
|
nsIFile* binDirectory,
|
|
|
|
nsIDirectoryServiceProvider* appFileLocationProvider)
|
1999-05-19 01:43:13 +04:00
|
|
|
{
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION;
|
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2002-06-11 23:26:04 +04:00
|
|
|
// We are not shutting down
|
2011-10-17 18:59:28 +04:00
|
|
|
gXPCOMShuttingDown = false;
|
2002-06-11 23:26:04 +04:00
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: log init");
|
|
|
|
|
2010-03-04 22:50:28 +03:00
|
|
|
NS_LogInit();
|
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: IPC init");
|
|
|
|
|
2009-07-30 01:11:42 +04:00
|
|
|
// Set up chromium libs
|
|
|
|
NS_ASSERTION(!sExitManager && !sMessageLoop, "Bad logic!");
|
|
|
|
|
|
|
|
if (!AtExitManager::AlreadyRegistered()) {
|
|
|
|
sExitManager = new AtExitManager();
|
|
|
|
NS_ENSURE_STATE(sExitManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!MessageLoop::current()) {
|
2010-02-04 01:17:09 +03:00
|
|
|
sMessageLoop = new MessageLoopForUI(MessageLoop::TYPE_MOZILLA_UI);
|
2009-07-30 01:11:42 +04:00
|
|
|
NS_ENSURE_STATE(sMessageLoop);
|
|
|
|
}
|
2009-08-28 23:46:21 +04:00
|
|
|
|
2009-08-29 03:16:19 +04:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Default &&
|
|
|
|
!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
|
2009-08-28 23:46:21 +04:00
|
|
|
scoped_ptr<BrowserProcessSubThread> ioThread(
|
|
|
|
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
|
|
|
|
NS_ENSURE_TRUE(ioThread.get(), NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
base::Thread::Options options;
|
|
|
|
options.message_loop_type = MessageLoop::TYPE_IO;
|
|
|
|
NS_ENSURE_TRUE(ioThread->StartWithOptions(options), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
sIOThread = ioThread.release();
|
|
|
|
}
|
2009-07-30 01:11:42 +04:00
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: thread manager init");
|
|
|
|
|
2000-03-06 00:26:01 +03:00
|
|
|
// Establish the main thread here.
|
2006-05-10 21:30:15 +04:00
|
|
|
rv = nsThreadManager::get()->Init();
|
2000-03-06 00:26:01 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-10-30 05:52:55 +04:00
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: timer startup");
|
|
|
|
|
2004-05-11 13:38:50 +04:00
|
|
|
// Set up the timer globals/timer thread
|
|
|
|
rv = nsTimerImpl::Startup();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-05-01 22:59:24 +04:00
|
|
|
#ifndef ANDROID
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: setlocale");
|
|
|
|
|
2004-06-15 20:38:43 +04: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, NULL), "C") == 0)
|
|
|
|
setlocale(LC_ALL, "");
|
2005-01-31 00:33:47 +03:00
|
|
|
#endif
|
2004-06-15 20:38:43 +04:00
|
|
|
|
2002-10-07 07:47:50 +04:00
|
|
|
#if defined(XP_UNIX) || defined(XP_OS2)
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: startup native charset utils");
|
|
|
|
|
2002-06-10 22:50:11 +04:00
|
|
|
NS_StartupNativeCharsetUtils();
|
2002-06-10 23:44:07 +04:00
|
|
|
#endif
|
2010-08-11 02:08:06 +04:00
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: startup local file");
|
|
|
|
|
2000-12-09 07:11:05 +03:00
|
|
|
NS_StartupLocalFile();
|
|
|
|
|
2001-02-19 06:09:57 +03:00
|
|
|
StartupSpecialSystemDirectory();
|
|
|
|
|
2005-06-07 23:35:20 +04:00
|
|
|
rv = nsDirectoryService::RealInit();
|
2001-09-07 01:13:11 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2002-01-28 02:56:02 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool value;
|
2011-07-21 11:57:07 +04:00
|
|
|
|
2006-05-01 07:47:02 +04:00
|
|
|
if (binDirectory)
|
1999-05-19 01:43:13 +04:00
|
|
|
{
|
2006-05-01 07:47:02 +04:00
|
|
|
rv = binDirectory->IsDirectory(&value);
|
2002-09-27 17:07:01 +04:00
|
|
|
|
2006-05-01 07:47:02 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && value) {
|
|
|
|
nsDirectoryService::gService->Set(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, binDirectory);
|
2001-01-19 01:51:57 +03:00
|
|
|
}
|
2006-05-01 07:47:02 +04:00
|
|
|
}
|
2011-07-21 11:57:07 +04:00
|
|
|
|
|
|
|
if (appFileLocationProvider) {
|
|
|
|
rv = nsDirectoryService::gService->RegisterProvider(appFileLocationProvider);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2006-05-01 07:47:02 +04:00
|
|
|
}
|
2002-01-28 02:56:02 +03:00
|
|
|
|
2011-07-21 11:57:07 +04:00
|
|
|
nsCOMPtr<nsIFile> xpcomLib;
|
|
|
|
|
|
|
|
nsDirectoryService::gService->Get(NS_GRE_DIR,
|
|
|
|
NS_GET_IID(nsIFile),
|
|
|
|
getter_AddRefs(xpcomLib));
|
|
|
|
|
2006-05-01 07:47:02 +04:00
|
|
|
if (xpcomLib) {
|
|
|
|
xpcomLib->AppendNative(nsDependentCString(XPCOM_DLL));
|
|
|
|
nsDirectoryService::gService->Set(NS_XPCOM_LIBRARY_FILE, xpcomLib);
|
|
|
|
}
|
|
|
|
|
2010-08-11 02:08:06 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: Omnijar init");
|
|
|
|
|
2011-02-25 14:53:36 +03:00
|
|
|
if (!mozilla::Omnijar::IsInitialized()) {
|
|
|
|
mozilla::Omnijar::Init();
|
2010-08-11 02:08:06 +04:00
|
|
|
}
|
|
|
|
|
2009-09-04 11:23:06 +04:00
|
|
|
if ((sCommandLineWasInitialized = !CommandLine::IsInitialized())) {
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: IPC command line init");
|
|
|
|
|
2009-09-04 11:23:06 +04:00
|
|
|
#ifdef OS_WIN
|
|
|
|
CommandLine::Init(0, nsnull);
|
|
|
|
#else
|
|
|
|
nsCOMPtr<nsIFile> binaryFile;
|
|
|
|
nsDirectoryService::gService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
|
|
|
NS_GET_IID(nsIFile),
|
|
|
|
getter_AddRefs(binaryFile));
|
|
|
|
NS_ENSURE_STATE(binaryFile);
|
|
|
|
|
|
|
|
rv = binaryFile->AppendNative(NS_LITERAL_CSTRING("nonexistent-executable"));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCString binaryPath;
|
|
|
|
rv = binaryFile->GetNativePath(binaryPath);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
static char const *const argv = { strdup(binaryPath.get()) };
|
|
|
|
CommandLine::Init(1, &argv);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-05-01 07:47:02 +04:00
|
|
|
NS_ASSERTION(nsComponentManagerImpl::gComponentManager == NULL, "CompMgr not null at init");
|
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: component manager init");
|
|
|
|
|
2006-05-01 07:47:02 +04:00
|
|
|
// Create the Component/Service Manager
|
2010-06-12 00:13:26 +04:00
|
|
|
nsComponentManagerImpl::gComponentManager = new nsComponentManagerImpl();
|
|
|
|
NS_ADDREF(nsComponentManagerImpl::gComponentManager);
|
2006-05-01 07:47:02 +04:00
|
|
|
|
2010-06-22 20:59:57 +04:00
|
|
|
rv = nsCycleCollector_startup();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2010-06-12 00:13:26 +04:00
|
|
|
rv = nsComponentManagerImpl::gComponentManager->Init();
|
2006-05-01 07:47:02 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
{
|
2010-06-12 00:13:26 +04:00
|
|
|
NS_RELEASE(nsComponentManagerImpl::gComponentManager);
|
2006-05-01 07:47:02 +04:00
|
|
|
return rv;
|
|
|
|
}
|
2002-01-28 02:56:02 +03:00
|
|
|
|
2006-05-01 07:47:02 +04:00
|
|
|
if (result) {
|
2010-06-12 00:13:26 +04:00
|
|
|
NS_ADDREF(*result = nsComponentManagerImpl::gComponentManager);
|
1999-05-19 01:43:13 +04:00
|
|
|
}
|
2000-06-03 13:46:12 +04:00
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: cycle collector startup");
|
|
|
|
|
|
|
|
NS_TIME_FUNCTION_MARK("Next: interface info manager init");
|
|
|
|
|
2010-06-10 20:51:43 +04:00
|
|
|
// The iimanager constructor searches and registers XPT files.
|
2010-06-24 04:30:59 +04:00
|
|
|
// (We trigger the singleton's lazy construction here to make that happen.)
|
|
|
|
(void) xptiInterfaceInfoManager::GetSingleton();
|
2005-12-13 20:55:43 +03:00
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: register category providers");
|
|
|
|
|
2005-06-07 23:35:20 +04:00
|
|
|
// 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();
|
|
|
|
|
2010-08-12 23:37:44 +04:00
|
|
|
mozilla::scache::StartupCache::GetSingleton();
|
2011-12-15 23:48:38 +04:00
|
|
|
mozilla::AvailableMemoryTracker::Init();
|
|
|
|
|
2010-05-20 03:22:19 +04:00
|
|
|
NS_TIME_FUNCTION_MARK("Next: create services from category");
|
|
|
|
|
2002-09-24 01:46:25 +04:00
|
|
|
// Notify observers of xpcom autoregistration start
|
2008-03-08 12:50:29 +03:00
|
|
|
NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_CATEGORY,
|
2002-09-24 01:46:25 +04:00
|
|
|
nsnull,
|
|
|
|
NS_XPCOM_STARTUP_OBSERVER_ID);
|
2010-10-16 23:58:20 +04:00
|
|
|
#ifdef XP_WIN
|
2010-11-08 09:43:25 +03:00
|
|
|
ScheduleMediaCacheRemover();
|
2010-10-16 23:58:20 +04:00
|
|
|
#endif
|
|
|
|
|
2011-08-06 02:22:11 +04:00
|
|
|
mozilla::MapsMemoryReporter::Init();
|
|
|
|
|
2011-10-12 21:52:26 +04:00
|
|
|
mozilla::HangMonitor::Startup();
|
|
|
|
|
2012-01-11 00:29:58 +04:00
|
|
|
mozilla::Telemetry::Init();
|
|
|
|
|
2003-08-16 00:37:32 +04:00
|
|
|
return NS_OK;
|
1999-05-19 01:43:13 +04:00
|
|
|
}
|
|
|
|
|
2002-08-13 02:09:25 +04:00
|
|
|
|
1999-07-31 04:07:31 +04:00
|
|
|
//
|
|
|
|
// NS_ShutdownXPCOM()
|
|
|
|
//
|
|
|
|
// The shutdown sequence for xpcom would be
|
|
|
|
//
|
2005-11-30 21:51:27 +03:00
|
|
|
// - Notify "xpcom-shutdown" for modules to release primary (root) references
|
2006-03-03 16:48:25 +03:00
|
|
|
// - Shutdown XPCOM timers
|
2005-11-30 21:51:27 +03:00
|
|
|
// - Notify "xpcom-shutdown-threads" for thread joins
|
2006-01-17 18:41:40 +03:00
|
|
|
// - Shutdown the event queues
|
1999-07-31 04:07:31 +04: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 21:51:27 +03:00
|
|
|
// - Notify module loaders to shut down
|
1999-07-31 04:07:31 +04:00
|
|
|
// - Unload Libraries
|
2000-09-14 03:57:52 +04:00
|
|
|
// - Release Contractid Cache held by Component Manager
|
1999-07-31 04:07:31 +04:00
|
|
|
// - Release dll abstraction held by Component Manager
|
|
|
|
// - Release the Registry held by Component Manager
|
|
|
|
// - Finally, release the component manager itself
|
|
|
|
//
|
2005-11-08 21:17:49 +03:00
|
|
|
EXPORT_XPCOM_API(nsresult)
|
|
|
|
NS_ShutdownXPCOM(nsIServiceManager* servMgr)
|
2009-06-16 23:36:44 +04:00
|
|
|
{
|
|
|
|
return mozilla::ShutdownXPCOM(servMgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
ShutdownXPCOM(nsIServiceManager* servMgr)
|
1999-07-28 11:57:39 +04:00
|
|
|
{
|
2011-10-12 21:52:26 +04:00
|
|
|
// Make sure the hang monitor is enabled for shutdown.
|
|
|
|
HangMonitor::NotifyActivity();
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_ENSURE_STATE(NS_IsMainThread());
|
2005-11-30 21:51:27 +03:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
nsresult rv;
|
2005-11-30 21:51:27 +03:00
|
|
|
nsCOMPtr<nsISimpleEnumerator> moduleLoaders;
|
2002-04-16 02:26:29 +04:00
|
|
|
|
1999-11-10 02:41:24 +03:00
|
|
|
// Notify observers of xpcom shutting down
|
|
|
|
{
|
|
|
|
// Block it so that the COMPtr will get deleted before we hit
|
|
|
|
// servicemanager shutdown
|
2006-01-17 18:41:40 +03:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
|
|
|
NS_ENSURE_STATE(thread);
|
2006-01-17 18:41:40 +03:00
|
|
|
|
2006-03-21 17:43:56 +03:00
|
|
|
nsRefPtr<nsObserverService> observerService;
|
|
|
|
CallGetService("@mozilla.org/observer-service;1",
|
|
|
|
(nsObserverService**) getter_AddRefs(observerService));
|
2005-11-30 21:51:27 +03:00
|
|
|
|
|
|
|
if (observerService)
|
1999-11-10 02:41:24 +03:00
|
|
|
{
|
2009-11-21 01:25:11 +03:00
|
|
|
(void) observerService->
|
|
|
|
NotifyObservers(nsnull, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID,
|
|
|
|
nsnull);
|
|
|
|
|
2001-10-16 07:35:52 +04:00
|
|
|
nsCOMPtr<nsIServiceManager> mgr;
|
|
|
|
rv = NS_GetServiceManager(getter_AddRefs(mgr));
|
1999-11-10 02:41:24 +03:00
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
{
|
2005-11-30 21:51:27 +03:00
|
|
|
(void) observerService->
|
|
|
|
NotifyObservers(mgr, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
|
|
|
nsnull);
|
1999-11-10 02:41:24 +03:00
|
|
|
}
|
|
|
|
}
|
2005-11-23 17:32:18 +03:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_ProcessPendingEvents(thread);
|
2010-08-12 23:37:44 +04:00
|
|
|
mozilla::scache::StartupCache::DeleteSingleton();
|
2005-11-30 21:51:27 +03:00
|
|
|
if (observerService)
|
|
|
|
(void) observerService->
|
|
|
|
NotifyObservers(nsnull, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID,
|
|
|
|
nsnull);
|
|
|
|
|
2010-11-12 01:52:30 +03:00
|
|
|
nsCycleCollector_shutdownThreads();
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_ProcessPendingEvents(thread);
|
|
|
|
|
|
|
|
// Shutdown the timer thread and all timers that might still be alive before
|
|
|
|
// shutting down the component manager
|
|
|
|
nsTimerImpl::Shutdown();
|
|
|
|
|
|
|
|
NS_ProcessPendingEvents(thread);
|
2005-11-30 21:51:27 +03:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
// 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();
|
2006-01-17 18:41:40 +03:00
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_ProcessPendingEvents(thread);
|
2006-01-17 18:41:40 +03:00
|
|
|
|
2011-10-12 21:52:26 +04:00
|
|
|
HangMonitor::NotifyActivity();
|
|
|
|
|
2005-11-30 21:51:27 +03:00
|
|
|
// We save the "xpcom-shutdown-loaders" observers to notify after
|
|
|
|
// the observerservice is gone.
|
2006-03-21 17:43:56 +03:00
|
|
|
if (observerService) {
|
2005-11-30 21:51:27 +03:00
|
|
|
observerService->
|
|
|
|
EnumerateObservers(NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID,
|
|
|
|
getter_AddRefs(moduleLoaders));
|
2006-03-21 17:43:56 +03:00
|
|
|
|
|
|
|
observerService->Shutdown();
|
|
|
|
}
|
2005-11-23 23:21:46 +03:00
|
|
|
}
|
2005-11-30 21:51:27 +03:00
|
|
|
|
2012-01-27 00:54:03 +04: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();
|
|
|
|
|
2001-10-26 01:03:35 +04: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.
|
2010-04-02 22:38:25 +04:00
|
|
|
mozilla::services::Shutdown();
|
2000-01-11 00:26:56 +03:00
|
|
|
|
2002-05-12 01:15:06 +04:00
|
|
|
#ifdef DEBUG_dougt
|
|
|
|
fprintf(stderr, "* * * * XPCOM shutdown. Access will be denied * * * * \n");
|
|
|
|
#endif
|
1999-09-26 00:11:33 +04:00
|
|
|
// We may have AddRef'd for the caller of NS_InitXPCOM, so release it
|
|
|
|
// here again:
|
1999-09-24 10:26:17 +04:00
|
|
|
NS_IF_RELEASE(servMgr);
|
1999-12-08 05:03:25 +03:00
|
|
|
|
2005-12-13 20:55:43 +03:00
|
|
|
// Shutdown global servicemanager
|
|
|
|
if (nsComponentManagerImpl::gComponentManager) {
|
|
|
|
nsComponentManagerImpl::gComponentManager->FreeServices();
|
|
|
|
}
|
|
|
|
|
2000-02-22 00:52:18 +03:00
|
|
|
// Release the directory service
|
2005-06-07 23:35:20 +04:00
|
|
|
NS_IF_RELEASE(nsDirectoryService::gService);
|
1999-10-30 10:45:45 +04:00
|
|
|
|
2007-01-25 03:24:20 +03:00
|
|
|
nsCycleCollector_shutdown();
|
|
|
|
|
2005-11-30 21:51:27 +03:00
|
|
|
if (moduleLoaders) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool more;
|
2005-11-30 21:51:27 +03:00
|
|
|
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
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserver> obs(do_QueryInterface(el));
|
|
|
|
if (obs)
|
|
|
|
(void) obs->Observe(nsnull,
|
|
|
|
NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID,
|
|
|
|
nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
moduleLoaders = nsnull;
|
|
|
|
}
|
|
|
|
|
2000-12-09 07:11:05 +03:00
|
|
|
// Shutdown nsLocalFile string conversion
|
|
|
|
NS_ShutdownLocalFile();
|
2002-06-10 23:44:07 +04:00
|
|
|
#ifdef XP_UNIX
|
2002-06-10 22:50:11 +04:00
|
|
|
NS_ShutdownNativeCharsetUtils();
|
2002-06-10 23:44:07 +04:00
|
|
|
#endif
|
2000-12-09 07:11:05 +03:00
|
|
|
|
1999-10-22 01:34:39 +04:00
|
|
|
// Shutdown xpcom. This will release all loaders and cause others holding
|
|
|
|
// a refcount to the component manager to release it.
|
2002-09-12 23:35:49 +04:00
|
|
|
if (nsComponentManagerImpl::gComponentManager) {
|
|
|
|
rv = (nsComponentManagerImpl::gComponentManager)->Shutdown();
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed.");
|
|
|
|
} else
|
|
|
|
NS_WARNING("Component Manager was never created ...");
|
1999-10-22 01:34:39 +04:00
|
|
|
|
1999-11-10 03:28:34 +03: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
|
2005-11-08 21:17:49 +03:00
|
|
|
xptiInterfaceInfoManager::FreeInterfaceInfoManager();
|
1999-11-10 03:28:34 +03:00
|
|
|
|
1999-09-21 00:53:49 +04:00
|
|
|
// Finally, release the component manager last because it unloads the
|
|
|
|
// libraries:
|
2002-02-14 06:26:19 +03:00
|
|
|
if (nsComponentManagerImpl::gComponentManager) {
|
|
|
|
nsrefcnt cnt;
|
|
|
|
NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt);
|
2006-03-30 22:40:56 +04:00
|
|
|
NS_ASSERTION(cnt == 0, "Component Manager being held past XPCOM shutdown.");
|
2002-02-14 06:26:19 +03:00
|
|
|
}
|
2001-10-17 03:39:20 +04:00
|
|
|
nsComponentManagerImpl::gComponentManager = nsnull;
|
2010-06-10 22:11:11 +04:00
|
|
|
nsCategoryManager::Destroy();
|
1999-10-08 01:50:20 +04:00
|
|
|
|
2000-07-11 11:31:50 +04:00
|
|
|
NS_PurgeAtomTable();
|
1999-10-05 04:07:39 +04:00
|
|
|
|
2003-08-01 18:40:33 +04:00
|
|
|
NS_IF_RELEASE(gDebug);
|
|
|
|
|
2009-08-28 23:46:21 +04:00
|
|
|
if (sIOThread) {
|
|
|
|
delete sIOThread;
|
|
|
|
sIOThread = nsnull;
|
|
|
|
}
|
2009-07-30 01:11:42 +04:00
|
|
|
if (sMessageLoop) {
|
|
|
|
delete sMessageLoop;
|
|
|
|
sMessageLoop = nsnull;
|
|
|
|
}
|
|
|
|
if (sCommandLineWasInitialized) {
|
|
|
|
CommandLine::Terminate();
|
|
|
|
sCommandLineWasInitialized = false;
|
|
|
|
}
|
|
|
|
if (sExitManager) {
|
|
|
|
delete sExitManager;
|
|
|
|
sExitManager = nsnull;
|
|
|
|
}
|
|
|
|
|
2011-10-12 21:52:26 +04:00
|
|
|
Omnijar::CleanUp();
|
|
|
|
|
|
|
|
HangMonitor::Shutdown();
|
2010-08-11 02:08:06 +04:00
|
|
|
|
2010-03-04 22:50:28 +03:00
|
|
|
NS_LogTerm();
|
|
|
|
|
1999-07-28 11:57:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-06-16 23:36:44 +04:00
|
|
|
|
|
|
|
} // namespace mozilla
|