Bug 1304207 - Add telemetry to track when EME CDMs are instantiated. r=gerald,r=francois
Add opt-out telemetry probe to track which EME CDMs are being instantiated.
This will enable us to determine when it's safe to remove the Adobe CDM.
MozReview-Commit-ID: iEPSTk7UtP
--- a/dom/media/eme/MediaKeys.cpp
+++ b/dom/media/eme/MediaKeys.cpp
@@ -8,16 +8,17 @@
#include "GMPService.h"
#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/dom/MediaKeysBinding.h"
#include "mozilla/dom/MediaKeyMessageEvent.h"
#include "mozilla/dom/MediaKeyError.h"
#include "mozilla/dom/MediaKeySession.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/UnionTypes.h"
+#include "mozilla/Telemetry.h"
#include "GMPCDMProxy.h"
#include "mozilla/EMEUtils.h"
#include "nsContentUtils.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsContentTypeParser.h"
#ifdef MOZ_FMP4
#include "MP4Decoder.h"
#endif
@@ -395,16 +396,36 @@ MediaKeys::Init(ErrorResult& aRv)
NS_ConvertUTF8toUTF16(origin),
NS_ConvertUTF8toUTF16(topLevelOrigin),
KeySystemToGMPName(mKeySystem),
inPrivateBrowsing);
return promise.forget();
}
+enum CDMCreatedType {
+ eClearKey = 0,
+ ePrimetime = 1,
+ eWidevine = 2,
+ eUnknown = 3
+};
+
+static CDMCreatedType
+ToCDMCreatedTelemetryEnum(const nsString& aKeySystem)
+{
+ if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem)) {
+ return CDMCreatedType::eWidevine;
+ } else if (!CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem)) {
+ return CDMCreatedType::eClearKey;
+ } else if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
+ return CDMCreatedType::ePrimetime;
+ }
+ return CDMCreatedType::eUnknown;
+}
+
void
MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const uint32_t aPluginId)
{
RefPtr<DetailedPromise> promise(RetrievePromise(aId));
if (!promise) {
return;
}
mNodeId = aNodeId;
@@ -413,16 +434,18 @@ MediaKeys::OnCDMCreated(PromiseId aId, c
promise->MaybeResolve(keys);
if (mCreatePromiseId == aId) {
Release();
}
MediaKeySystemAccess::NotifyObservers(mParent,
mKeySystem,
MediaKeySystemStatus::Cdm_created);
+
+ Telemetry::Accumulate(Telemetry::VIDEO_CDM_CREATED, ToCDMCreatedTelemetryEnum(mKeySystem));
}
already_AddRefed<MediaKeySession>
MediaKeys::CreateSession(JSContext* aCx,
MediaKeySessionType aSessionType,
ErrorResult& aRv)
{
if (!mProxy) {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -8580,16 +8580,25 @@
"expires_in_version": "55",
"bug_numbers": [1230265],
"kind": "linear",
"high": 1000,
"n_buckets": 100,
"description": "720p VP9 decode benchmark measurement in frames per second",
"releaseChannelCollection": "opt-out"
},
+ "VIDEO_CDM_CREATED": {
+ "alert_emails": ["cpearce@mozilla.com"],
+ "expires_in_version": "58",
+ "bug_numbers": [1304207],
+ "kind": "enumerated",
+ "n_values": 6,
+ "description": "Note the type of CDM (0=ClearKey, 1=Primetime, 2=Widevine, 3=unknown) every time we successfully instantiate an EME MediaKeys object.",
+ "releaseChannelCollection": "opt-out"
+ },
"MEDIA_CODEC_USED": {
"alert_emails": ["cpearce@mozilla.com"],
"expires_in_version": "never",
"keyed": true,
"kind": "count",
"description": "Count of use of audio/video codecs in HTMLMediaElements and WebAudio. Those with 'resource' prefix are approximate; report based on HTTP ContentType or sniffing. Those with 'webaudio' prefix are for WebAudio."
},
"FX_SANITIZE_TOTAL": {