Bug 1295352 - Release MediaEngineTabVideoSource main-thread-only members on main thread. r=jesup

MozReview-Commit-ID: H3N70b9tGiI

--HG--
extra : rebase_source : e8dd9562fcf0cfe3d37987947ab85f0ac1ef66a3
extra : intermediate-source : 57f7b75e5a6210ba05e58cb6a117151e1d25f29e
extra : source : 5a2bbbf8ce4b6afc4e3649ce9ca5786aac4b5336
This commit is contained in:
Andreas Pehrson 2016-08-30 14:17:59 +02:00
Родитель aafd1d4711
Коммит 24b498b985
2 изменённых файлов: 20 добавлений и 0 удалений

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

@ -119,6 +119,17 @@ MediaEngineTabVideoSource::InitRunnable::Run()
return NS_OK; return NS_OK;
} }
nsresult
MediaEngineTabVideoSource::DestroyRunnable::Run()
{
MOZ_ASSERT(NS_IsMainThread());
mVideoSource->mWindow = nullptr;
mVideoSource->mTabSource = nullptr;
return NS_OK;
}
void void
MediaEngineTabVideoSource::GetName(nsAString_internal& aName) const MediaEngineTabVideoSource::GetName(nsAString_internal& aName) const
{ {
@ -193,6 +204,8 @@ nsresult
MediaEngineTabVideoSource::Deallocate(AllocationHandle* aHandle) MediaEngineTabVideoSource::Deallocate(AllocationHandle* aHandle)
{ {
MOZ_ASSERT(!aHandle); MOZ_ASSERT(!aHandle);
NS_DispatchToMainThread(do_AddRef(new DestroyRunnable(this)));
{ {
MonitorAutoLock mon(mMonitor); MonitorAutoLock mon(mMonitor);
mState = kReleased; mState = kReleased;

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

@ -81,6 +81,13 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
RefPtr<MediaEngineTabVideoSource> mVideoSource; RefPtr<MediaEngineTabVideoSource> mVideoSource;
}; };
class DestroyRunnable : public Runnable {
public:
explicit DestroyRunnable(MediaEngineTabVideoSource* videoSource) : mVideoSource(videoSource) {}
NS_IMETHOD Run();
RefPtr<MediaEngineTabVideoSource> mVideoSource;
};
protected: protected:
~MediaEngineTabVideoSource() {} ~MediaEngineTabVideoSource() {}