diff --git a/dom/media/eme/mediafoundation/WMFCDMImpl.cpp b/dom/media/eme/mediafoundation/WMFCDMImpl.cpp index 0af18f9aebfe..2192e976c104 100644 --- a/dom/media/eme/mediafoundation/WMFCDMImpl.cpp +++ b/dom/media/eme/mediafoundation/WMFCDMImpl.cpp @@ -15,6 +15,24 @@ include " mozilla / +AppShutdown +. +h +" +# +include +" +mozilla +/ +ClearOnShutdown +. +h +" +# +include +" +mozilla +/ dom / MediaKeySession @@ -47,6 +65,31 @@ nsAString aKeySystem ) { +MOZ_ASSERT +( +NS_IsMainThread +( +) +) +; +if +( +AppShutdown +: +: +IsInOrBeyond +( +ShutdownPhase +: +: +AppShutdownConfirmed +) +) +{ +return +false +; +} static std : @@ -56,8 +99,67 @@ map nsString bool > -supports +sSupports +; +static +bool +sSetRunOnShutdown += +false ; +if +( +! +sSetRunOnShutdown +) +{ +GetMainThreadSerialEventTarget +( +) +- +> +Dispatch +( +NS_NewRunnableFunction +( +" +WMFCDMImpl +: +: +Supports +" +[ +& +] +{ +RunOnShutdown +( +[ +& +] +{ +sSupports +. +clear +( +) +; +} +ShutdownPhase +: +: +XPCOMShutdown +) +; +} +) +) +; +sSetRunOnShutdown += +true +; +} nsString key ( @@ -71,7 +173,7 @@ auto & s = -supports +sSupports . find ( @@ -81,7 +183,7 @@ key s ! = -supports +sSupports . end ( @@ -126,7 +228,7 @@ GetCapabilities configs ) ; -supports +sSupports [ key ] @@ -151,21 +253,31 @@ KeySystemConfig aOutConfigs ) { -nsCOMPtr -< -nsISerialEventTarget -> -backgroundTaskQueue +MOZ_ASSERT +( +NS_IsMainThread +( +) +) ; -NS_CreateBackgroundTaskQueue +if ( -__func__ -getter_AddRefs +AppShutdown +: +: +IsInOrBeyond ( -backgroundTaskQueue +ShutdownPhase +: +: +AppShutdownConfirmed ) ) +{ +return +false ; +} static std : @@ -185,6 +297,65 @@ sKeySystemConfigs { } ; +static +bool +sSetRunOnShutdown += +false +; +if +( +! +sSetRunOnShutdown +) +{ +GetMainThreadSerialEventTarget +( +) +- +> +Dispatch +( +NS_NewRunnableFunction +( +" +WMFCDMImpl +: +: +GetCapabilities +" +[ +& +] +{ +RunOnShutdown +( +[ +& +] +{ +sKeySystemConfigs +. +clear +( +) +; +} +ShutdownPhase +: +: +XPCOMShutdown +) +; +} +) +) +; +sSetRunOnShutdown += +true +; +} auto keySystem = @@ -292,6 +463,21 @@ return true ; } +nsCOMPtr +< +nsISerialEventTarget +> +backgroundTaskQueue +; +NS_CreateBackgroundTaskQueue +( +__func__ +getter_AddRefs +( +backgroundTaskQueue +) +) +; if ( !