Bug 1155268 - Add checked methods to convert from an AbstractThread to a concrete type. r=cpearce

This commit is contained in:
Bobby Holley 2015-04-20 05:29:35 -07:00
parent a2b628e20e
commit 8188a54287
4 changed files with 10 additions and 2 deletions

View File

@ -85,6 +85,8 @@ public:
return mTailDispatcher.ref();
}
virtual nsIThread* AsXPCOMThread() override { return mTarget; }
private:
nsRefPtr<nsIThread> mTarget;
Maybe<AutoTaskDispatcher> mTailDispatcher;

View File

@ -17,6 +17,7 @@
namespace mozilla {
class MediaTaskQueue;
class TaskDispatcher;
/*
@ -66,6 +67,9 @@ public:
// tasks to go through the tail dispatcher.
bool RequiresTailDispatch() const { return mRequireTailDispatch; }
virtual MediaTaskQueue* AsTaskQueue() { MOZ_CRASH("Not a task queue!"); }
virtual nsIThread* AsXPCOMThread() { MOZ_CRASH("Not an XPCOM thread!"); }
// Convenience method for getting an AbstractThread for the main thread.
static AbstractThread* MainThread();

View File

@ -42,6 +42,8 @@ public:
TaskDispatcher& TailDispatcher() override;
MediaTaskQueue* AsTaskQueue() override { return this; }
void Dispatch(already_AddRefed<nsIRunnable> aRunnable,
DispatchFailureHandling aFailureHandling = AssertDispatchSuccess,
DispatchReason aReason = NormalDispatch) override

View File

@ -241,7 +241,7 @@ EMEDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
nsRefPtr<MediaDataDecoder> emeDecoder(new EMEDecryptor(decoder,
aCallback,
mProxy,
static_cast<MediaTaskQueue*>(AbstractThread::GetCurrent())));
AbstractThread::GetCurrent()->AsTaskQueue()));
return emeDecoder.forget();
}
@ -272,7 +272,7 @@ EMEDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
nsRefPtr<MediaDataDecoder> emeDecoder(new EMEDecryptor(decoder,
aCallback,
mProxy,
static_cast<MediaTaskQueue*>(AbstractThread::GetCurrent())));
AbstractThread::GetCurrent()->AsTaskQueue()));
return emeDecoder.forget();
}