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/CompositorBridgeParent.h"
|
||||||
#include "mozilla/layers/CompositorThread.h"
|
#include "mozilla/layers/CompositorThread.h"
|
||||||
#include "mozilla/layers/ImageBridgeParent.h"
|
#include "mozilla/layers/ImageBridgeParent.h"
|
||||||
|
#include "nsDebugImpl.h"
|
||||||
#include "VRManager.h"
|
#include "VRManager.h"
|
||||||
#include "VRManagerParent.h"
|
#include "VRManagerParent.h"
|
||||||
#include "VsyncBridgeParent.h"
|
#include "VsyncBridgeParent.h"
|
||||||
@@ -45,17 +46,22 @@ GPUParent::Init(base::ProcessId aParentPid,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsDebugImpl::SetMultiprocessMode("GPU");
|
||||||
|
|
||||||
// Ensure gfxPrefs are initialized.
|
// Ensure gfxPrefs are initialized.
|
||||||
gfxPrefs::GetSingleton();
|
gfxPrefs::GetSingleton();
|
||||||
gfxConfig::Init();
|
gfxConfig::Init();
|
||||||
gfxVars::Initialize();
|
gfxVars::Initialize();
|
||||||
|
gfxPlatform::InitNullMetadata();
|
||||||
#if defined(XP_WIN)
|
#if defined(XP_WIN)
|
||||||
DeviceManagerD3D11::Init();
|
DeviceManagerD3D11::Init();
|
||||||
DeviceManagerD3D9::Init();
|
DeviceManagerD3D9::Init();
|
||||||
#endif
|
#endif
|
||||||
|
if (NS_FAILED(NS_InitMinimalXPCOM())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
CompositorThreadHolder::Start();
|
CompositorThreadHolder::Start();
|
||||||
VRManager::ManagerInit();
|
VRManager::ManagerInit();
|
||||||
gfxPlatform::InitNullMetadata();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,6 +247,7 @@ GPUParent::ActorDestroy(ActorDestroyReason aWhy)
|
|||||||
gfxVars::Shutdown();
|
gfxVars::Shutdown();
|
||||||
gfxConfig::Shutdown();
|
gfxConfig::Shutdown();
|
||||||
gfxPrefs::DestroySingleton();
|
gfxPrefs::DestroySingleton();
|
||||||
|
NS_ShutdownXPCOM(nullptr);
|
||||||
XRE_ShutdownChildProcess();
|
XRE_ShutdownChildProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -474,6 +474,8 @@ TimeSinceProcessCreation()
|
|||||||
return (TimeStamp::Now() - TimeStamp::ProcessCreation(ignore)).ToMilliseconds();
|
return (TimeStamp::Now() - TimeStamp::ProcessCreation(ignore)).ToMilliseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool sInitializedJS = false;
|
||||||
|
|
||||||
// Note that on OSX, aBinDirectory will point to .app/Contents/Resources/browser
|
// Note that on OSX, aBinDirectory will point to .app/Contents/Resources/browser
|
||||||
EXPORT_XPCOM_API(nsresult)
|
EXPORT_XPCOM_API(nsresult)
|
||||||
NS_InitXPCOM2(nsIServiceManager** aResult,
|
NS_InitXPCOM2(nsIServiceManager** aResult,
|
||||||
@@ -709,6 +711,7 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
|||||||
if (jsInitFailureReason) {
|
if (jsInitFailureReason) {
|
||||||
NS_RUNTIMEABORT(jsInitFailureReason);
|
NS_RUNTIMEABORT(jsInitFailureReason);
|
||||||
}
|
}
|
||||||
|
sInitializedJS = true;
|
||||||
|
|
||||||
rv = nsComponentManagerImpl::gComponentManager->Init();
|
rv = nsComponentManagerImpl::gComponentManager->Init();
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@@ -782,6 +785,37 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
|||||||
return NS_OK;
|
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()
|
// NS_ShutdownXPCOM()
|
||||||
@@ -1003,8 +1037,11 @@ ShutdownXPCOM(nsIServiceManager* aServMgr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Shut down the JS engine.
|
if (sInitializedJS) {
|
||||||
JS_ShutDown();
|
// Shut down the JS engine.
|
||||||
|
JS_ShutDown();
|
||||||
|
sInitializedJS = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Release our own singletons
|
// Release our own singletons
|
||||||
// Do this _after_ shutting down the component manager, because the
|
// Do this _after_ shutting down the component manager, because the
|
||||||
|
|||||||
@@ -75,6 +75,13 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
|||||||
nsIFile* aBinDirectory,
|
nsIFile* aBinDirectory,
|
||||||
nsIDirectoryServiceProvider* aAppFileLocationProvider);
|
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
|
* Shutdown XPCOM. You must call this method after you are finished
|
||||||
* using xpcom.
|
* using xpcom.
|
||||||
|
|||||||
Reference in New Issue
Block a user