Bug 1343459. Part 1 - Label runnables under dom/media/mediasource. r?jya
MozReview-Commit-ID: 5lJUZXWFH8u
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -518,17 +518,17 @@ MediaSource::DispatchSimpleEvent(const c
DispatchTrustedEvent(NS_ConvertUTF8toUTF16(aName));
}
void
MediaSource::QueueAsyncSimpleEvent(const char* aName)
{
MSE_DEBUG("Queuing event '%s'", aName);
nsCOMPtr<nsIRunnable> event = new AsyncEventRunner<MediaSource>(this, aName);
- NS_DispatchToMainThread(event);
+ mAbstractMainThread->Dispatch(event.forget());
}
void
MediaSource::DurationChange(double aNewDuration, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_DEBUG("DurationChange(aNewDuration=%f)", aNewDuration);
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -354,17 +354,17 @@ SourceBuffer::DispatchSimpleEvent(const
DispatchTrustedEvent(NS_ConvertUTF8toUTF16(aName));
}
void
SourceBuffer::QueueAsyncSimpleEvent(const char* aName)
{
MSE_DEBUG("Queuing event '%s'", aName);
nsCOMPtr<nsIRunnable> event = new AsyncEventRunner<SourceBuffer>(this, aName);
- NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
+ mAbstractMainThread->Dispatch(event.forget());
}
void
SourceBuffer::StartUpdating()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mUpdating);
mUpdating = true;
--- a/dom/media/mediasource/SourceBufferList.cpp
+++ b/dom/media/mediasource/SourceBufferList.cpp
@@ -158,22 +158,23 @@ SourceBufferList::DispatchSimpleEvent(co
DispatchTrustedEvent(NS_ConvertUTF8toUTF16(aName));
}
void
SourceBufferList::QueueAsyncSimpleEvent(const char* aName)
{
MSE_DEBUG("Queue event '%s'", aName);
nsCOMPtr<nsIRunnable> event = new AsyncEventRunner<SourceBufferList>(this, aName);
- NS_DispatchToMainThread(event);
+ mAbstractMainThread->Dispatch(event.forget());
}
SourceBufferList::SourceBufferList(MediaSource* aMediaSource)
: DOMEventTargetHelper(aMediaSource->GetParentObject())
, mMediaSource(aMediaSource)
+ , mAbstractMainThread(mMediaSource->AbstractMainThread())
{
MOZ_ASSERT(aMediaSource);
}
MediaSource*
SourceBufferList::GetParentObject() const
{
return mMediaSource;
--- a/dom/media/mediasource/SourceBufferList.h
+++ b/dom/media/mediasource/SourceBufferList.h
@@ -92,15 +92,16 @@ private:
~SourceBufferList();
friend class AsyncEventRunner<SourceBufferList>;
void DispatchSimpleEvent(const char* aName);
void QueueAsyncSimpleEvent(const char* aName);
RefPtr<MediaSource> mMediaSource;
nsTArray<RefPtr<SourceBuffer> > mSourceBuffers;
+ const RefPtr<AbstractThread> mAbstractMainThread;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_SourceBufferList_h_ */
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -1086,19 +1086,20 @@ TrackBuffersManager::OnDemuxerInitDone(n
mAudioTracks.mLastInfo = new TrackInfoSharedPtr(info.mAudio, streamID);
mVideoTracks.mLastInfo = new TrackInfoSharedPtr(info.mVideo, streamID);
}
UniquePtr<EncryptionInfo> crypto = mInputDemuxer->GetCrypto();
if (crypto && crypto->IsEncrypted()) {
// Try and dispatch 'encrypted'. Won't go if ready state still HAVE_NOTHING.
for (uint32_t i = 0; i < crypto->mInitDatas.Length(); i++) {
- NS_DispatchToMainThread(
+ nsCOMPtr<nsIRunnable> r =
new DispatchKeyNeededEvent(mParentDecoder, crypto->mInitDatas[i].mInitData,
- crypto->mInitDatas[i].mType));
+ crypto->mInitDatas[i].mType);
+ mAbstractMainThread->Dispatch(r.forget());
}
info.mCrypto = *crypto;
// We clear our crypto init data array, so the MediaFormatReader will
// not emit an encrypted event for the same init data again.
info.mCrypto.mInitDatas.Clear();
}
{