Bug 1336356 - Ensure MediaDecode::Shutdown() is called by MediaShutdownManager::BlockShutdown(). r=gerald

MozReview-Commit-ID: 80AFMafXoeB

--HG--
extra : rebase_source : 8b51b6c9fe4b83b4639c7ae081854307c4308391
extra : source : 7ca33be035c12485e0d6529c529b0cda914fd405
This commit is contained in:
JW Wang 2017-02-03 17:12:38 +08:00
Родитель 049e9128c4
Коммит f40aaeaffc
4 изменённых файлов: 23 добавлений и 7 удалений

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

@ -523,6 +523,22 @@ MediaDecoder::Shutdown()
mOwner = nullptr;
}
void
MediaDecoder::NotifyXPCOMShutdown()
{
MOZ_ASSERT(NS_IsMainThread());
if (auto owner = GetOwner()) {
owner->NotifyXPCOMShutdown();
}
MOZ_DIAGNOSTIC_ASSERT(IsShutdown());
// Don't cause grief to release builds by ensuring Shutdown()
// is always called during shutdown phase.
if (!IsShutdown()) {
Shutdown();
}
}
MediaDecoder::~MediaDecoder()
{
MOZ_ASSERT(NS_IsMainThread());

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

@ -134,6 +134,11 @@ public:
// thread by the owning object before that object disposes of this object.
virtual void Shutdown();
// Notified by the shutdown manager that XPCOM shutdown has begun.
// The decoder should notify its owner to drop the reference to the decoder
// to prevent further calls into the decoder.
void NotifyXPCOMShutdown();
// Start downloading the media. Decode the downloaded data up to the
// point of the first frame of data.
// This is called at most once per decoder, after Init().

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

@ -142,7 +142,7 @@ public:
// Called by media decoder when the audible state changed
virtual void SetAudibleState(bool aAudible) = 0;
// Notified by the shutdown manager that XPCOM shutdown has begun.
// Notified by the decoder that XPCOM shutdown has begun.
// The decoder owner should call Shutdown() on the decoder and drop the
// reference to the decoder to prevent further calls into the decoder.
virtual void NotifyXPCOMShutdown() = 0;

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

@ -154,12 +154,7 @@ MediaShutdownManager::BlockShutdown(nsIAsyncShutdownClient*)
// Iterate over the decoders and shut them down.
for (auto iter = mDecoders.Iter(); !iter.Done(); iter.Next()) {
MediaDecoderOwner* owner = iter.Get()->GetKey()->GetOwner();
if (owner) {
// The owner will call MediaDecoder::Shutdown() and
// drop its reference to the decoder.
owner->NotifyXPCOMShutdown();
}
iter.Get()->GetKey()->NotifyXPCOMShutdown();
// Check MediaDecoder::Shutdown doesn't call Unregister() synchronously in
// order not to corrupt our hashtable traversal.
MOZ_ASSERT(mDecoders.Count() == oldCount);