Bug 1513059 - Use the minimal XPCOM for the socket process.r=froydnj
authorDragana Damjanovic <dd.mozilla@gmail.com>
Wed, 16 Jan 2019 23:05:11 +0000
changeset 511276 8d4aa37d713744c3b6713c0c5fa3cecef535ee74
parent 511275 d3d3222460fce87fc3dc53bdfd9794059b447c06
child 511277 5b6434fa88d4595c3990604ef99c95d1c8ca48e7
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1513059
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1513059 - Use the minimal XPCOM for the socket process.r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D15024
docshell/base/timeline/TimelineConsumers.cpp
dom/power/PowerManagerService.cpp
modules/libpref/Preferences.cpp
netwerk/build/nsNetModule.cpp
netwerk/ipc/SocketProcessChild.cpp
netwerk/ipc/SocketProcessImpl.cpp
toolkit/components/telemetry/core/Telemetry.cpp
toolkit/xre/nsAppRunner.cpp
widget/cocoa/nsAppShell.mm
widget/cocoa/nsWidgetFactory.mm
widget/gtk/nsWidgetFactory.cpp
widget/windows/nsWidgetFactory.cpp
xpcom/build/XPCOMInit.cpp
xpcom/build/XPCOMModule.inc
xpcom/components/Module.h
xpcom/components/nsComponentManager.cpp
--- a/docshell/base/timeline/TimelineConsumers.cpp
+++ b/docshell/base/timeline/TimelineConsumers.cpp
@@ -31,18 +31,17 @@ bool TimelineConsumers::sInShutdown = fa
 
 already_AddRefed<TimelineConsumers> TimelineConsumers::Get() {
   // Using this class is not supported yet for other processes other than
   // parent or content. To avoid accidental checks to methods like `IsEmpty`,
   // which would probably always be true in those cases, assert here.
   // Remember, there will be different singletons available to each process.
 
   // TODO: we have to avoid calling this function in socket process.
-  MOZ_ASSERT(XRE_IsContentProcess() || XRE_IsParentProcess() ||
-             XRE_IsSocketProcess());
+  MOZ_ASSERT(XRE_IsContentProcess() || XRE_IsParentProcess());
 
   // If we are shutting down, don't bother doing anything. Note: we can only
   // know whether or not we're in shutdown if we're instantiated.
   if (sInShutdown) {
     return nullptr;
   }
 
   // Note: We don't simply check `sInstance` for null-ness here, since otherwise
--- a/dom/power/PowerManagerService.cpp
+++ b/dom/power/PowerManagerService.cpp
@@ -153,33 +153,33 @@ already_AddRefed<WakeLock> PowerManagerS
 NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID);
 
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(
     nsIPowerManagerService,
     mozilla::dom::power::PowerManagerService::GetInstance)
 
 static const mozilla::Module::CIDEntry kPowerManagerCIDs[] = {
     // clang-format off
-  { &kNS_POWERMANAGERSERVICE_CID, false, nullptr, nsIPowerManagerServiceConstructor, mozilla::Module::ALLOW_IN_GPU_PROCESS },
+  { &kNS_POWERMANAGERSERVICE_CID, false, nullptr, nsIPowerManagerServiceConstructor, mozilla::Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS },
   { nullptr }
     // clang-format on
 };
 
 static const mozilla::Module::ContractIDEntry kPowerManagerContracts[] = {
     // clang-format off
-  { POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID, mozilla::Module::ALLOW_IN_GPU_PROCESS },
+  { POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID, mozilla::Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS },
   { nullptr }
     // clang-format on
 };
 
 // We mark the power module as being available in the GPU process because the
 // appshell depends on the power manager service.
 static const mozilla::Module kPowerManagerModule = {
     mozilla::Module::kVersion,
     kPowerManagerCIDs,
     kPowerManagerContracts,
     nullptr,
     nullptr,
     nullptr,
     nullptr,
-    mozilla::Module::ALLOW_IN_GPU_PROCESS};
+    mozilla::Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS};
 
 NSMODULE_DEFN(nsPowerManagerModule) = &kPowerManagerModule;
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -5411,29 +5411,30 @@ static void InitVarCachePref(const nsACS
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Preferences,
                                          Preferences::GetInstanceForService)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefLocalizedString, Init)
 
 static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID);
 static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID);
 
 static mozilla::Module::CIDEntry kPrefCIDs[] = {
-    {&kPrefServiceCID, true, nullptr, PreferencesConstructor},
+    {&kPrefServiceCID, true, nullptr, PreferencesConstructor, Module::ALLOW_IN_SOCKET_PROCESS},
     {&kPrefLocalizedStringCID, false, nullptr,
      nsPrefLocalizedStringConstructor},
     {nullptr}};
 
 static mozilla::Module::ContractIDEntry kPrefContracts[] = {
-    {NS_PREFSERVICE_CONTRACTID, &kPrefServiceCID},
+    {NS_PREFSERVICE_CONTRACTID, &kPrefServiceCID, Module::ALLOW_IN_SOCKET_PROCESS},
     {NS_PREFLOCALIZEDSTRING_CONTRACTID, &kPrefLocalizedStringCID},
     {nullptr}};
 
 static void UnloadPrefsModule() { Preferences::Shutdown(); }
 
 static const mozilla::Module kPrefModule = {mozilla::Module::kVersion,
                                             kPrefCIDs,
                                             kPrefContracts,
                                             nullptr,
                                             nullptr,
                                             nullptr,
-                                            UnloadPrefsModule};
+                                            UnloadPrefsModule,
+                                            Module::ALLOW_IN_SOCKET_PROCESS};
 
 NSMODULE_DEFN(nsPrefModule) = &kPrefModule;
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -712,24 +712,24 @@ NS_DEFINE_NAMED_CID(NS_NETWORKPREDICTOR_
 NS_DEFINE_NAMED_CID(NS_CAPTIVEPORTAL_CID);
 NS_DEFINE_NAMED_CID(NS_NETWORKCONNECTIVITYSERVICE_CID);
 #ifdef BUILD_NETWORK_INFO_SERVICE
 NS_DEFINE_NAMED_CID(NETWORKINFOSERVICE_CID);
 #endif  // BUILD_NETWORK_INFO_SERVICE
 
 static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
     // clang-format off
-    { &kNS_IOSERVICE_CID, false, nullptr, nsIOServiceConstructor },
+    { &kNS_IOSERVICE_CID, false, nullptr, nsIOServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
     { &kNS_STREAMTRANSPORTSERVICE_CID, false, nullptr, nsStreamTransportServiceConstructor },
-    { &kNS_SOCKETTRANSPORTSERVICE_CID, false, nullptr, nsSocketTransportServiceConstructor },
+    { &kNS_SOCKETTRANSPORTSERVICE_CID, false, nullptr, nsSocketTransportServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
     { &kNS_SERVERSOCKET_CID, false, nullptr, nsServerSocketConstructor },
     { &kNS_TLSSERVERSOCKET_CID, false, nullptr, TLSServerSocketConstructor },
     { &kNS_UDPSOCKET_CID, false, nullptr, nsUDPSocketConstructor },
-    { &kNS_DNSSERVICE_CID, false, nullptr, nsIDNSServiceConstructor },
-    { &kNS_IDNSERVICE_CID, false, nullptr, nsIDNServiceConstructor },
+    { &kNS_DNSSERVICE_CID, false, nullptr, nsIDNSServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
+    { &kNS_IDNSERVICE_CID, false, nullptr, nsIDNServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
     { &kNS_EFFECTIVETLDSERVICE_CID, false, nullptr, nsEffectiveTLDServiceConstructor },
     { &kNS_SIMPLEURI_CID, false, nullptr, nsSimpleURIMutatorConstructor }, // do_CreateInstance returns mutator
     { &kNS_SIMPLEURIMUTATOR_CID, false, nullptr, nsSimpleURIMutatorConstructor },
     { &kNS_SIMPLENESTEDURI_CID, false, nullptr, nsSimpleNestedURIMutatorConstructor }, // do_CreateInstance returns mutator
     { &kNS_SIMPLENESTEDURIMUTATOR_CID, false, nullptr, nsSimpleNestedURIMutatorConstructor },
     { &kNS_ASYNCSTREAMCOPIER_CID, false, nullptr, nsAsyncStreamCopierConstructor },
     { &kNS_INPUTSTREAMPUMP_CID, false, nullptr, nsInputStreamPumpConstructor },
     { &kNS_INPUTSTREAMCHANNEL_CID, false, nullptr, nsInputStreamChannelConstructor },
@@ -743,21 +743,21 @@ static const mozilla::Module::CIDEntry k
     { &kNS_SIMPLESTREAMLISTENER_CID, false, nullptr, nsSimpleStreamListenerConstructor },
     { &kNS_STREAMLISTENERTEE_CID, false, nullptr, nsStreamListenerTeeConstructor },
     { &kNS_LOADGROUP_CID, false, nullptr, nsLoadGroupConstructor },
     { &kNS_LOCALFILEINPUTSTREAM_CID, false, nullptr, nsFileInputStream::Create },
     { &kNS_LOCALFILEOUTPUTSTREAM_CID, false, nullptr, nsFileOutputStream::Create },
     { &kNS_ATOMICLOCALFILEOUTPUTSTREAM_CID, false, nullptr, nsAtomicFileOutputStreamConstructor },
     { &kNS_SAFELOCALFILEOUTPUTSTREAM_CID, false, nullptr, nsSafeFileOutputStreamConstructor },
     { &kNS_INCREMENTALDOWNLOAD_CID, false, nullptr, net_NewIncrementalDownload },
-    { &kNS_STDURLPARSER_CID, false, nullptr, nsStdURLParserConstructor },
-    { &kNS_NOAUTHURLPARSER_CID, false, nullptr, nsNoAuthURLParserConstructor },
-    { &kNS_AUTHURLPARSER_CID, false, nullptr, nsAuthURLParserConstructor },
-    { &kNS_STANDARDURL_CID, false, nullptr, nsStandardURLMutatorConstructor }, // do_CreateInstance returns mutator
-    { &kNS_STANDARDURLMUTATOR_CID, false, nullptr, nsStandardURLMutatorConstructor },
+    { &kNS_STDURLPARSER_CID, false, nullptr, nsStdURLParserConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
+    { &kNS_NOAUTHURLPARSER_CID, false, nullptr, nsNoAuthURLParserConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
+    { &kNS_AUTHURLPARSER_CID, false, nullptr, nsAuthURLParserConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
+    { &kNS_STANDARDURL_CID, false, nullptr, nsStandardURLMutatorConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, // do_CreateInstance returns mutator
+    { &kNS_STANDARDURLMUTATOR_CID, false, nullptr, nsStandardURLMutatorConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
     { &kNS_ARRAYBUFFERINPUTSTREAM_CID, false, nullptr, ArrayBufferInputStreamConstructor },
     { &kNS_BUFFEREDINPUTSTREAM_CID, false, nullptr, nsBufferedInputStream::Create },
     { &kNS_BUFFEREDOUTPUTSTREAM_CID, false, nullptr, nsBufferedOutputStream::Create },
     { &kNS_MIMEINPUTSTREAM_CID, false, nullptr, nsMIMEInputStreamConstructor },
     { &kNS_PROTOCOLPROXYSERVICE_CID, true, nullptr, nsProtocolProxyServiceConstructor },
     { &kNS_STREAMCONVERTERSERVICE_CID, false, nullptr, CreateNewStreamConvServiceFactory },
     { &kNS_DASHBOARD_CID, false, nullptr, mozilla::net::DashboardConstructor },
     { &kNS_FTPDIRLISTINGCONVERTER_CID, false, nullptr, CreateNewFTPDirListingConv },
@@ -821,25 +821,25 @@ static const mozilla::Module::CIDEntry k
     { &kNETWORKINFOSERVICE_CID, false, nullptr, nsNetworkInfoServiceConstructor },
 #endif
     { nullptr }
     // clang-format on
 };
 
 static const mozilla::Module::ContractIDEntry kNeckoContracts[] = {
     // clang-format off
-    { NS_IOSERVICE_CONTRACTID, &kNS_IOSERVICE_CID },
+    { NS_IOSERVICE_CONTRACTID, &kNS_IOSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
     { NS_NETUTIL_CONTRACTID, &kNS_IOSERVICE_CID },
     { NS_STREAMTRANSPORTSERVICE_CONTRACTID, &kNS_STREAMTRANSPORTSERVICE_CID },
-    { NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &kNS_SOCKETTRANSPORTSERVICE_CID },
+    { NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &kNS_SOCKETTRANSPORTSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
     { NS_SERVERSOCKET_CONTRACTID, &kNS_SERVERSOCKET_CID },
     { NS_TLSSERVERSOCKET_CONTRACTID, &kNS_TLSSERVERSOCKET_CID },
     { NS_UDPSOCKET_CONTRACTID, &kNS_UDPSOCKET_CID },
-    { NS_DNSSERVICE_CONTRACTID, &kNS_DNSSERVICE_CID },
-    { NS_IDNSERVICE_CONTRACTID, &kNS_IDNSERVICE_CID },
+    { NS_DNSSERVICE_CONTRACTID, &kNS_DNSSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
+    { NS_IDNSERVICE_CONTRACTID, &kNS_IDNSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
     { NS_EFFECTIVETLDSERVICE_CONTRACTID, &kNS_EFFECTIVETLDSERVICE_CID },
     { NS_SIMPLEURIMUTATOR_CONTRACTID, &kNS_SIMPLEURIMUTATOR_CID },
     { NS_ASYNCSTREAMCOPIER_CONTRACTID, &kNS_ASYNCSTREAMCOPIER_CID },
     { NS_INPUTSTREAMPUMP_CONTRACTID, &kNS_INPUTSTREAMPUMP_CID },
     { NS_INPUTSTREAMCHANNEL_CONTRACTID, &kNS_INPUTSTREAMCHANNEL_CID },
     { NS_STREAMLOADER_CONTRACTID, &kNS_STREAMLOADER_CID },
     { NS_INCREMENTALSTREAMLOADER_CONTRACTID, &kNS_INCREMENTALSTREAMLOADER_CID },
     { NS_DOWNLOADER_CONTRACTID, &kNS_DOWNLOADER_CID },
@@ -848,20 +848,20 @@ static const mozilla::Module::ContractID
     { NS_SIMPLESTREAMLISTENER_CONTRACTID, &kNS_SIMPLESTREAMLISTENER_CID },
     { NS_STREAMLISTENERTEE_CONTRACTID, &kNS_STREAMLISTENERTEE_CID },
     { NS_LOADGROUP_CONTRACTID, &kNS_LOADGROUP_CID },
     { NS_LOCALFILEINPUTSTREAM_CONTRACTID, &kNS_LOCALFILEINPUTSTREAM_CID },
     { NS_LOCALFILEOUTPUTSTREAM_CONTRACTID, &kNS_LOCALFILEOUTPUTSTREAM_CID },
     { NS_ATOMICLOCALFILEOUTPUTSTREAM_CONTRACTID, &kNS_ATOMICLOCALFILEOUTPUTSTREAM_CID },
     { NS_SAFELOCALFILEOUTPUTSTREAM_CONTRACTID, &kNS_SAFELOCALFILEOUTPUTSTREAM_CID },
     { NS_INCREMENTALDOWNLOAD_CONTRACTID, &kNS_INCREMENTALDOWNLOAD_CID },
-    { NS_STDURLPARSER_CONTRACTID, &kNS_STDURLPARSER_CID },
-    { NS_NOAUTHURLPARSER_CONTRACTID, &kNS_NOAUTHURLPARSER_CID },
-    { NS_AUTHURLPARSER_CONTRACTID, &kNS_AUTHURLPARSER_CID },
-    { NS_STANDARDURLMUTATOR_CONTRACTID, &kNS_STANDARDURLMUTATOR_CID },
+    { NS_STDURLPARSER_CONTRACTID, &kNS_STDURLPARSER_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
+    { NS_NOAUTHURLPARSER_CONTRACTID, &kNS_NOAUTHURLPARSER_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
+    { NS_AUTHURLPARSER_CONTRACTID, &kNS_AUTHURLPARSER_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
+    { NS_STANDARDURLMUTATOR_CONTRACTID, &kNS_STANDARDURLMUTATOR_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
     { NS_ARRAYBUFFERINPUTSTREAM_CONTRACTID, &kNS_ARRAYBUFFERINPUTSTREAM_CID },
     { NS_BUFFEREDINPUTSTREAM_CONTRACTID, &kNS_BUFFEREDINPUTSTREAM_CID },
     { NS_BUFFEREDOUTPUTSTREAM_CONTRACTID, &kNS_BUFFEREDOUTPUTSTREAM_CID },
     { NS_MIMEINPUTSTREAM_CONTRACTID, &kNS_MIMEINPUTSTREAM_CID },
     { NS_PROTOCOLPROXYSERVICE_CONTRACTID, &kNS_PROTOCOLPROXYSERVICE_CID },
     { NS_STREAMCONVERTERSERVICE_CONTRACTID, &kNS_STREAMCONVERTERSERVICE_CID },
     { NS_DASHBOARD_CONTRACTID, &kNS_DASHBOARD_CID },
     { NS_ISTREAMCONVERTER_KEY FTP_TO_INDEX, &kNS_FTPDIRLISTINGCONVERTER_CID },
@@ -931,11 +931,12 @@ static const mozilla::Module::ContractID
 };
 
 static const mozilla::Module kNeckoModule = {mozilla::Module::kVersion,
                                              kNeckoCIDs,
                                              kNeckoContracts,
                                              kNeckoCategories,
                                              nullptr,
                                              nsNetStartup,
-                                             nsNetShutdown};
+                                             nsNetShutdown,
+                                             mozilla::Module::ALLOW_IN_SOCKET_PROCESS};
 
 NSMODULE_DEFN(necko) = &kNeckoModule;
--- a/netwerk/ipc/SocketProcessChild.cpp
+++ b/netwerk/ipc/SocketProcessChild.cpp
@@ -63,16 +63,20 @@ bool SocketProcessChild::Init(base::Proc
     // We need to quit this process if the buildID doesn't match the parent's.
     // This can occur when an update occurred in the background.
     ProcessChild::QuickExit();
   }
 
   // Init crash reporter support.
   CrashReporterClient::InitSingleton(this);
 
+  if (NS_FAILED(NS_InitMinimalXPCOM())) {
+    return false;
+  }
+
   SetThisProcessName("Socket Process");
   return true;
 }
 
 void SocketProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
   LOG(("SocketProcessChild::ActorDestroy\n"));
 
   if (AbnormalShutdown == aWhy) {
--- a/netwerk/ipc/SocketProcessImpl.cpp
+++ b/netwerk/ipc/SocketProcessImpl.cpp
@@ -76,20 +76,16 @@ bool SocketProcessImpl::Init(int aArgc, 
   }
 
   SharedPreferenceDeserializer deserializer;
   if (!deserializer.DeserializeFromSharedMemory(prefsHandle, prefMapHandle,
                                                 prefsLen, prefMapSize)) {
     return false;
   }
 
-  if (NS_FAILED(NS_InitXPCOM2(nullptr, nullptr, nullptr))) {
-    return false;
-  }
-
   return mSocketProcessChild.Init(ParentPid(), parentBuildID,
                                   IOThreadChild::message_loop(),
                                   IOThreadChild::channel());
 }
 
 void SocketProcessImpl::CleanUp() { mSocketProcessChild.CleanUp(); }
 
 }  // namespace net
--- a/toolkit/components/telemetry/core/Telemetry.cpp
+++ b/toolkit/components/telemetry/core/Telemetry.cpp
@@ -1538,32 +1538,32 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR
     0xaea477f2, 0xb3a2, 0x469c, {                    \
       0xaa, 0x29, 0x0a, 0x82, 0xd1, 0x32, 0xb8, 0x29 \
     }                                                \
   }
 NS_DEFINE_NAMED_CID(NS_TELEMETRY_CID);
 
 const Module::CIDEntry kTelemetryCIDs[] = {
     {&kNS_TELEMETRY_CID, false, nullptr, nsITelemetryConstructor,
-     Module::ALLOW_IN_GPU_AND_VR_PROCESS},
+     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
     {nullptr}};
 
 const Module::ContractIDEntry kTelemetryContracts[] = {
     {"@mozilla.org/base/telemetry;1", &kNS_TELEMETRY_CID,
-     Module::ALLOW_IN_GPU_AND_VR_PROCESS},
+     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
     {nullptr}};
 
 const Module kTelemetryModule = {Module::kVersion,
                                  kTelemetryCIDs,
                                  kTelemetryContracts,
                                  nullptr,
                                  nullptr,
                                  nullptr,
                                  TelemetryImpl::ShutdownTelemetry,
-                                 Module::ALLOW_IN_GPU_AND_VR_PROCESS};
+                                 Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS};
 
 NS_IMETHODIMP
 TelemetryImpl::GetFileIOReports(JSContext* cx, JS::MutableHandleValue ret) {
   if (sTelemetryIOObserver) {
     JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     if (!obj) {
       return NS_ERROR_FAILURE;
     }
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4705,17 +4705,17 @@ bool XRE_IsE10sParentProcess() {
   bool XRE_Is##xre_name##Process() {                             \
     return XRE_GetProcessType() == GeckoProcessType_##enum_name; \
   }
 #include "mozilla/GeckoProcessTypes.h"
 #undef GECKO_PROCESS_TYPE
 
 bool XRE_UseNativeEventProcessing() {
 #ifdef XP_MACOSX
-  if (XRE_IsRDDProcess()) {
+  if (XRE_IsRDDProcess() || XRE_IsSocketProcess()) {
     return false;
   }
 #endif
   if (XRE_IsContentProcess()) {
     static bool sInited = false;
     static bool sUseNativeEventProcessing = false;
     if (!sInited) {
       Preferences::AddBoolVarCache(&sUseNativeEventProcessing,
--- a/widget/cocoa/nsAppShell.mm
+++ b/widget/cocoa/nsAppShell.mm
@@ -310,17 +310,18 @@ nsAppShell::Init()
 
   // mAutoreleasePools is used as a stack of NSAutoreleasePool objects created
   // by |this|.  CFArray is used instead of NSArray because NSArray wants to
   // retain each object you add to it, and you can't retain an
   // NSAutoreleasePool.
   mAutoreleasePools = ::CFArrayCreateMutable(nullptr, 0, nullptr);
   NS_ENSURE_STATE(mAutoreleasePools);
 
-  if (XRE_GetProcessType() != GeckoProcessType_RDD) {
+  if (XRE_GetProcessType() != GeckoProcessType_RDD &&
+      XRE_GetProcessType() != GeckoProcessType_Socket) {
     // Get the path of the nib file, which lives in the GRE location
     nsCOMPtr<nsIFile> nibFile;
     nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(nibFile));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nibFile->AppendNative(NS_LITERAL_CSTRING("res"));
     nibFile->AppendNative(NS_LITERAL_CSTRING("MainMenu.nib"));
 
--- a/widget/cocoa/nsWidgetFactory.mm
+++ b/widget/cocoa/nsWidgetFactory.mm
@@ -129,17 +129,17 @@ NS_DEFINE_NAMED_CID(NS_STANDALONENATIVEM
 NS_DEFINE_NAMED_CID(NS_MACSYSTEMSTATUSBAR_CID);
 NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
 
 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
   { &kNS_FILEPICKER_CID, false, NULL, nsFilePickerConstructor,
     mozilla::Module::MAIN_PROCESS_ONLY },
   { &kNS_COLORPICKER_CID, false, NULL, nsColorPickerConstructor,
     mozilla::Module::MAIN_PROCESS_ONLY },
-  { &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor, mozilla::Module::ALLOW_IN_GPU_AND_VR_PROCESS },
+  { &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor, mozilla::Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS },
   { &kNS_SOUND_CID, false, NULL, nsSoundConstructor,
     mozilla::Module::MAIN_PROCESS_ONLY },
   { &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
   { &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
   { &kNS_CLIPBOARD_CID, false, NULL, nsClipboardConstructor,
     mozilla::Module::MAIN_PROCESS_ONLY },
   { &kNS_CLIPBOARDHELPER_CID, false, NULL, nsClipboardHelperConstructor },
   { &kNS_DRAGSERVICE_CID, false, NULL, nsDragServiceConstructor,
@@ -162,17 +162,17 @@ static const mozilla::Module::CIDEntry k
   { NULL }
 };
 
 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
   { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID,
     mozilla::Module::MAIN_PROCESS_ONLY },
   { "@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID,
     mozilla::Module::MAIN_PROCESS_ONLY },
-  { "@mozilla.org/widget/appshell/mac;1", &kNS_APPSHELL_CID, mozilla::Module::ALLOW_IN_GPU_AND_VR_PROCESS },
+  { "@mozilla.org/widget/appshell/mac;1", &kNS_APPSHELL_CID, mozilla::Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS },
   { "@mozilla.org/sound;1", &kNS_SOUND_CID,
     mozilla::Module::MAIN_PROCESS_ONLY },
   { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
   { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
   { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID,
     mozilla::Module::MAIN_PROCESS_ONLY },
   { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
   { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID,
@@ -210,12 +210,12 @@ nsWidgetCocoaModuleDtor()
 static const mozilla::Module kWidgetModule = {
   mozilla::Module::kVersion,
   kWidgetCIDs,
   kWidgetContracts,
   NULL,
   NULL,
   nsAppShellInit,
   nsWidgetCocoaModuleDtor,
-  mozilla::Module::ALLOW_IN_GPU_AND_VR_PROCESS
+  mozilla::Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS
 };
 
 NSMODULE_DEFN(nsWidgetMacModule) = &kWidgetModule;
--- a/widget/gtk/nsWidgetFactory.cpp
+++ b/widget/gtk/nsWidgetFactory.cpp
@@ -180,17 +180,17 @@ NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVIC
 NS_DEFINE_NAMED_CID(NS_IMAGE_TO_PIXBUF_CID);
 #if defined(MOZ_X11)
 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
 #endif
 
 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
     {&kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor,
-     Module::ALLOW_IN_GPU_AND_VR_PROCESS},
+     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
     {&kNS_COLORPICKER_CID, false, nullptr, nsColorPickerConstructor,
      Module::MAIN_PROCESS_ONLY},
     {&kNS_FILEPICKER_CID, false, nullptr, nsFilePickerConstructor,
      Module::MAIN_PROCESS_ONLY},
 #ifdef MOZ_WIDGET_GTK
     {&kNS_APPLICATIONCHOOSER_CID, false, nullptr,
      nsApplicationChooserConstructor, Module::MAIN_PROCESS_ONLY},
 #endif
@@ -224,17 +224,17 @@ static const mozilla::Module::CIDEntry k
 #if defined(MOZ_X11)
     {&kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceGTKConstructor},
     {&kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor},
 #endif
     {nullptr}};
 
 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
     {"@mozilla.org/widget/appshell/gtk;1", &kNS_APPSHELL_CID,
-     Module::ALLOW_IN_GPU_AND_VR_PROCESS},
+     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
     {"@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID,
      Module::MAIN_PROCESS_ONLY},
     {"@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID,
      Module::MAIN_PROCESS_ONLY},
 #ifdef MOZ_WIDGET_GTK
     {"@mozilla.org/applicationchooser;1", &kNS_APPLICATIONCHOOSER_CID,
      Module::MAIN_PROCESS_ONLY},
 #endif
@@ -286,11 +286,11 @@ static void nsWidgetGtk2ModuleDtor() {
 static const mozilla::Module kWidgetModule = {
     mozilla::Module::kVersion,
     kWidgetCIDs,
     kWidgetContracts,
     nullptr,
     nullptr,
     nsAppShellInit,
     nsWidgetGtk2ModuleDtor,
-    Module::ALLOW_IN_GPU_AND_VR_PROCESS};
+    Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS};
 
 NSMODULE_DEFN(nsWidgetGtk2Module) = &kWidgetModule;
--- a/widget/windows/nsWidgetFactory.cpp
+++ b/widget/windows/nsWidgetFactory.cpp
@@ -161,21 +161,21 @@ NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SP
 #endif
 
 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
     {&kNS_FILEPICKER_CID, false, nullptr, FilePickerConstructor,
      Module::MAIN_PROCESS_ONLY},
     {&kNS_COLORPICKER_CID, false, nullptr, ColorPickerConstructor,
      Module::MAIN_PROCESS_ONLY},
     {&kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor,
-     Module::ALLOW_IN_GPU_AND_VR_PROCESS},
+     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
     {&kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor,
      Module::MAIN_PROCESS_ONLY},
     {&kNS_GFXINFO_CID, false, nullptr, GfxInfoConstructor,
-     Module::ALLOW_IN_GPU_PROCESS},
+     Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS},
     {&kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceWinConstructor},
     {&kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor,
      Module::MAIN_PROCESS_ONLY},
     {&kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor},
     {&kNS_SOUND_CID, false, nullptr, nsISoundConstructor,
      Module::MAIN_PROCESS_ONLY},
     {&kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor},
     {&kNS_HTMLFORMATCONVERTER_CID, false, nullptr,
@@ -211,20 +211,21 @@ static const mozilla::Module::CIDEntry k
     {nullptr}};
 
 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
     {"@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID,
      Module::MAIN_PROCESS_ONLY},
     {"@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID,
      Module::MAIN_PROCESS_ONLY},
     {"@mozilla.org/widget/appshell/win;1", &kNS_APPSHELL_CID,
-     Module::ALLOW_IN_GPU_AND_VR_PROCESS},
+     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
     {"@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID,
      Module::MAIN_PROCESS_ONLY},
-    {"@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID, Module::ALLOW_IN_GPU_PROCESS},
+    {"@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID,
+     Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS},
     {"@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID},
     {"@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID,
      Module::MAIN_PROCESS_ONLY},
     {"@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID},
     {"@mozilla.org/sound;1", &kNS_SOUND_CID, Module::MAIN_PROCESS_ONLY},
     {"@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID},
     {"@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID},
     {"@mozilla.org/windows-taskbar;1", &kNS_WIN_TASKBAR_CID},
@@ -266,11 +267,11 @@ static void nsWidgetWindowsModuleDtor() 
 static const mozilla::Module kWidgetModule = {
     mozilla::Module::kVersion,
     kWidgetCIDs,
     kWidgetContracts,
     nullptr,
     nullptr,
     nsAppShellInit,
     nsWidgetWindowsModuleDtor,
-    Module::ALLOW_IN_GPU_AND_VR_PROCESS};
+    Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS};
 
 NSMODULE_DEFN(nsWidgetModule) = &kWidgetModule;
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -263,17 +263,17 @@ static already_AddRefed<nsIFactory> Crea
 #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_AND_VR_PROCESS},
+     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
@@ -303,17 +303,17 @@ const mozilla::Module::ContractIDEntry k
 
 const mozilla::Module kXPCOMModule = {mozilla::Module::kVersion,
                                       kXPCOMCIDEntries,
                                       kXPCOMContracts,
                                       nullptr,
                                       nullptr,
                                       nullptr,
                                       nullptr,
-                                      Module::ALLOW_IN_GPU_AND_VR_PROCESS};
+                                      Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS};
 
 // gDebug will be freed during shutdown.
 static nsIDebug2* gDebug = nullptr;
 
 EXPORT_XPCOM_API(nsresult)
 NS_GetDebug(nsIDebug2** aResult) {
   return nsDebugImpl::Create(nullptr, NS_GET_IID(nsIDebug2), (void**)aResult);
 }
--- a/xpcom/build/XPCOMModule.inc
+++ b/xpcom/build/XPCOMModule.inc
@@ -1,26 +1,26 @@
-    COMPONENT_M(MEMORY, nsMemoryImpl::Create, Module::ALLOW_IN_GPU_AND_VR_PROCESS)
-    COMPONENT_M(DEBUG,  nsDebugImpl::Create, Module::ALLOW_IN_GPU_PROCESS)
+    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_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_AND_VR_PROCESS)
+    COMPONENT_M(OBSERVERSERVICE, nsObserverService::Create, Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS)
 
-    COMPONENT_M(TIMER, nsTimer::XPCOMConstructor, Module::ALLOW_IN_GPU_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)
@@ -58,12 +58,12 @@
     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_PROCESS)
+    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)
--- a/xpcom/components/Module.h
+++ b/xpcom/components/Module.h
@@ -46,17 +46,20 @@ struct Module {
 
     /**
      * By default, modules are not loaded in the GPU process, even if
      * ANY_PROCESS is specified. This flag enables a module in the
      * GPU process.
      */
     ALLOW_IN_GPU_PROCESS = 0x4,
     ALLOW_IN_VR_PROCESS = 0x8,
-    ALLOW_IN_GPU_AND_VR_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS
+    ALLOW_IN_SOCKET_PROCESS = 0x10,
+    ALLOW_IN_GPU_AND_VR_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS,
+    ALLOW_IN_GPU_AND_SOCKET_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_SOCKET_PROCESS,
+    ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS | ALLOW_IN_SOCKET_PROCESS
   };
 
   /**
    * The constructor callback is an implementation detail of the default binary
    * loader and may be null.
    */
   struct CIDEntry {
     const nsCID* cid;
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -435,16 +435,20 @@ nsresult nsComponentManagerImpl::Init() 
 }
 
 static bool ProcessSelectorMatches(Module::ProcessSelector aSelector) {
   GeckoProcessType type = XRE_GetProcessType();
   if (type == GeckoProcessType_GPU || type == GeckoProcessType_RDD) {
     return !!(aSelector & Module::ALLOW_IN_GPU_PROCESS);
   }
 
+  if (type == GeckoProcessType_Socket) {
+    return !!(aSelector & (Module::ALLOW_IN_SOCKET_PROCESS));
+  }
+
   if (type == GeckoProcessType_VR) {
     return !!(aSelector & Module::ALLOW_IN_VR_PROCESS);
   }
 
   if (aSelector & Module::MAIN_PROCESS_ONLY) {
     return type == GeckoProcessType_Default;
   }
   if (aSelector & Module::CONTENT_PROCESS_ONLY) {