Bug 882718 - Do not dispatch task to main thread when shutdown. r=rillian

MozReview-Commit-ID: 5Y79Fbhyoc3
This commit is contained in:
bechen
2016-06-01 15:13:45 +08:00
parent b3a670e7fd
commit 7a60c08ea5
2 changed files with 41 additions and 1 deletions

View File

@@ -22,6 +22,8 @@
namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS(TextTrackManager::ShutdownObserverProxy, nsIObserver);
CompareTextTracks::CompareTextTracks(HTMLMediaElement* aMediaElement)
{
mMediaElement = aMediaElement;
@@ -94,6 +96,7 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
, mLastTimeMarchesOnCalled(0.0)
, mTimeMarchesOnDispatched(false)
, performedTrackSelection(false)
, mShutdown(false)
{
nsISupports* parentObject =
mMediaElement->OwnerDoc()->GetParentObject();
@@ -112,10 +115,12 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
sParserWrapper = parserWrapper;
ClearOnShutdown(&sParserWrapper);
}
mShutdownProxy = new ShutdownObserverProxy(this);
}
TextTrackManager::~TextTrackManager()
{
nsContentUtils::UnregisterShutdownObserver(mShutdownProxy);
}
TextTrackList*
@@ -512,7 +517,7 @@ TextTrackManager::DispatchTimeMarchesOn()
// enqueue the current playback position and whether only that changed
// through its usual monotonic increase during normal playback; current
// executing call upon completion will check queue for further 'work'.
if (!mTimeMarchesOnDispatched) {
if (!mTimeMarchesOnDispatched && !mShutdown) {
NS_DispatchToMainThread(NewRunnableMethod(this, &TextTrackManager::TimeMarchesOn));
mTimeMarchesOnDispatched = true;
}