зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1216972 - MediaManager AsyncShutdown for content processes. r=jesup
--HG-- extra : transplant_source : %D9%A4%C4%95%EB%F9%0Fh%83z%21%91A5cu7%B4%DF%DE
This commit is contained in:
Родитель
a775946746
Коммит
0da8936844
|
@ -98,6 +98,23 @@ struct nsIMediaDevice::COMTypeInfo<mozilla::AudioDevice, void> {
|
|||
};
|
||||
const nsIID nsIMediaDevice::COMTypeInfo<mozilla::AudioDevice, void>::kIID = NS_IMEDIADEVICE_IID;
|
||||
|
||||
namespace {
|
||||
already_AddRefed<nsIAsyncShutdownClient> GetShutdownPhase() {
|
||||
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
|
||||
MOZ_RELEASE_ASSERT(svc);
|
||||
|
||||
nsCOMPtr<nsIAsyncShutdownClient> shutdownPhase;
|
||||
nsresult rv = svc->GetProfileBeforeChange(getter_AddRefs(shutdownPhase));
|
||||
if (!shutdownPhase) {
|
||||
// We are probably in a content process.
|
||||
rv = svc->GetContentChildShutdown(getter_AddRefs(shutdownPhase));
|
||||
}
|
||||
MOZ_RELEASE_ASSERT(shutdownPhase);
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
return shutdownPhase.forget();
|
||||
}
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
#ifdef LOG
|
||||
|
@ -1560,13 +1577,7 @@ MediaManager::Get() {
|
|||
|
||||
// Prepare async shutdown
|
||||
|
||||
nsCOMPtr<nsIAsyncShutdownClient> profileBeforeChange;
|
||||
{
|
||||
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
|
||||
MOZ_RELEASE_ASSERT(svc);
|
||||
nsresult rv = svc->GetProfileBeforeChange(getter_AddRefs(profileBeforeChange));
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
nsCOMPtr<nsIAsyncShutdownClient> shutdownPhase = GetShutdownPhase();
|
||||
|
||||
class Blocker : public media::ShutdownBlocker
|
||||
{
|
||||
|
@ -1575,7 +1586,7 @@ MediaManager::Get() {
|
|||
: media::ShutdownBlocker(NS_LITERAL_STRING(
|
||||
"Media shutdown: blocking on media thread")) {}
|
||||
|
||||
NS_IMETHOD BlockShutdown(nsIAsyncShutdownClient* aProfileBeforeChange) override
|
||||
NS_IMETHOD BlockShutdown(nsIAsyncShutdownClient*) override
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(MediaManager::GetIfExists());
|
||||
MediaManager::GetIfExists()->Shutdown();
|
||||
|
@ -1584,10 +1595,10 @@ MediaManager::Get() {
|
|||
};
|
||||
|
||||
sSingleton->mShutdownBlocker = new Blocker();
|
||||
nsresult rv = profileBeforeChange->AddBlocker(sSingleton->mShutdownBlocker,
|
||||
NS_LITERAL_STRING(__FILE__),
|
||||
__LINE__,
|
||||
NS_LITERAL_STRING("Media shutdown"));
|
||||
nsresult rv = shutdownPhase->AddBlocker(sSingleton->mShutdownBlocker,
|
||||
NS_LITERAL_STRING(__FILE__),
|
||||
__LINE__,
|
||||
NS_LITERAL_STRING("Media shutdown"));
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#ifdef MOZ_B2G
|
||||
// Init MediaPermissionManager before sending out any permission requests.
|
||||
|
@ -2654,14 +2665,8 @@ MediaManager::Shutdown()
|
|||
|
||||
// Remove async shutdown blocker
|
||||
|
||||
nsCOMPtr<nsIAsyncShutdownClient> profileBeforeChange;
|
||||
{
|
||||
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
|
||||
MOZ_RELEASE_ASSERT(svc);
|
||||
nsresult rv = svc->GetProfileBeforeChange(getter_AddRefs(profileBeforeChange));
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
profileBeforeChange->RemoveBlocker(sSingleton->mShutdownBlocker);
|
||||
nsCOMPtr<nsIAsyncShutdownClient> shutdownPhase = GetShutdownPhase();
|
||||
shutdownPhase->RemoveBlocker(sSingleton->mShutdownBlocker);
|
||||
|
||||
// we hold a ref to 'that' which is the same as sSingleton
|
||||
sSingleton = nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче