/* static */ AsyncLatencyLogger* AsyncLatencyLogger::Get(bool aStartTimer) { // Users don't generally null-check the result since we should live longer than they MOZ_ASSERT(gAsyncLogger); if (aStartTimer) { gAsyncLogger->Init(); } return gAsyncLogger; }
// static MIDIPlatformService* MIDIPlatformService::Get() { // We should never touch the platform service in a child process. MOZ_ASSERT(XRE_IsParentProcess()); AssertIsOnBackgroundThread(); if (!IsRunning()) { ErrorResult rv; // Uncomment once we have an actual platform library to test. // // bool useTestService = false; // rv = Preferences::GetRootBranch()->GetBoolPref("midi.testing", // &useTestService); gMIDIPlatformService = new TestMIDIPlatformService(); gMIDIPlatformService->Init(); } return gMIDIPlatformService; }
/* static */ nsRFPService* nsRFPService::GetOrCreate() { if (!sInitialized) { sRFPService = new nsRFPService(); nsresult rv = sRFPService->Init(); if (NS_FAILED(rv)) { sRFPService = nullptr; return nullptr; } ClearOnShutdown(&sRFPService); sInitialized = true; } return sRFPService; }
/* static */ already_AddRefed<nsPrintingProxy> nsPrintingProxy::GetInstance() { if (!sPrintingProxyInstance) { sPrintingProxyInstance = new nsPrintingProxy(); if (!sPrintingProxyInstance) { return nullptr; } nsresult rv = sPrintingProxyInstance->Init(); if (NS_FAILED(rv)) { sPrintingProxyInstance = nullptr; return nullptr; } ClearOnShutdown(&sPrintingProxyInstance); } RefPtr<nsPrintingProxy> inst = sPrintingProxyInstance.get(); return inst.forget(); }