Skip to content

Commit

Permalink
Bug 1845946 - Part 2. Add plumbing for component services to be used …
Browse files Browse the repository at this point in the history
…in the GMP process. r=emilio,geckoview-reviewers,owlish

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
  • Loading branch information
aosmond committed Aug 18, 2023
1 parent 6718d67 commit 00188ff
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 16 deletions.
2 changes: 1 addition & 1 deletion modules/libpref/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/telemetry/core/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
]
2 changes: 1 addition & 1 deletion widget/android/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Classes = [
'contract_ids': ['@mozilla.org/widget/appshell/android;1'],
'legacy_constructor': 'nsAppShellConstructor',
'headers': ['/widget/android/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': '{d594094c-28b6-466b-97d7-66c039c3dea9}',
Expand Down
2 changes: 1 addition & 1 deletion widget/cocoa/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down
2 changes: 1 addition & 1 deletion widget/gtk/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down
2 changes: 1 addition & 1 deletion widget/windows/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down
2 changes: 1 addition & 1 deletion xpcom/build/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down
17 changes: 11 additions & 6 deletions xpcom/components/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 =
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xpcom/components/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
]
10 changes: 10 additions & 0 deletions xpcom/components/gen_static_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -114,6 +123,7 @@ class ProcessSelector:
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
}


Expand Down
13 changes: 12 additions & 1 deletion xpcom/components/nsComponentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)] =
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -360,7 +372,6 @@ nsresult nsComponentManagerImpl::Init() {
// processes really need chrome manifests...?
case GeckoProcessType_Default:
case GeckoProcessType_Content:
case GeckoProcessType_GMPlugin:
loadChromeManifests = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion xpcom/ds/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
]

0 comments on commit 00188ff

Please sign in to comment.