Bug 1098114 - Remove ReferenceKeeperRunnable because we can release the MediaCodecReader on other thread. r=jwwang

This commit is contained in:
Benjamin Chen 2014-11-17 14:28:10 +08:00
parent 0b69a07e40
commit e88c9496c8
2 changed files with 0 additions and 36 deletions

View File

@ -282,10 +282,6 @@ void
MediaCodecReader::ProcessCachedDataTask::Run()
{
mReader->ProcessCachedData(mOffset, nullptr);
nsRefPtr<ReferenceKeeperRunnable<MediaCodecReader>> runnable(
new ReferenceKeeperRunnable<MediaCodecReader>(mReader));
mReader = nullptr;
NS_DispatchToMainThread(runnable.get());
}
MediaCodecReader::MediaCodecReader(AbstractMediaDecoder* aDecoder)
@ -305,7 +301,6 @@ MediaCodecReader::MediaCodecReader(AbstractMediaDecoder* aDecoder)
MediaCodecReader::~MediaCodecReader()
{
MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread.");
}
nsresult

View File

@ -338,37 +338,6 @@ private:
};
friend class ProcessCachedDataTask;
// This class is used to keep one reference count of T in it. And this class
// can make sure the stored reference count will be released on the dispatched
// thread. By using this class properly (ex. passing the pointer into this
// runnable first, then releasing the original pointer held by ourselves, and
// then dispatching this runnable onto the desired thread), we can avoid
// running the destructor of the referenced object on any other threads
// unexpectedly before this runnable has been executed.
template<class T>
class ReferenceKeeperRunnable : public nsRunnable
{
public:
ReferenceKeeperRunnable(nsRefPtr<T> aPointer)
: mPointer(aPointer)
{
}
NS_IMETHOD Run() MOZ_OVERRIDE
{
mPointer = nullptr;
return NS_OK;
}
private:
// Forbidden
ReferenceKeeperRunnable() MOZ_DELETE;
ReferenceKeeperRunnable(const ReferenceKeeperRunnable &rhs) MOZ_DELETE;
const ReferenceKeeperRunnable &operator=(const ReferenceKeeperRunnable &rhs) MOZ_DELETE;
nsRefPtr<T> mPointer;
};
// Forbidden
MediaCodecReader() MOZ_DELETE;
const MediaCodecReader& operator=(const MediaCodecReader& rhs) MOZ_DELETE;