Bug 1674845 - part1 : use media utils's method to get shutdown barrier. r=bryce

We've already had a same method in media utils, so no need to keep this one. In addition, doing that can prevent the build ambiguous error when removing autoplay related files from `dom/media`.

Differential Revision: https://phabricator.services.mozilla.com/D95878
This commit is contained in:
alwu 2020-11-05 04:50:16 +00:00
Родитель 9cfe871d07
Коммит 9fe8b678ad
1 изменённых файлов: 7 добавлений и 25 удалений

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

@ -4,12 +4,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Logging.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Services.h"
#include "MediaShutdownManager.h"
#include "MediaDecoder.h"
#include "MediaShutdownManager.h"
#include "mozilla/Logging.h"
#include "mozilla/media/MediaUtils.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
namespace mozilla {
@ -46,25 +47,6 @@ MediaShutdownManager& MediaShutdownManager::Instance() {
return *sInstance;
}
static nsCOMPtr<nsIAsyncShutdownClient> GetShutdownBarrier() {
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdownService();
if (!svc) {
LOGW("Failed to get shutdown service in MediaShutdownManager!");
return nullptr;
}
nsCOMPtr<nsIAsyncShutdownClient> barrier;
nsresult rv = svc->GetProfileBeforeChange(getter_AddRefs(barrier));
if (!barrier) {
// We are probably in a content process. We need to do cleanup at
// XPCOM shutdown in leakchecking builds.
rv = svc->GetXpcomWillShutdown(getter_AddRefs(barrier));
}
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
MOZ_RELEASE_ASSERT(barrier);
return barrier;
}
void MediaShutdownManager::InitStatics() {
MOZ_ASSERT(NS_IsMainThread());
if (sInitPhase != NotInited) {
@ -74,7 +56,7 @@ void MediaShutdownManager::InitStatics() {
sInstance = new MediaShutdownManager();
MOZ_DIAGNOSTIC_ASSERT(sInstance);
nsCOMPtr<nsIAsyncShutdownClient> barrier = GetShutdownBarrier();
nsCOMPtr<nsIAsyncShutdownClient> barrier = media::GetShutdownBarrier();
if (!barrier) {
LOGW("Failed to get barrier, cannot add shutdown blocker!");
@ -97,7 +79,7 @@ void MediaShutdownManager::RemoveBlocker() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(sInitPhase == XPCOMShutdownStarted);
MOZ_ASSERT(mDecoders.Count() == 0);
nsCOMPtr<nsIAsyncShutdownClient> barrier = GetShutdownBarrier();
nsCOMPtr<nsIAsyncShutdownClient> barrier = media::GetShutdownBarrier();
// xpcom should still be available because we blocked shutdown by having a
// blocker. Until it completely shuts down we should still be able to get
// the barrier.