Commit f1914fab authored by xhwang's avatar xhwang Committed by Commit bot

Encrypted Media: Add UMA for system code.

Choose to put the UMA reporting code in content_decryptor_delegate.cc because:
- It's hard to do UMA in CdmAdapter due to pp::UMAPrivate limitations.
- I want to report system code for OnPromiseRejected() and OnSessionError() in
  one file. So I can't do it in CdmPromise.

BUG=412987
TEST=Tested by hacking Chromium to provide a wrong license. Then check about://histograms and I see the histogram generated.

Review URL: https://codereview.chromium.org/561643002

Cr-Commit-Position: refs/heads/master@{#294478}
parent 8417c8e5
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "base/message_loop/message_loop_proxy.h" #include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/sparse_histogram.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "content/renderer/media/crypto/key_systems.h"
#include "content/renderer/pepper/ppb_buffer_impl.h" #include "content/renderer/pepper/ppb_buffer_impl.h"
#include "media/base/audio_buffer.h" #include "media/base/audio_buffer.h"
#include "media/base/audio_decoder_config.h" #include "media/base/audio_decoder_config.h"
...@@ -94,7 +96,7 @@ bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) { ...@@ -94,7 +96,7 @@ bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) {
// //
// Returns true if |block_info| is successfully filled. Returns false // Returns true if |block_info| is successfully filled. Returns false
// otherwise. // otherwise.
static bool MakeEncryptedBlockInfo( bool MakeEncryptedBlockInfo(
const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
uint32_t request_id, uint32_t request_id,
PP_EncryptedBlockInfo* block_info) { PP_EncryptedBlockInfo* block_info) {
...@@ -288,6 +290,16 @@ MediaKeys::Exception PpExceptionTypeToMediaException( ...@@ -288,6 +290,16 @@ MediaKeys::Exception PpExceptionTypeToMediaException(
} }
} }
// TODO(xhwang): Unify EME UMA reporting code when prefixed EME is deprecated.
// See http://crbug.com/412987 for details.
void ReportSystemCodeUMA(const std::string& key_system, uint32 system_code) {
// Sparse histogram macro does not cache the histogram, so it's safe to use
// macro with non-static histogram name here.
UMA_HISTOGRAM_SPARSE_SLOWLY(
"Media.EME." + KeySystemNameForUMA(key_system) + ".SystemCode",
system_code);
}
} // namespace } // namespace
ContentDecryptorDelegate::ContentDecryptorDelegate( ContentDecryptorDelegate::ContentDecryptorDelegate(
...@@ -767,6 +779,8 @@ void ContentDecryptorDelegate::OnPromiseRejected( ...@@ -767,6 +779,8 @@ void ContentDecryptorDelegate::OnPromiseRejected(
PP_CdmExceptionCode exception_code, PP_CdmExceptionCode exception_code,
uint32 system_code, uint32 system_code,
PP_Var error_description) { PP_Var error_description) {
ReportSystemCodeUMA(key_system_, system_code);
StringVar* error_description_string = StringVar::FromPPVar(error_description); StringVar* error_description_string = StringVar::FromPPVar(error_description);
DCHECK(error_description_string); DCHECK(error_description_string);
...@@ -846,6 +860,8 @@ void ContentDecryptorDelegate::OnSessionError( ...@@ -846,6 +860,8 @@ void ContentDecryptorDelegate::OnSessionError(
PP_CdmExceptionCode exception_code, PP_CdmExceptionCode exception_code,
uint32 system_code, uint32 system_code,
PP_Var error_description) { PP_Var error_description) {
ReportSystemCodeUMA(key_system_, system_code);
if (session_error_cb_.is_null()) if (session_error_cb_.is_null())
return; return;
......
...@@ -11305,6 +11305,11 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -11305,6 +11305,11 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>KeyError event count using an unknown key system.</summary> <summary>KeyError event count using an unknown key system.</summary>
</histogram> </histogram>
<histogram name="Media.EME.Unknown.SystemCode" units="system code">
<owner>xhwang@chromium.org</owner>
<summary>System code count using an unknown key system.</summary>
</histogram>
<histogram name="Media.EME.Widevine.addKey" enum="MediaKeyException"> <histogram name="Media.EME.Widevine.addKey" enum="MediaKeyException">
<owner>xhwang@chromium.org</owner> <owner>xhwang@chromium.org</owner>
<summary>addKey result using the Widevine key system.</summary> <summary>addKey result using the Widevine key system.</summary>
...@@ -11343,6 +11348,11 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -11343,6 +11348,11 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>KeyError event count using the Widevine key system.</summary> <summary>KeyError event count using the Widevine key system.</summary>
</histogram> </histogram>
<histogram name="Media.EME.Widevine.SystemCode" units="system code">
<owner>xhwang@chromium.org</owner>
<summary>System code count using the Widevine key system.</summary>
</histogram>
<histogram name="Media.FallbackHardwareAudioBitsPerChannel"> <histogram name="Media.FallbackHardwareAudioBitsPerChannel">
<owner>dalecurtis@chromium.org</owner> <owner>dalecurtis@chromium.org</owner>
<summary> <summary>
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