зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1098114 - Remove ReferenceKeeperRunnable because we can release the MediaCodecReader on other thread. r=jwwang
This commit is contained in:
Родитель
41e8eeb120
Коммит
d0b453d1eb
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче