From ce46c63b8df332593a74d733fad1075f76b54509 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Thu, 10 Aug 2023 14:31:47 +0000 Subject: [PATCH] Bug 1845946 - Part 2. Add plumbing for component services to be used in the GMP process. r=emilio In order to bring the GMP process in closer alignment with how other special purpose processes work, we need to be able to use the same component services generally expected. This patch makes the GMP process allow the same services as seen in the GPU/VR/RDD/Utility processes. Differential Revision: https://phabricator.services.mozilla.com/D185336 --- modules/libpref/components.conf | 2 +- .../components/telemetry/core/components.conf | 2 +- widget/cocoa/components.conf | 30 +++++++++---------- widget/gtk/components.conf | 2 +- widget/windows/components.conf | 2 +- xpcom/build/components.conf | 4 +-- xpcom/components/Module.h | 17 +++++++---- xpcom/components/components.conf | 2 +- xpcom/components/gen_static_components.py | 10 +++++++ xpcom/components/nsComponentManager.cpp | 13 +++++++- xpcom/ds/components.conf | 2 +- 11 files changed, 56 insertions(+), 30 deletions(-) diff --git a/modules/libpref/components.conf b/modules/libpref/components.conf index 25f3aecbb78f..20f4e61d2f33 100644 --- a/modules/libpref/components.conf +++ b/modules/libpref/components.conf @@ -21,7 +21,7 @@ Classes = [ 'type': 'mozilla::Preferences', 'headers': ['mozilla/Preferences.h'], 'constructor': 'mozilla::Preferences::GetInstanceForService', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{064d9cee-1dd2-11b2-83e3-d25ab0193c26}', diff --git a/toolkit/components/telemetry/core/components.conf b/toolkit/components/telemetry/core/components.conf index 82a624f4ece5..d003b414a1be 100644 --- a/toolkit/components/telemetry/core/components.conf +++ b/toolkit/components/telemetry/core/components.conf @@ -16,6 +16,6 @@ Classes = [ 'interfaces': ['nsITelemetry'], 'singleton': True, 'type': 'nsITelemetry', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, ] diff --git a/widget/cocoa/components.conf b/widget/cocoa/components.conf index 199e5cf25508..e3d583930280 100644 --- a/widget/cocoa/components.conf +++ b/widget/cocoa/components.conf @@ -41,7 +41,7 @@ Classes = [ 'cid': '{2d96b3df-c051-11d1-a827-0040959a28c9}', 'contract_ids': ['@mozilla.org/widget/appshell/mac;1'], 'legacy_constructor': 'nsAppShellConstructor', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{15cc80a9-5329-4fcb-9a0b-c6cf1440ae51}', @@ -53,19 +53,19 @@ Classes = [ 'cid': '{8b5314bc-db01-11d2-96ce-0060b0fb9956}', 'contract_ids': ['@mozilla.org/widget/transferable;1'], 'type': 'nsTransferable', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{948a0023-e3a7-11d2-96cf-0060b0fb9956}', 'contract_ids': ['@mozilla.org/widget/htmlformatconverter;1'], 'type': 'nsHTMLFormatConverter', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}', 'contract_ids': ['@mozilla.org/widget/clipboardhelper;1'], 'type': 'nsClipboardHelper', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{9a155bb2-2b67-45de-83e3-13a9dacf8336}', @@ -96,7 +96,7 @@ Classes = [ 'cid': '{841387c8-72e6-484b-9296-bf6eea80d58a}', 'contract_ids': ['@mozilla.org/gfx/printsettings-service;1'], 'type': 'nsPrintSettingsServiceX', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{06beec76-a183-4d9f-85dd-085f26da565a}', @@ -109,60 +109,60 @@ Classes = [ 'contract_ids': ['@mozilla.org/widget/useridleservice;1'], 'type': 'nsUserIdleServiceX', 'singleton': True, - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{84e11f80-ca55-11dd-ad8b-0800200c9a66}', 'contract_ids': ['@mozilla.org/system-alerts-service;1'], 'type': 'mozilla::OSXNotificationCenter', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{2451baed-8dc3-46d9-9e30-96e1baa03666}', 'contract_ids': ['@mozilla.org/widget/macdocksupport;1'], 'type': 'nsMacDockSupport', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{74ea4101-a5bb-49bc-9984-66da8b225a37}', 'contract_ids': ['@mozilla.org/widget/macfinderprogress;1'], 'type': 'nsMacFinderProgress', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{de59fe1a-46c8-490f-b04d-34545acb06c9}', 'contract_ids': ['@mozilla.org/widget/macsharingservice;1'], 'type': 'nsMacSharingService', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{29046c8f-cba6-4ffa-9141-1685e96c4ea0}', 'contract_ids': ['@mozilla.org/widget/macuseractivityupdater;1'], 'type': 'nsMacUserActivityUpdater', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{e9096367-ddd9-45e4-b762-49c0c18b7119}', 'contract_ids': ['@mozilla.org/widget/mac-web-app-utils;1'], 'type': 'nsMacWebAppUtils', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{1f39ae50-b6a0-4b37-90f4-60af614193d8}', 'contract_ids': ['@mozilla.org/widget/standalonenativemenu;1'], 'type': 'nsStandaloneNativeMenu', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{b6e1a890-b2b8-4883-a65f-9476f6185313}', 'contract_ids': ['@mozilla.org/widget/systemstatusbar;1'], 'type': 'nsSystemStatusBarCocoa', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{38f396e2-93c9-4a77-aaf7-2d50b9962186}', 'contract_ids': ['@mozilla.org/widget/touchbarupdater;1'], 'type': 'nsTouchBarUpdater', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, ] diff --git a/widget/gtk/components.conf b/widget/gtk/components.conf index a2759a3c45cc..851de59d0c66 100644 --- a/widget/gtk/components.conf +++ b/widget/gtk/components.conf @@ -17,7 +17,7 @@ Classes = [ 'contract_ids': ['@mozilla.org/widget/appshell/gtk;1'], 'legacy_constructor': 'nsAppShellConstructor', 'headers': ['/widget/gtk/nsWidgetFactory.h'], - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{e9537f8f-c07e-4435-8ab3-83f1ad6e3bbf}', diff --git a/widget/windows/components.conf b/widget/windows/components.conf index 0ccaae359826..11b1df3ebd01 100644 --- a/widget/windows/components.conf +++ b/widget/windows/components.conf @@ -26,7 +26,7 @@ Classes = [ 'contract_ids': ['@mozilla.org/widget/appshell/win;1'], 'headers': ['/widget/windows/nsWidgetFactory.h'], 'legacy_constructor': 'nsAppShellConstructor', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{6987230e-0098-4e78-bc5f-1493ee7519fa}', diff --git a/xpcom/build/components.conf b/xpcom/build/components.conf index 6bf301c26f08..3de2dbb1190c 100644 --- a/xpcom/build/components.conf +++ b/xpcom/build/components.conf @@ -78,7 +78,7 @@ Classes = [ 'type': 'nsMemoryReporterManager', 'headers': ['/xpcom/base/nsMemoryReporterManager.h'], 'init_method': 'Init', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, { 'cid': '{7b4eeb20-d781-11d4-8a83-0010a4e0c9ca}', @@ -241,7 +241,7 @@ Classes = [ 'contract_ids': ['@mozilla.org/xpcom/ini-parser-factory;1'], 'type': 'nsINIParserFactory', 'headers': ['/xpcom/ds/nsINIParserImpl.h'], - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, ] diff --git a/xpcom/components/Module.h b/xpcom/components/Module.h index f9b8f16f4e32..b8fae6435693 100644 --- a/xpcom/components/Module.h +++ b/xpcom/components/Module.h @@ -24,9 +24,9 @@ enum ProcessSelector { CONTENT_PROCESS_ONLY = 1 << 1, /** - * By default, modules are not loaded in the GPU, VR, Socket, RDD, Utility - * and IPDLUnitTest processes, even if ANY_PROCESS is specified. This flag - * enables a module in the relevant process. + * By default, modules are not loaded in the GPU, VR, Socket, RDD, Utility, + * GMPlugin and IPDLUnitTest processes, even if ANY_PROCESS is specified. + * This flag enables a module in the relevant process. * * NOTE: IPDLUnitTest does not have its own flag, and will only load a * module if it is enabled in all processes. @@ -36,6 +36,7 @@ enum ProcessSelector { ALLOW_IN_SOCKET_PROCESS = 1 << 4, ALLOW_IN_RDD_PROCESS = 1 << 5, ALLOW_IN_UTILITY_PROCESS = 1 << 6, + ALLOW_IN_GMPLUGIN_PROCESS = 1 << 7, ALLOW_IN_GPU_AND_MAIN_PROCESS = ALLOW_IN_GPU_PROCESS | MAIN_PROCESS_ONLY, ALLOW_IN_GPU_AND_VR_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS, ALLOW_IN_GPU_AND_SOCKET_PROCESS = @@ -53,11 +54,15 @@ enum ProcessSelector { ALLOW_IN_SOCKET_PROCESS, ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_RDD_PROCESS | ALLOW_IN_VR_PROCESS | - ALLOW_IN_SOCKET_PROCESS | ALLOW_IN_UTILITY_PROCESS + ALLOW_IN_SOCKET_PROCESS | ALLOW_IN_UTILITY_PROCESS, + ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS = + ALLOW_IN_GPU_PROCESS | ALLOW_IN_RDD_PROCESS | ALLOW_IN_VR_PROCESS | + ALLOW_IN_SOCKET_PROCESS | ALLOW_IN_UTILITY_PROCESS | + ALLOW_IN_GMPLUGIN_PROCESS }; -static constexpr size_t kMaxProcessSelector = - size_t(ProcessSelector::ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS); +static constexpr size_t kMaxProcessSelector = size_t( + ProcessSelector::ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS); /** * This allows category entries to be marked so that they are or are diff --git a/xpcom/components/components.conf b/xpcom/components/components.conf index 73cc177e8d94..9938fb104f81 100644 --- a/xpcom/components/components.conf +++ b/xpcom/components/components.conf @@ -18,6 +18,6 @@ Classes = [ 'cid': '{91775d60-d5dc-11d2-92fb-00e09805570f}', 'legacy_constructor': 'nsComponentManagerImpl::Create', 'headers': ['/xpcom/components/nsComponentManager.h'], - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, ] diff --git a/xpcom/components/gen_static_components.py b/xpcom/components/gen_static_components.py index 8e5d3e9685fb..f759dc313245 100644 --- a/xpcom/components/gen_static_components.py +++ b/xpcom/components/gen_static_components.py @@ -64,6 +64,7 @@ class ProcessSelector: ALLOW_IN_SOCKET_PROCESS = 1 << 4 ALLOW_IN_RDD_PROCESS = 1 << 5 ALLOW_IN_UTILITY_PROCESS = 1 << 6 + ALLOW_IN_GMPLUGIN_PROCESS = 1 << 7 ALLOW_IN_GPU_AND_MAIN_PROCESS = ALLOW_IN_GPU_PROCESS | MAIN_PROCESS_ONLY ALLOW_IN_GPU_AND_SOCKET_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_SOCKET_PROCESS ALLOW_IN_GPU_AND_VR_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS @@ -93,6 +94,14 @@ class ProcessSelector: | ALLOW_IN_SOCKET_PROCESS | ALLOW_IN_UTILITY_PROCESS ) + ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS = ( + ALLOW_IN_GPU_PROCESS + | ALLOW_IN_RDD_PROCESS + | ALLOW_IN_VR_PROCESS + | ALLOW_IN_SOCKET_PROCESS + | ALLOW_IN_UTILITY_PROCESS + | ALLOW_IN_GMPLUGIN_PROCESS + ) # Maps ProcessSelector constants to the name of the corresponding @@ -114,6 +123,7 @@ PROCESSES = { ProcessSelector.ALLOW_IN_GPU_RDD_SOCKET_AND_UTILITY_PROCESS: "ALLOW_IN_GPU_RDD_SOCKET_AND_UTILITY_PROCESS", # NOQA: E501 ProcessSelector.ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS: "ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS", # NOQA: E501 ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS: "ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS", # NOQA: E501 + ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS: "ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS", # NOQA: E501 } diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 35954b170205..a55d926b4f0a 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -115,6 +115,10 @@ bool ProcessSelectorMatches(ProcessSelector aSelector) { return !!(aSelector & Module::ALLOW_IN_UTILITY_PROCESS); } + if (type == GeckoProcessType_GMPlugin) { + return !!(aSelector & Module::ALLOW_IN_GMPLUGIN_PROCESS); + } + // Only allow XPCOM modules which can be loaded in all processes to be loaded // in the IPDLUnitTest process. if (type == GeckoProcessType_IPDLUnitTest) { @@ -294,6 +298,8 @@ nsresult nsComponentManagerImpl::Init() { ProcessSelectorMatches(ProcessSelector::ALLOW_IN_SOCKET_PROCESS); gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_RDD_PROCESS)] = ProcessSelectorMatches(ProcessSelector::ALLOW_IN_RDD_PROCESS); + gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_GMPLUGIN_PROCESS)] = + ProcessSelectorMatches(ProcessSelector::ALLOW_IN_GMPLUGIN_PROCESS); gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_GPU_AND_MAIN_PROCESS)] = ProcessSelectorMatches(ProcessSelector::ALLOW_IN_GPU_AND_MAIN_PROCESS); gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_GPU_AND_VR_PROCESS)] = @@ -326,6 +332,12 @@ nsresult nsComponentManagerImpl::Init() { ProcessSelector::ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS)] = ProcessSelectorMatches( ProcessSelector::ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS); + gProcessMatchTable[size_t( + ProcessSelector:: + ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS)] = + ProcessSelectorMatches( + ProcessSelector:: + ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS); } MOZ_ASSERT(NOT_INITIALIZED == mStatus); @@ -360,7 +372,6 @@ nsresult nsComponentManagerImpl::Init() { // processes really need chrome manifests...? case GeckoProcessType_Default: case GeckoProcessType_Content: - case GeckoProcessType_GMPlugin: loadChromeManifests = true; break; } diff --git a/xpcom/ds/components.conf b/xpcom/ds/components.conf index 1b600352b3e4..c2cf35e787e7 100644 --- a/xpcom/ds/components.conf +++ b/xpcom/ds/components.conf @@ -19,6 +19,6 @@ Classes = [ 'interfaces': ['nsIObserverService'], 'legacy_constructor': 'nsObserverService::Create', 'headers': ['/xpcom/ds/nsObserverService.h'], - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS, }, ]