Commit 06e40740 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Add Media.EME.RequestMediaKeySystemAccess UKM

Reported when EME navigator.requestMediaKeySystemAccess() is called.
Currently only reported for Widevine key system, but could be extended
to report for any key systems.

Record two metrics for now:
- VideoCapabilities.HasHwSecureAllRobustness
- VideoCapabilities.HasEmptyRobustness

Bug: 920679
Test: Manually tested on chrome://ukm
Change-Id: I6992bcc2c614dd4e3c54db18afc6a8c6cb14b18f
Reviewed-on: https://chromium-review.googlesource.com/c/1407445Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622946}
parent 3514a77e
include_rules = [ include_rules = [
"-third_party/blink/renderer/modules", "-third_party/blink/renderer/modules",
"+services/metrics/public/cpp/ukm_builders.h",
"+services/metrics/public/cpp/ukm_recorder.h",
"+third_party/blink/renderer/modules/encryptedmedia", "+third_party/blink/renderer/modules/encryptedmedia",
"+third_party/blink/renderer/modules/event_modules.h", "+third_party/blink/renderer/modules/event_modules.h",
"+third_party/blink/renderer/modules/event_target_modules.h", "+third_party/blink/renderer/modules/event_target_modules.h",
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <algorithm> #include <algorithm>
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "third_party/blink/public/mojom/feature_policy/feature_policy.mojom-blink.h" #include "third_party/blink/public/mojom/feature_policy/feature_policy.mojom-blink.h"
#include "third_party/blink/public/platform/web_encrypted_media_client.h" #include "third_party/blink/public/platform/web_encrypted_media_client.h"
#include "third_party/blink/public/platform/web_encrypted_media_request.h" #include "third_party/blink/public/platform/web_encrypted_media_request.h"
...@@ -241,23 +243,38 @@ bool MediaKeySystemAccessInitializer::IsExecutionContextValid() const { ...@@ -241,23 +243,38 @@ bool MediaKeySystemAccessInitializer::IsExecutionContextValid() const {
} }
void MediaKeySystemAccessInitializer::CheckVideoCapabilityRobustness() const { void MediaKeySystemAccessInitializer::CheckVideoCapabilityRobustness() const {
// Only check for widevine key system. const char kWidevineKeySystem[] = "com.widevine.alpha";
if (KeySystem() != "com.widevine.alpha") const char kWidevineHwSecureAllRobustness[] = "HW_SECURE_ALL";
// Reported to UKM. Existing values must not change and new values must be
// added at the end of the list.
enum KeySystemForUkm {
kClearKey = 0,
kWidevine = 1,
};
// Only check for widevine key system for now.
if (KeySystem() != kWidevineKeySystem)
return; return;
bool has_video_capabilities = false; bool has_video_capabilities = false;
bool has_empty_robustness = false; bool has_empty_robustness = false;
bool has_hw_secure_all = false;
for (const auto& config : supported_configurations_) { for (const auto& config : supported_configurations_) {
for (const auto& capability : config.video_capabilities) { for (const auto& capability : config.video_capabilities) {
has_video_capabilities = true; has_video_capabilities = true;
if (capability.robustness.IsEmpty()) { if (capability.robustness.IsEmpty()) {
has_empty_robustness = true; has_empty_robustness = true;
break; } else if (capability.robustness == kWidevineHwSecureAllRobustness) {
has_hw_secure_all = true;
} }
if (has_empty_robustness && has_hw_secure_all)
break;
} }
if (has_empty_robustness) if (has_empty_robustness && has_hw_secure_all)
break; break;
} }
...@@ -278,6 +295,20 @@ void MediaKeySystemAccessInitializer::CheckVideoCapabilityRobustness() const { ...@@ -278,6 +295,20 @@ void MediaKeySystemAccessInitializer::CheckVideoCapabilityRobustness() const {
"specifying the robustness level could result in unexpected " "specifying the robustness level could result in unexpected "
"behavior.")); "behavior."));
} }
Document* document = To<Document>(resolver_->GetExecutionContext());
if (!document)
return;
ukm::builders::Media_EME_RequestMediaKeySystemAccess builder(
document->UkmSourceID());
builder.SetKeySystem(KeySystemForUkm::kWidevine);
builder.SetVideoCapabilities(static_cast<int>(has_video_capabilities));
builder.SetVideoCapabilities_HasEmptyRobustness(
static_cast<int>(has_empty_robustness));
builder.SetVideoCapabilities_HasHwSecureAllRobustness(
static_cast<int>(has_hw_secure_all));
builder.Record(document->UkmRecorder());
} }
} // namespace } // namespace
......
...@@ -1964,6 +1964,36 @@ be describing additional metrics about the same event. ...@@ -1964,6 +1964,36 @@ be describing additional metrics about the same event.
</metric> </metric>
</event> </event>
<event name="Media.EME.RequestMediaKeySystemAccess">
<owner>xhwang@chromium.org</owner>
<owner>media-dev@chromium.org</owner>
<summary>
Event recorded when RequestMediaKeySystemAccess() is called as part of
Encrypted Media Extensions (EME) API.
</summary>
<metric name="KeySystem">
<summary>
The key system passed in requestMediaKeySystemAccess() call.
</summary>
</metric>
<metric name="VideoCapabilities">
<summary>
Whether there are any &quot;videoCapabilities&quot;.
</summary>
</metric>
<metric name="VideoCapabilities.HasEmptyRobustness">
<summary>
Whether there are any &quot;videoCapabilities&quot; with empty robustness.
</summary>
</metric>
<metric name="VideoCapabilities.HasHwSecureAllRobustness">
<summary>
Whether there are any &quot;videoCapabilities&quot; with robustness being
&quot;HW_SECURE_ALL&quot;.
</summary>
</metric>
</event>
<event name="Media.Engagement.ShortPlaybackIgnored"> <event name="Media.Engagement.ShortPlaybackIgnored">
<owner>beccahughes@chromium.org</owner> <owner>beccahughes@chromium.org</owner>
<owner>media-dev@chromium.org</owner> <owner>media-dev@chromium.org</owner>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment