Commit d1d8cfe0 authored by Kris Maglione's avatar Kris Maglione
Browse files

Bug 1478124: Part 8e - Update XPCOM module to use a static component manifest. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D15043

--HG--
extra : rebase_source : 67200c20fe6db1abaf58b9e5203dce0e665e1117
extra : source : 012fd0107204da802f04b7c133b33a5dd22123a4
parent 3a9e3cc7
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.

Classes = [
    {
        'cid': '{cb6cdb94-e417-4601-b4a5-f991bf41453d}',
        'contract_ids': ['@mozilla.org/xpcom/debug;1'],
        'legacy_constructor': 'nsDebugImpl::Create',
        'headers': ['nsDebugImpl.h'],
        'processes': ProcessSelector.ALLOW_IN_GPU_AND_SOCKET_PROCESS,
    },
    {
        'cid': '{30a04e40-38e7-11d4-8cf5-0060b0fc14a3}',
        'contract_ids': ['@mozilla.org/xpcom/memory-service;1'],
        'legacy_constructor': 'nsMemoryImpl::Create',
        'headers': ['/xpcom/base/nsMemoryImpl.h'],
        'processes': ProcessSelector.ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS,
    },
    {
        'cid': '{67b3ac0c-d806-4d48-939e-6a819e6c248f}',
        'contract_ids': ['@mozilla.org/message-loop;1'],
        'legacy_constructor': 'nsMessageLoopConstructor',
        'headers': ['/xpcom/base/nsMessageLoop.h'],
    },
]
+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':

XPIDL_MODULE = 'xpcom_base'

XPCOM_MANIFESTS += [
    'components.conf',
]

EXPORTS += [
    '!ErrorList.h',
    '!ErrorNamesInternal.h',
+10 −145
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@
 * 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/. */

#include "XPCOMModule.h"

#include "base/basictypes.h"

#include "mozilla/Atomics.h"
@@ -27,22 +29,12 @@
#include "prlink.h"

#include "nsCycleCollector.h"
#include "nsObserverList.h"
#include "nsObserverService.h"
#include "nsScriptableInputStream.h"
#include "nsBinaryStream.h"
#include "nsStorageStream.h"
#include "nsPipe.h"
#include "nsScriptableBase64Encoder.h"

#include "nsMemoryImpl.h"
#include "nsDebugImpl.h"
#include "nsTraceRefcnt.h"
#include "nsSystemInfo.h"

#include "nsArray.h"
#include "nsINIParserImpl.h"
#include "nsSupportsPrimitives.h"
#include "nsConsoleService.h"

#include "nsComponentManager.h"
#include "nsCategoryManagerUtils.h"
@@ -55,51 +47,21 @@
#include "TimerThread.h"

#include "nsThread.h"
#include "nsProcess.h"
#include "nsEnvironment.h"
#include "nsVersionComparatorImpl.h"

#include "nsIFile.h"
#include "nsLocalFile.h"
#if defined(XP_UNIX)
#  include "nsNativeCharsetUtils.h"
#endif
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsCategoryManager.h"
#include "nsICategoryManager.h"
#include "nsMultiplexInputStream.h"

#include "nsStringStream.h"
extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**);

#include "nsAtomTable.h"
#include "nsISupportsImpl.h"

#include "nsHashPropertyBag.h"

#include "nsUnicharInputStream.h"
#include "nsVariant.h"

#include "nsUUIDGenerator.h"

#include "nsIOUtil.h"

#include "SpecialSystemDirectory.h"

#if defined(XP_WIN)
#  include "nsWindowsRegKey.h"
#endif

#ifdef MOZ_WIDGET_COCOA
#  include "nsMacUtilsImpl.h"
#  include "nsMacPreferencesReader.h"
#endif

#include "nsSystemInfo.h"
#include "nsMemoryReporterManager.h"
#include "nsMemoryInfoDumper.h"
#include "nsSecurityConsoleMessage.h"
#include "nsMessageLoop.h"
#include "nss.h"
#include "ssl.h"
@@ -112,8 +74,6 @@ extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**);
#include "mozilla/Telemetry.h"
#include "mozilla/BackgroundHangMonitor.h"

#include "nsChromeRegistry.h"
#include "nsChromeProtocolHandler.h"
#include "mozilla/PoisonIOInterposer.h"
#include "mozilla/LateWriteChecks.h"

@@ -170,55 +130,7 @@ extern nsresult NS_CategoryManagerGetFactory(nsIFactory**);
extern nsresult CreateAnonTempFileRemover();
#endif

NS_GENERIC_FACTORY_CONSTRUCTOR(nsProcess)

NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsID)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsString)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCString)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRBool)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint8)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint16)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint32)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint64)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRTime)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsChar)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt16)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt32)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt64)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsFloat)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsDouble)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsInterfacePointer)

NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsConsoleService, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryOutputStream)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryInputStream)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsStorageStream)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsVersionComparatorImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableBase64Encoder)

NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariantCC)

NS_GENERIC_FACTORY_CONSTRUCTOR(nsHashPropertyBagCC)

NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUUIDGenerator, Init)

#ifdef MOZ_WIDGET_COCOA
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacPreferencesReader)
#endif

NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init)

NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMemoryReporterManager, Init)

NS_GENERIC_FACTORY_CONSTRUCTOR(nsMemoryInfoDumper)

NS_GENERIC_FACTORY_CONSTRUCTOR(nsIOUtil)

NS_GENERIC_FACTORY_CONSTRUCTOR(nsSecurityConsoleMessage)

static nsresult nsThreadManagerGetSingleton(nsISupports* aOuter,
                                            const nsIID& aIID,
nsresult nsThreadManagerGetSingleton(nsISupports* aOuter, const nsIID& aIID,
                                     void** aInstancePtr) {
  NS_ASSERTION(aInstancePtr, "null outptr");
  if (NS_WARN_IF(aOuter)) {
@@ -228,78 +140,31 @@ static nsresult nsThreadManagerGetSingleton(nsISupports* aOuter,
  return nsThreadManager::get().QueryInterface(aIID, aInstancePtr);
}

nsresult nsLocalFileConstructor(nsISupports* aOuter, const nsIID& aIID,
                                void** aInstancePtr) {
  return nsLocalFile::nsLocalFileConstructor(aOuter, aIID, aInstancePtr);
}

nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = nullptr;
bool gXPCOMShuttingDown = false;
bool gXPCOMThreadsShutDown = false;
char16_t* gGREBinPath = nullptr;

static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kINIParserFactoryCID, NS_INIPARSERFACTORY_CID);

NS_DEFINE_NAMED_CID(NS_CHROMEREGISTRY_CID);
NS_DEFINE_NAMED_CID(NS_CHROMEPROTOCOLHANDLER_CID);

NS_DEFINE_NAMED_CID(NS_SECURITY_CONSOLE_MESSAGE_CID);

#ifdef MOZ_WIDGET_COCOA
NS_DEFINE_NAMED_CID(NS_MACPREFERENCESREADER_CID);
#endif

NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsChromeRegistry,
                                         nsChromeRegistry::GetSingleton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeProtocolHandler)

static already_AddRefed<nsIFactory> CreateINIParserFactory(
    const mozilla::Module& aModule, const mozilla::Module::CIDEntry& aEntry) {
  nsCOMPtr<nsIFactory> f = new nsINIParserFactory();
  return f.forget();
}

#define COMPONENT(NAME, Ctor) \
  static NS_DEFINE_CID(kNS_##NAME##_CID, NS_##NAME##_CID);
#define COMPONENT_M(NAME, Ctor, Selector) \
  static NS_DEFINE_CID(kNS_##NAME##_CID, NS_##NAME##_CID);
#include "XPCOMModule.inc"
#undef COMPONENT
#undef COMPONENT_M

#define COMPONENT(NAME, Ctor) {&kNS_##NAME##_CID, false, nullptr, Ctor},
#define COMPONENT_M(NAME, Ctor, Selector) \
  {&kNS_##NAME##_CID, false, nullptr, Ctor, Selector},
const mozilla::Module::CIDEntry kXPCOMCIDEntries[] = {
    {&kComponentManagerCID, true, nullptr, nsComponentManagerImpl::Create,
     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
    {&kINIParserFactoryCID, false, CreateINIParserFactory},
#include "XPCOMModule.inc"
    {&kNS_CHROMEREGISTRY_CID, false, nullptr, nsChromeRegistryConstructor},
    {&kNS_CHROMEPROTOCOLHANDLER_CID, false, nullptr,
     nsChromeProtocolHandlerConstructor},
    {&kNS_SECURITY_CONSOLE_MESSAGE_CID, false, nullptr,
     nsSecurityConsoleMessageConstructor},
#ifdef MOZ_WIDGET_COCOA
    {&kNS_MACPREFERENCESREADER_CID, false, nullptr,
     nsMacPreferencesReaderConstructor},
#endif
    {nullptr}};
#undef COMPONENT
#undef COMPONENT_M

#define COMPONENT(NAME, Ctor) {NS_##NAME##_CONTRACTID, &kNS_##NAME##_CID},
#define COMPONENT_M(NAME, Ctor, Selector) \
  {NS_##NAME##_CONTRACTID, &kNS_##NAME##_CID, Selector},
const mozilla::Module::ContractIDEntry kXPCOMContracts[] = {
#include "XPCOMModule.inc"
    {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},
#ifdef MOZ_WIDGET_COCOA
    {NS_MACPREFERENCESREADER_CONTRACTID, &kNS_MACPREFERENCESREADER_CID},
#endif
    {nullptr}};
#undef COMPONENT
#undef COMPONENT_M

const mozilla::Module kXPCOMModule = {
    mozilla::Module::kVersion,
+23 −0
Original line number Diff line number Diff line
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

#ifndef XPCOMModule_h
#define XPCOMModule_h

#include "nsID.h"

class nsISupports;

nsresult nsThreadManagerGetSingleton(nsISupports* aOuter, const nsIID& aIID,
                                     void** aInstancePtr);

nsresult nsLocalFileConstructor(nsISupports* aOuter, const nsIID& aIID,
                                void** aInstancePtr);

extern nsresult nsStringInputStreamConstructor(nsISupports*, const nsID&,
                                               void**);

#endif  // XPCOMModule_h
+0 −66
Original line number Diff line number Diff line
    COMPONENT_M(MEMORY, nsMemoryImpl::Create, Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS)
    COMPONENT_M(DEBUG,  nsDebugImpl::Create, Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS)

    COMPONENT_M(CATEGORYMANAGER, nsCategoryManager::Create, Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS)

    COMPONENT(SCRIPTABLEINPUTSTREAM, nsScriptableInputStream::Create)
    COMPONENT(BINARYINPUTSTREAM, nsBinaryInputStreamConstructor)
    COMPONENT(BINARYOUTPUTSTREAM, nsBinaryOutputStreamConstructor)
    COMPONENT(STORAGESTREAM, nsStorageStreamConstructor)
    COMPONENT(VERSIONCOMPARATOR, nsVersionComparatorImplConstructor)
    COMPONENT(SCRIPTABLEBASE64ENCODER, nsScriptableBase64EncoderConstructor)
    COMPONENT(PIPE, nsPipeConstructor)

    COMPONENT(ARRAY, nsArrayBase::XPCOMConstructor)
    COMPONENT(CONSOLESERVICE, nsConsoleServiceConstructor)
    COMPONENT_M(OBSERVERSERVICE, nsObserverService::Create, Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS)

    COMPONENT_M(TIMER, nsTimer::XPCOMConstructor, Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS)

#define COMPONENT_SUPPORTS(TYPE, Type)                                         \
  COMPONENT(SUPPORTS_##TYPE, nsSupports##Type##Constructor)

    COMPONENT_SUPPORTS(ID, ID)
    COMPONENT_SUPPORTS(STRING, String)
    COMPONENT_SUPPORTS(CSTRING, CString)
    COMPONENT_SUPPORTS(PRBOOL, PRBool)
    COMPONENT_SUPPORTS(PRUINT8, PRUint8)
    COMPONENT_SUPPORTS(PRUINT16, PRUint16)
    COMPONENT_SUPPORTS(PRUINT32, PRUint32)
    COMPONENT_SUPPORTS(PRUINT64, PRUint64)
    COMPONENT_SUPPORTS(PRTIME, PRTime)
    COMPONENT_SUPPORTS(CHAR, Char)
    COMPONENT_SUPPORTS(PRINT16, PRInt16)
    COMPONENT_SUPPORTS(PRINT32, PRInt32)
    COMPONENT_SUPPORTS(PRINT64, PRInt64)
    COMPONENT_SUPPORTS(FLOAT, Float)
    COMPONENT_SUPPORTS(DOUBLE, Double)
    COMPONENT_SUPPORTS(INTERFACE_POINTER, InterfacePointer)

#undef COMPONENT_SUPPORTS
    COMPONENT(LOCAL_FILE, nsLocalFile::nsLocalFileConstructor)
    COMPONENT(DIRECTORY_SERVICE, nsDirectoryService::Create)
    COMPONENT(PROCESS, nsProcessConstructor)
    COMPONENT(ENVIRONMENT, nsEnvironment::Create)

    COMPONENT(THREADMANAGER, nsThreadManagerGetSingleton)

    COMPONENT(STRINGINPUTSTREAM, nsStringInputStreamConstructor)
    COMPONENT(MULTIPLEXINPUTSTREAM, nsMultiplexInputStreamConstructor)

    COMPONENT(VARIANT, nsVariantCCConstructor)

    COMPONENT(HASH_PROPERTY_BAG, nsHashPropertyBagCCConstructor)

    COMPONENT(UUID_GENERATOR, nsUUIDGeneratorConstructor)

#if defined(XP_WIN)
    COMPONENT(WINDOWSREGKEY, nsWindowsRegKeyConstructor)
#endif

#if defined(MOZ_WIDGET_COCOA)
    COMPONENT(MACUTILSIMPL, nsMacUtilsImplConstructor)
#endif

    COMPONENT(SYSTEMINFO, nsSystemInfoConstructor)
    COMPONENT_M(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor, Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS)
    COMPONENT(MEMORY_INFO_DUMPER, nsMemoryInfoDumperConstructor)
    COMPONENT(IOUTIL, nsIOUtilConstructor)
    COMPONENT(MESSAGE_LOOP, nsMessageLoopConstructor)
Loading