Bug 1319251 - Add more current thread assertions in VideoDecoderParent so it's more obvious about which code runs where. r=jya

--HG--
extra : rebase_source : 03abb6a3f8f0e635032ac19ea0b4168483867cb1
This commit is contained in:
Matt Woodrow 2016-11-22 21:48:21 +13:00
Родитель f9ca04b579
Коммит d3bab17663
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -54,6 +54,7 @@ VideoDecoderParent::VideoDecoderParent(VideoDecoderManagerParent* aParent,
, mDestroyed(false)
{
MOZ_COUNT_CTOR(VideoDecoderParent);
MOZ_ASSERT(OnManagerThread());
// We hold a reference to ourselves to keep us alive until IPDL
// explictly destroys us. There may still be refs held by
// tasks, but no new ones should be added after we're
@ -91,6 +92,7 @@ VideoDecoderParent::~VideoDecoderParent()
void
VideoDecoderParent::Destroy()
{
MOZ_ASSERT(OnManagerThread());
mDecodeTaskQueue->AwaitShutdownAndIdle();
mDestroyed = true;
mIPDLSelfRef = nullptr;
@ -99,6 +101,7 @@ VideoDecoderParent::Destroy()
mozilla::ipc::IPCResult
VideoDecoderParent::RecvInit()
{
MOZ_ASSERT(OnManagerThread());
RefPtr<VideoDecoderParent> self = this;
mDecoder->Init()->Then(mManagerTaskQueue, __func__,
[self] (TrackInfo::TrackType aTrack) {
@ -119,6 +122,7 @@ VideoDecoderParent::RecvInit()
mozilla::ipc::IPCResult
VideoDecoderParent::RecvInput(const MediaRawDataIPDL& aData)
{
MOZ_ASSERT(OnManagerThread());
// XXX: This copies the data into a buffer owned by the MediaRawData. Ideally we'd just take ownership
// of the shmem.
RefPtr<MediaRawData> data = new MediaRawData(aData.buffer().get<uint8_t>(), aData.buffer().Size<uint8_t>());
@ -138,6 +142,7 @@ mozilla::ipc::IPCResult
VideoDecoderParent::RecvFlush()
{
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(OnManagerThread());
if (mDecoder) {
mDecoder->Flush();
}
@ -158,6 +163,7 @@ mozilla::ipc::IPCResult
VideoDecoderParent::RecvDrain()
{
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(OnManagerThread());
mDecoder->Drain();
return IPC_OK();
}
@ -166,6 +172,7 @@ mozilla::ipc::IPCResult
VideoDecoderParent::RecvShutdown()
{
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(OnManagerThread());
if (mDecoder) {
mDecoder->Shutdown();
}
@ -177,6 +184,7 @@ mozilla::ipc::IPCResult
VideoDecoderParent::RecvSetSeekThreshold(const int64_t& aTime)
{
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(OnManagerThread());
mDecoder->SetSeekThreshold(media::TimeUnit::FromMicroseconds(aTime));
return IPC_OK();
}
@ -185,6 +193,7 @@ void
VideoDecoderParent::ActorDestroy(ActorDestroyReason aWhy)
{
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(OnManagerThread());
if (mDecoder) {
mDecoder->Shutdown();
mDecoder = nullptr;
@ -278,6 +287,12 @@ VideoDecoderParent::OnReaderTaskQueue()
// Most of our calls into mDecoder come directly from IPDL so are on
// the right thread, but not actually on the task queue. We only ever
// run a single thread, not a pool, so this should work fine.
return OnManagerThread();
}
bool
VideoDecoderParent::OnManagerThread()
{
return mParent->OnManagerThread();
}

Просмотреть файл

@ -53,6 +53,8 @@ public:
bool OnReaderTaskQueue() override;
private:
bool OnManagerThread();
~VideoDecoderParent();
RefPtr<VideoDecoderManagerParent> mParent;