summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-02 19:31:51 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-02 19:31:51 +0000
commit49a097eec42704cf30150b07794528c45a853e19 (patch)
tree650b1cd7e6536d5e65075a0f697de2293c7ea1f9
parentc1f620ce72ac314327743d083ea8c867edfe7822 (diff)
downloadchromium_src-49a097eec42704cf30150b07794528c45a853e19.zip
chromium_src-49a097eec42704cf30150b07794528c45a853e19.tar.gz
chromium_src-49a097eec42704cf30150b07794528c45a853e19.tar.bz2
Clean up media EME UMA reporting in WebMediaPlayerImpl.
Add two helper functions so that we don't call Histogram code directly. Review URL: https://chromiumcodereview.appspot.com/13401002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191874 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/media/webmediaplayer_impl.cc51
1 files changed, 31 insertions, 20 deletions
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index edae2bb..a193cc4 100644
--- a/webkit/media/webmediaplayer_impl.cc
+++ b/webkit/media/webmediaplayer_impl.cc
@@ -728,6 +728,30 @@ bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture(
return false;
}
+// Helper functions to report media EME related stats to UMA. They follow the
+// convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and
+// UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is
+// that UMA_* macros require the names to be constant throughout the process'
+// lifetime.
+static void EmeUMAHistogramEnumeration(const std::string& key_system,
+ const std::string& method,
+ int sample,
+ int boundary_value) {
+ base::LinearHistogram::FactoryGet(
+ kMediaEme + KeySystemNameForUMA(key_system) + "." + method,
+ 1, boundary_value, boundary_value + 1,
+ base::Histogram::kUmaTargetedHistogramFlag)->Add(sample);
+}
+
+static void EmeUMAHistogramCounts(const std::string& key_system,
+ const std::string& method,
+ int sample) {
+ // Use the same parameters as UMA_HISTOGRAM_COUNTS.
+ base::Histogram::FactoryGet(
+ kMediaEme + KeySystemNameForUMA(key_system) + "." + method,
+ 1, 1000000, 50, base::Histogram::kUmaTargetedHistogramFlag)->Add(sample);
+}
+
// Helper enum for reporting generateKeyRequest/addKey histograms.
enum MediaKeyException {
kUnknownResultId,
@@ -759,10 +783,8 @@ static void ReportMediaKeyExceptionToUMA(
WebMediaPlayer::MediaKeyException e) {
MediaKeyException result_id = MediaKeyExceptionForUMA(e);
DCHECK_NE(result_id, kUnknownResultId) << e;
- base::LinearHistogram::FactoryGet(
- kMediaEme + KeySystemNameForUMA(key_system) + "." + method, 1,
- kMaxMediaKeyException, kMaxMediaKeyException + 1,
- base::Histogram::kUmaTargetedHistogramFlag)->Add(result_id);
+ EmeUMAHistogramEnumeration(
+ key_system.utf8(), method, result_id, kMaxMediaKeyException);
}
WebMediaPlayer::MediaKeyException
@@ -819,7 +841,6 @@ WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey(
return e;
}
-
WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::AddKeyInternal(
const WebString& key_system,
const unsigned char* key,
@@ -953,11 +974,8 @@ void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) {
case media::PIPELINE_ERROR_DECRYPT:
// Decrypt error.
- base::Histogram::FactoryGet(
- (kMediaEme + KeySystemNameForUMA(current_key_system_) +
- ".DecryptError"),
- 1, 1000000, 50,
- base::Histogram::kUmaTargetedHistogramFlag)->Add(1);
+ EmeUMAHistogramCounts(current_key_system_.utf8(), "DecryptError", 1);
+
// TODO(xhwang): Change to use NetworkStateDecryptError once it's added in
// Webkit (see http://crbug.com/124486).
SetNetworkState(WebMediaPlayer::NetworkStateDecodeError);
@@ -1006,12 +1024,7 @@ void WebMediaPlayerImpl::OnDemuxerOpened(
void WebMediaPlayerImpl::OnKeyAdded(const std::string& key_system,
const std::string& session_id) {
DCHECK(main_loop_->BelongsToCurrentThread());
-
- base::Histogram::FactoryGet(
- kMediaEme + KeySystemNameForUMA(key_system) + ".KeyAdded",
- 1, 1000000, 50,
- base::Histogram::kUmaTargetedHistogramFlag)->Add(1);
-
+ EmeUMAHistogramCounts(key_system, "KeyAdded", 1);
GetClient()->keyAdded(WebString::fromUTF8(key_system),
WebString::fromUTF8(session_id));
}
@@ -1057,10 +1070,8 @@ void WebMediaPlayerImpl::OnKeyError(const std::string& key_system,
int system_code) {
DCHECK(main_loop_->BelongsToCurrentThread());
- base::LinearHistogram::FactoryGet(
- kMediaEme + KeySystemNameForUMA(key_system) + ".KeyError", 1,
- media::Decryptor::kMaxKeyError, media::Decryptor::kMaxKeyError + 1,
- base::Histogram::kUmaTargetedHistogramFlag)->Add(error_code);
+ EmeUMAHistogramEnumeration(
+ key_system, "KeyError", error_code, media::Decryptor::kMaxKeyError);
GetClient()->keyError(
WebString::fromUTF8(key_system),