Bug 1593843 - part8 : move helper functions out from 'AutoplayPolicy'. r=bryce

Move helper functions out from `AutoplayPolicy`, makes us clearly know which one could really be used to determine the blocking autoplay result. It also give other classes an ability to use those helper functions if they have a need.

Differential Revision: https://phabricator.services.mozilla.com/D52432
This commit is contained in:
alwu
2019-11-25 11:00:13 +00:00
parent 3e631342b1
commit c193817ea1
4 changed files with 27 additions and 16 deletions

View File

@@ -4143,7 +4143,8 @@ void HTMLMediaElement::UpdateHadAudibleAutoplayState() {
if ((Volume() > 0.0 && !Muted()) &&
(!OwnerDoc()->HasBeenUserGestureActivated() || Autoplay())) {
OwnerDoc()->SetDocTreeHadAudibleMedia();
if (AutoplayPolicy::WouldBeAllowedToPlayIfAutoplayDisabled(*this)) {
if (AutoplayPolicyTelemetryUtils::WouldBeAllowedToPlayIfAutoplayDisabled(
*this)) {
ScalarAdd(Telemetry::ScalarID::MEDIA_AUTOPLAY_WOULD_BE_ALLOWED_COUNT, 1);
} else {
ScalarAdd(Telemetry::ScalarID::MEDIA_AUTOPLAY_WOULD_NOT_BE_ALLOWED_COUNT,