Bug 1668139 - part2 : add a telemetry probe to know how many actions are handled by default handler or media session handler. r=chunmin

It would be good for us to know how many websites actually use MediaSession API to control (play/pause/stop) their media playback, an how many websites use our default handler.

Differential Revision: https://phabricator.services.mozilla.com/D93283
This commit is contained in:
alwu 2020-10-13 22:42:59 +00:00
parent 32fa7ff7fb
commit 873f48060e
3 changed files with 27 additions and 0 deletions

View File

@ -10,6 +10,7 @@
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "nsDataHashtable.h"
#include "nsGlobalWindowOuter.h"
@ -328,6 +329,9 @@ void ContentMediaController::HandleMediaKey(MediaControlKey aKey) {
}
LOG("Handle '%s' event, receiver num=%zu", ToMediaControlKeyStr(aKey),
mReceivers.Length());
AccumulateCategorical(
mozilla::Telemetry::LABELS_MEDIA_CONTROL_HANDLE_PLAY_PAUSE_STOP_ACTIONS::
DefaultHandler);
// We have default handlers for play, pause and stop.
// https://w3c.github.io/mediasession/#ref-for-dom-mediasessionaction-play%E2%91%A3
switch (aKey) {

View File

@ -7,6 +7,7 @@
#include "MediaControlUtils.h"
#include "mozilla/dom/MediaSession.h"
#include "mozilla/dom/Navigator.h"
#include "mozilla/Telemetry.h"
#include "nsFocusManager.h"
// avoid redefined macro in unified build
@ -61,6 +62,14 @@ void ContentPlaybackController::NotifyMediaSession(
LOG("Handle '%s' in media session behavior for BC %" PRIu64,
ToMediaSessionActionStr(aDetails.mAction), mBC->Id());
MOZ_ASSERT(session->IsActive(), "Notify inactive media session!");
if (aDetails.mAction == MediaSessionAction::Play ||
aDetails.mAction == MediaSessionAction::Pause ||
aDetails.mAction == MediaSessionAction::Stop) {
AccumulateCategorical(
mozilla::Telemetry::
LABELS_MEDIA_CONTROL_HANDLE_PLAY_PAUSE_STOP_ACTIONS::
MediaSessionHandler);
}
session->NotifyHandler(aDetails);
}
}

View File

@ -15130,6 +15130,20 @@
"description": "Counts the number of times users enable and use media control on different platforms.",
"releaseChannelCollection": "opt-out"
},
"MEDIA_CONTROL_HANDLE_PLAY_PAUSE_STOP_ACTIONS": {
"record_in_processes": ["content"],
"products": ["firefox"],
"alert_emails": [
"alwu@mozilla.com",
"cchang@mozilla.com"
],
"bug_numbers": [1668139],
"expires_in_version": "90",
"kind": "categorical",
"labels": ["DefaultHandler", "MediaSessionHandler"],
"description": "The number of times `play/pause/stop` actions are being handled on either default handler or media session action handler.",
"releaseChannelCollection": "opt-out"
},
"QM_QUOTA_INFO_LOAD_TIME_V0": {
"record_in_processes": ["main"],
"products": ["firefox", "fennec"],