Enable nsComponentManager in the GPU process. (bug 1294350 part 4, r=nfroyd)

This commit is contained in:
David Anderson 2016-08-22 22:57:36 -07:00
Родитель 3f96d36cdd
Коммит 9495e20273
3 изменённых файлов: 90 добавлений и 57 удалений

Просмотреть файл

@ -809,6 +809,16 @@ NS_InitMinimalXPCOM()
return rv;
}
// Create the Component/Service Manager
nsComponentManagerImpl::gComponentManager = new nsComponentManagerImpl();
NS_ADDREF(nsComponentManagerImpl::gComponentManager);
rv = nsComponentManagerImpl::gComponentManager->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(nsComponentManagerImpl::gComponentManager);
return rv;
}
// Global cycle collector initialization.
if (!nsCycleCollector_init()) {
return NS_ERROR_UNEXPECTED;

Просмотреть файл

@ -38,13 +38,20 @@ struct Module
/**
* This selector allows CIDEntrys to be marked so that they're only loaded
* into certain kinds of processes.
* into certain kinds of processes. Selectors can be combined.
*/
enum ProcessSelector
{
ANY_PROCESS = 0,
MAIN_PROCESS_ONLY,
CONTENT_PROCESS_ONLY
ANY_PROCESS = 0x0,
MAIN_PROCESS_ONLY = 0x1,
CONTENT_PROCESS_ONLY = 0x2,
/**
* 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
};
/**
@ -113,6 +120,12 @@ struct Module
*/
LoadFuncPtr loadProc;
UnloadFuncPtr unloadProc;
/**
* Optional flags which control whether the module loads on a process-type
* basis.
*/
ProcessSelector selector;
};
} // namespace mozilla

Просмотреть файл

@ -356,6 +356,8 @@ nsComponentManagerImpl::Init()
RegisterModule((*sStaticModules)[i], nullptr);
}
bool loadChromeManifests = (XRE_GetProcessType() != GeckoProcessType_GPU);
if (loadChromeManifests) {
// The overall order in which chrome.manifests are expected to be treated
// is the following:
// - greDir
@ -396,6 +398,7 @@ nsComponentManagerImpl::Init()
}
RereadChromeManifests(false);
}
nsCategoryManager::GetSingleton()->SuppressNotifications(false);
@ -429,12 +432,37 @@ nsComponentManagerImpl::Init()
return NS_OK;
}
static bool
ProcessSelectorMatches(Module::ProcessSelector aSelector)
{
GeckoProcessType type = XRE_GetProcessType();
if (type == GeckoProcessType_GPU) {
return !!(aSelector & Module::ALLOW_IN_GPU_PROCESS);
}
if (aSelector & Module::MAIN_PROCESS_ONLY) {
return type == GeckoProcessType_Default;
}
if (aSelector & Module::CONTENT_PROCESS_ONLY) {
return type == GeckoProcessType_Content;
}
return true;
}
static const int kModuleVersionWithSelector = 51;
void
nsComponentManagerImpl::RegisterModule(const mozilla::Module* aModule,
FileLocation* aFile)
{
mLock.AssertNotCurrentThreadOwns();
if (aModule->mVersion >= kModuleVersionWithSelector &&
!ProcessSelectorMatches(aModule->selector))
{
return;
}
{
// Scope the monitor so that we don't hold it while calling into the
// category manager.
@ -479,24 +507,6 @@ nsComponentManagerImpl::RegisterModule(const mozilla::Module* aModule,
}
}
static bool
ProcessSelectorMatches(Module::ProcessSelector aSelector)
{
if (aSelector == Module::ANY_PROCESS) {
return true;
}
GeckoProcessType type = XRE_GetProcessType();
switch (aSelector) {
case Module::MAIN_PROCESS_ONLY:
return type == GeckoProcessType_Default;
case Module::CONTENT_PROCESS_ONLY:
return type == GeckoProcessType_Content;
default:
MOZ_CRASH("invalid process aSelector");
}
}
void
nsComponentManagerImpl::RegisterCIDEntryLocked(
const mozilla::Module::CIDEntry* aEntry,