diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 6eaad3443ed3..41f525831318 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -61,7 +61,6 @@ #include "gfxPrefs.h" #include "BackgroundChild.h" #include "mozilla/ipc/PBackgroundChild.h" -#include "nsIIPCBackgroundChildCreateCallback.h" #include "mozilla/layout/VsyncChild.h" #include "VsyncSource.h" #include "mozilla/VsyncDispatcher.h" @@ -973,47 +972,6 @@ protected: uint32_t mNextDriverIndex; }; -// The PBackground protocol connection callback. It will be called when -// PBackground is ready. Then we create the PVsync sub-protocol for our -// vsync-base RefreshTimer. -class VsyncChildCreateCallback final : public nsIIPCBackgroundChildCreateCallback -{ - NS_DECL_ISUPPORTS - -public: - VsyncChildCreateCallback() - { - MOZ_ASSERT(NS_IsMainThread()); - } - - static void CreateVsyncActor(PBackgroundChild* aPBackgroundChild) - { - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aPBackgroundChild); - - layout::PVsyncChild* actor = aPBackgroundChild->SendPVsyncConstructor(); - layout::VsyncChild* child = static_cast(actor); - nsRefreshDriver::PVsyncActorCreated(child); - } - -private: - virtual ~VsyncChildCreateCallback() = default; - - void ActorCreated(PBackgroundChild* aPBackgroundChild) override - { - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aPBackgroundChild); - CreateVsyncActor(aPBackgroundChild); - } - - void ActorFailed() override - { - MOZ_ASSERT(NS_IsMainThread()); - MOZ_CRASH("Failed To Create VsyncChild Actor"); - } -}; // VsyncChildCreateCallback -NS_IMPL_ISUPPORTS(VsyncChildCreateCallback, nsIIPCBackgroundChildCreateCallback) - } // namespace mozilla static RefreshDriverTimer* sRegularRateTimer; @@ -1026,24 +984,22 @@ CreateContentVsyncRefreshTimer(void*) MOZ_ASSERT(!XRE_IsParentProcess()); // Create the PVsync actor child for vsync-base refresh timer. - // PBackgroundChild is created asynchronously. If PBackgroundChild is still - // unavailable, setup VsyncChildCreateCallback callback to handle the async - // connect. We will still use software timer before PVsync ready, and change - // to use hw timer when the connection is done. Please check - // VsyncChildCreateCallback::CreateVsyncActor() and - // nsRefreshDriver::PVsyncActorCreated(). - PBackgroundChild* backgroundChild = BackgroundChild::GetForCurrentThread(); - if (backgroundChild) { - // If we already have PBackgroundChild, create the - // child VsyncRefreshDriverTimer here. - VsyncChildCreateCallback::CreateVsyncActor(backgroundChild); - return; - } - // Setup VsyncChildCreateCallback callback - RefPtr callback = new VsyncChildCreateCallback(); - if (NS_WARN_IF(!BackgroundChild::GetOrCreateForCurrentThread(callback))) { + // PBackgroundChild is created synchronously. We will still use software + // timer before PVsync ready, and change to use hw timer when the connection + // is done. Please check nsRefreshDriver::PVsyncActorCreated(). + + PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread(); + if (NS_WARN_IF(!actorChild)) { MOZ_CRASH("PVsync actor create failed!"); } + + layout::PVsyncChild* actor = actorChild->SendPVsyncConstructor(); + if (NS_WARN_IF(!actor)) { + MOZ_CRASH("PVsyncChild actor create failed!"); + } + + layout::VsyncChild* child = static_cast(actor); + nsRefreshDriver::PVsyncActorCreated(child); } static void