Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick PR #4058: [telemetry] Add telemetry to SbDrmCreateSystem #4066

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions cobalt/media/base/drm_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@
namespace cobalt {
namespace media {

SbDrmSystem CreateSbDrmSystemWithHistogram(
const char* key_system, void* context,
SbDrmSessionUpdateRequestFunc update_request_callback,
SbDrmSessionUpdatedFunc session_updated_callback,
SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback,
SbDrmServerCertificateUpdatedFunc server_certificate_updated_callback,
SbDrmSessionClosedFunc session_closed_callback,
MediaMetricsProvider& media_metrics_provider) {
media_metrics_provider.StartTrackingAction(MediaAction::SBDRM_CREATE);
auto drm_system = SbDrmCreateSystem(
key_system, context, update_request_callback, session_updated_callback,
key_statuses_changed_callback, server_certificate_updated_callback,
session_closed_callback);
media_metrics_provider.EndTrackingAction(MediaAction::SBDRM_CREATE);
return drm_system;
}

DECLARE_INSTANCE_COUNTER(DrmSystem);

DrmSystem::Session::Session(
Expand Down Expand Up @@ -80,10 +97,11 @@ void DrmSystem::Session::Close() {
}

DrmSystem::DrmSystem(const char* key_system)
: wrapped_drm_system_(SbDrmCreateSystem(
: wrapped_drm_system_(CreateSbDrmSystemWithHistogram(
key_system, this, OnSessionUpdateRequestGeneratedFunc,
OnSessionUpdatedFunc, OnSessionKeyStatusesChangedFunc,
OnServerCertificateUpdatedFunc, OnSessionClosedFunc)),
OnServerCertificateUpdatedFunc, OnSessionClosedFunc,
media_metrics_provider_)),
task_runner_(base::SequencedTaskRunner::GetCurrentDefault()),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
weak_this_(weak_ptr_factory_.GetWeakPtr()) {
Expand Down
3 changes: 1 addition & 2 deletions cobalt/media/base/drm_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class DrmSystem : public base::RefCounted<DrmSystem> {
SbDrmStatus status,
const char* error_message);

MediaMetricsProvider media_metrics_provider_;
const SbDrmSystem wrapped_drm_system_;
scoped_refptr<base::SequencedTaskRunner> const task_runner_;

Expand All @@ -253,8 +254,6 @@ class DrmSystem : public base::RefCounted<DrmSystem> {
// Supports concurrent calls to |Session::Update|.
TicketToSessionUpdateMap ticket_to_session_update_map_;

MediaMetricsProvider media_metrics_provider_;

DISALLOW_COPY_AND_ASSIGN(DrmSystem);
};

Expand Down
10 changes: 10 additions & 0 deletions cobalt/media/base/metrics_provider_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ TEST_F(MediaMetricsProviderTest, SbDrmCloseSession) {
std::string(kUmaPrefix) + "SbDrm.CloseSession.LatencyTiming", 570, 1);
}

TEST_F(MediaMetricsProviderTest, SbDrmCreate) {
metrics_.StartTrackingAction(MediaAction::SBDRM_CREATE);

clock_.Advance(base::TimeDelta::FromMicroseconds(570));
metrics_.EndTrackingAction(MediaAction::SBDRM_CREATE);

histogram_tester_.ExpectUniqueSample(
std::string(kUmaPrefix) + "SbDrm.Create.LatencyTiming", 570, 1);
}

TEST_F(MediaMetricsProviderTest, SbDrmDestroy) {
metrics_.StartTrackingAction(MediaAction::SBDRM_DESTROY);

Expand Down
9 changes: 9 additions & 0 deletions tools/metrics/histograms/metadata/cobalt/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ Always run the pretty print utility on this file after editing:
<summary>Timing data for closing session of SbDrm.</summary>
</histogram>

<histogram name="Cobalt.Media.SbDrm.Create.LatencyTiming" units="microseconds"
expires_after="never">
<!-- expires-never: Needed for long-term tracking of SbPlayer latencies. -->

<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>Timing data for the creation of SbDrm.</summary>
</histogram>

<histogram name="Cobalt.Media.SbDrm.Destroy.LatencyTiming" units="microseconds"
expires_after="never">
<!-- expires-never: Needed for long-term tracking of SbPlayer latencies. -->
Expand Down
Loading