зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1336345. Part 2 - some code cleanup. r=gerald
MozReview-Commit-ID: 1XHkvz4aWxB --HG-- extra : rebase_source : 5303151acf39cbd05ee07d643c834b38d99c2562 extra : source : 4367d744807385cbba96fa0d7e9250e0d6329ba6
This commit is contained in:
Родитель
b2d7143749
Коммит
4182436102
|
@ -19,8 +19,6 @@ extern LazyLogModule gMediaDecoderLog;
|
|||
NS_IMPL_ISUPPORTS(MediaShutdownManager, nsIAsyncShutdownBlocker)
|
||||
|
||||
MediaShutdownManager::MediaShutdownManager()
|
||||
: mIsObservingShutdown(false)
|
||||
, mIsDoingXPCOMShutDown(false)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
@ -83,36 +81,6 @@ MediaShutdownManager::InitStatics()
|
|||
}));
|
||||
}
|
||||
|
||||
void
|
||||
MediaShutdownManager::EnsureCorrectShutdownObserverState()
|
||||
{
|
||||
bool needShutdownObserver = mDecoders.Count() > 0;
|
||||
if (needShutdownObserver != mIsObservingShutdown) {
|
||||
mIsObservingShutdown = needShutdownObserver;
|
||||
if (mIsObservingShutdown) {
|
||||
nsresult rv = GetShutdownBarrier()->AddBlocker(
|
||||
this, NS_LITERAL_STRING(__FILE__), __LINE__,
|
||||
NS_LITERAL_STRING("MediaShutdownManager shutdown"));
|
||||
if (NS_FAILED(rv)) {
|
||||
// Leak the buffer on the heap to make sure that it lives long enough,
|
||||
// as MOZ_CRASH_ANNOTATE expects the pointer passed to it to live to
|
||||
// the end of the program.
|
||||
const size_t CAPACITY = 256;
|
||||
auto buf = new char[CAPACITY];
|
||||
snprintf(buf, CAPACITY, "Failed to add shutdown blocker! rv=%x", uint32_t(rv));
|
||||
MOZ_CRASH_ANNOTATE(buf);
|
||||
MOZ_REALLY_CRASH();
|
||||
}
|
||||
} else {
|
||||
GetShutdownBarrier()->RemoveBlocker(this);
|
||||
// Clear our singleton reference. This will probably delete
|
||||
// this instance, so don't deref |this| clearing sInstance.
|
||||
sInstance = nullptr;
|
||||
DECODER_LOG(LogLevel::Debug, ("MediaShutdownManager::BlockShutdown() end."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MediaShutdownManager::RemoveBlocker()
|
||||
{
|
||||
|
|
|
@ -75,10 +75,6 @@ private:
|
|||
virtual ~MediaShutdownManager();
|
||||
void RemoveBlocker();
|
||||
|
||||
// Ensures we have a shutdown listener if we need one, and removes the
|
||||
// listener and destroys the singleton if we don't.
|
||||
void EnsureCorrectShutdownObserverState();
|
||||
|
||||
static StaticRefPtr<MediaShutdownManager> sInstance;
|
||||
|
||||
// References to the MediaDecoder. The decoders unregister themselves
|
||||
|
@ -86,10 +82,7 @@ private:
|
|||
// we're shutting down (in the non xpcom-shutdown case).
|
||||
nsTHashtable<nsRefPtrHashKey<MediaDecoder>> mDecoders;
|
||||
|
||||
// True if we have an XPCOM shutdown observer.
|
||||
bool mIsObservingShutdown;
|
||||
|
||||
bool mIsDoingXPCOMShutDown;
|
||||
bool mIsDoingXPCOMShutDown = false;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче