From 6ec5a5564310ea845b2330fad48421444a45809b Mon Sep 17 00:00:00 2001 From: JW Wang Date: Mon, 20 Jul 2015 14:07:25 +0800 Subject: [PATCH] Bug 1184460 - Remove sync dispatch since SharedThreadPool::Get() can be called off the main thread. r=cpearce. --- dom/media/VideoUtils.cpp | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/dom/media/VideoUtils.cpp b/dom/media/VideoUtils.cpp index 9e03501c0bba..c485b4f14268 100644 --- a/dom/media/VideoUtils.cpp +++ b/dom/media/VideoUtils.cpp @@ -322,46 +322,20 @@ GenerateRandomPathName(nsCString& aOutSalt, uint32_t aLength) return NS_OK; } -class CreateTaskQueueTask : public nsRunnable { -public: - NS_IMETHOD Run() { - MOZ_ASSERT(NS_IsMainThread()); - mTaskQueue = - new TaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)); - return NS_OK; - } - nsRefPtr mTaskQueue; -}; - -class CreateFlushableTaskQueueTask : public nsRunnable { -public: - NS_IMETHOD Run() { - MOZ_ASSERT(NS_IsMainThread()); - mTaskQueue = - new FlushableTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)); - return NS_OK; - } - nsRefPtr mTaskQueue; -}; - already_AddRefed CreateMediaDecodeTaskQueue() { - // We must create the TaskQueue/SharedThreadPool on the main thread. - nsRefPtr t(new CreateTaskQueueTask()); - nsresult rv = NS_DispatchToMainThread(t, NS_DISPATCH_SYNC); - NS_ENSURE_SUCCESS(rv, nullptr); - return t->mTaskQueue.forget(); + nsRefPtr queue = new TaskQueue( + GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)); + return queue.forget(); } already_AddRefed CreateFlushableMediaDecodeTaskQueue() { - // We must create the TaskQueue/SharedThreadPool on the main thread. - nsRefPtr t(new CreateFlushableTaskQueueTask()); - nsresult rv = NS_DispatchToMainThread(t, NS_DISPATCH_SYNC); - NS_ENSURE_SUCCESS(rv, nullptr); - return t->mTaskQueue.forget(); + nsRefPtr queue = new FlushableTaskQueue( + GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)); + return queue.forget(); } } // end namespace mozilla