Initialize a subset of XPCOM in the GPU process. (bug 1294350 part 3, r=froydnj)
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/layers/ImageBridgeParent.h"
|
||||
#include "nsDebugImpl.h"
|
||||
#include "VRManager.h"
|
||||
#include "VRManagerParent.h"
|
||||
#include "VsyncBridgeParent.h"
|
||||
@@ -45,17 +46,22 @@ GPUParent::Init(base::ProcessId aParentPid,
|
||||
return false;
|
||||
}
|
||||
|
||||
nsDebugImpl::SetMultiprocessMode("GPU");
|
||||
|
||||
// Ensure gfxPrefs are initialized.
|
||||
gfxPrefs::GetSingleton();
|
||||
gfxConfig::Init();
|
||||
gfxVars::Initialize();
|
||||
gfxPlatform::InitNullMetadata();
|
||||
#if defined(XP_WIN)
|
||||
DeviceManagerD3D11::Init();
|
||||
DeviceManagerD3D9::Init();
|
||||
#endif
|
||||
if (NS_FAILED(NS_InitMinimalXPCOM())) {
|
||||
return false;
|
||||
}
|
||||
CompositorThreadHolder::Start();
|
||||
VRManager::ManagerInit();
|
||||
gfxPlatform::InitNullMetadata();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -241,6 +247,7 @@ GPUParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
gfxVars::Shutdown();
|
||||
gfxConfig::Shutdown();
|
||||
gfxPrefs::DestroySingleton();
|
||||
NS_ShutdownXPCOM(nullptr);
|
||||
XRE_ShutdownChildProcess();
|
||||
}
|
||||
|
||||
|
||||
@@ -474,6 +474,8 @@ TimeSinceProcessCreation()
|
||||
return (TimeStamp::Now() - TimeStamp::ProcessCreation(ignore)).ToMilliseconds();
|
||||
}
|
||||
|
||||
static bool sInitializedJS = false;
|
||||
|
||||
// Note that on OSX, aBinDirectory will point to .app/Contents/Resources/browser
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InitXPCOM2(nsIServiceManager** aResult,
|
||||
@@ -709,6 +711,7 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
||||
if (jsInitFailureReason) {
|
||||
NS_RUNTIMEABORT(jsInitFailureReason);
|
||||
}
|
||||
sInitializedJS = true;
|
||||
|
||||
rv = nsComponentManagerImpl::gComponentManager->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
@@ -782,6 +785,37 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InitMinimalXPCOM()
|
||||
{
|
||||
mozPoisonValueInit();
|
||||
NS_SetMainThread();
|
||||
mozilla::TimeStamp::Startup();
|
||||
NS_LogInit();
|
||||
NS_InitAtomTable();
|
||||
mozilla::LogModule::Init();
|
||||
|
||||
char aLocal;
|
||||
profiler_init(&aLocal);
|
||||
|
||||
nsresult rv = nsThreadManager::get()->Init();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Set up the timer globals/timer thread.
|
||||
rv = nsTimerImpl::Startup();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Global cycle collector initialization.
|
||||
if (!nsCycleCollector_init()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// NS_ShutdownXPCOM()
|
||||
@@ -1003,8 +1037,11 @@ ShutdownXPCOM(nsIServiceManager* aServMgr)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sInitializedJS) {
|
||||
// Shut down the JS engine.
|
||||
JS_ShutDown();
|
||||
sInitializedJS = false;
|
||||
}
|
||||
|
||||
// Release our own singletons
|
||||
// Do this _after_ shutting down the component manager, because the
|
||||
|
||||
@@ -75,6 +75,13 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
||||
nsIFile* aBinDirectory,
|
||||
nsIDirectoryServiceProvider* aAppFileLocationProvider);
|
||||
|
||||
/**
|
||||
* Initialize only minimal components of XPCOM. This ensures nsThreadManager,
|
||||
* logging, and timers will work.
|
||||
*/
|
||||
XPCOM_API(nsresult)
|
||||
NS_InitMinimalXPCOM();
|
||||
|
||||
/**
|
||||
* Shutdown XPCOM. You must call this method after you are finished
|
||||
* using xpcom.
|
||||
|
||||
Reference in New Issue
Block a user