From 9451263fdea2b5337466247062dc29d874ddb02d Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Mon, 13 Apr 2015 22:08:47 -0700 Subject: [PATCH] Bug 1154782 - Detemplatize nsIThread wrapper and move it into AbstractThread.cpp. r=jww --- dom/media/AbstractThread.cpp | 37 ++++++++++++++++++++---------------- dom/media/AbstractThread.h | 11 ----------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/dom/media/AbstractThread.cpp b/dom/media/AbstractThread.cpp index cc9741586b55..2eb19ee05315 100644 --- a/dom/media/AbstractThread.cpp +++ b/dom/media/AbstractThread.cpp @@ -16,23 +16,28 @@ namespace mozilla { StaticRefPtr sMainThread; -template<> -nsresult -AbstractThreadImpl::Dispatch(already_AddRefed aRunnable) +class XPCOMThreadWrapper : public AbstractThread { - MediaTaskQueue::AssertInTailDispatchIfNeeded(); - nsCOMPtr r = aRunnable; - return mTarget->Dispatch(r, NS_DISPATCH_NORMAL); -} +public: + explicit XPCOMThreadWrapper(nsIThread* aTarget) : mTarget(aTarget) {} -template<> -bool -AbstractThreadImpl::IsCurrentThreadIn() -{ - bool in = NS_GetCurrentThread() == mTarget; - MOZ_ASSERT_IF(in, MediaTaskQueue::GetCurrentQueue() == nullptr); - return in; -} + virtual nsresult Dispatch(already_AddRefed aRunnable) override + { + MediaTaskQueue::AssertInTailDispatchIfNeeded(); + nsCOMPtr r = aRunnable; + return mTarget->Dispatch(r, NS_DISPATCH_NORMAL); + } + + virtual bool IsCurrentThreadIn() override + { + bool in = NS_GetCurrentThread() == mTarget; + MOZ_ASSERT_IF(in, MediaTaskQueue::GetCurrentQueue() == nullptr); + return in; + } + +private: + nsRefPtr mTarget; +}; void AbstractThread::MaybeTailDispatch(already_AddRefed aRunnable, @@ -64,7 +69,7 @@ AbstractThread::InitStatics() nsCOMPtr mainThread; NS_GetMainThread(getter_AddRefs(mainThread)); MOZ_DIAGNOSTIC_ASSERT(mainThread); - sMainThread = new AbstractThreadImpl(mainThread.get()); + sMainThread = new XPCOMThreadWrapper(mainThread.get()); ClearOnShutdown(&sMainThread); } diff --git a/dom/media/AbstractThread.h b/dom/media/AbstractThread.h index e1f7b5eeb5b7..d512773d9c8f 100644 --- a/dom/media/AbstractThread.h +++ b/dom/media/AbstractThread.h @@ -50,17 +50,6 @@ protected: virtual ~AbstractThread() {} }; -template -class AbstractThreadImpl : public AbstractThread -{ -public: - explicit AbstractThreadImpl(TargetType* aTarget) : mTarget(aTarget) {} - virtual nsresult Dispatch(already_AddRefed aRunnable); - virtual bool IsCurrentThreadIn(); -private: - nsRefPtr mTarget; -}; - } // namespace mozilla #endif