Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: content/browser/media/media_internals.cc

Issue 697463005: Add PipelineStatus UMA logging to media_internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing CL comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/media/media_internals.cc
diff --git a/content/browser/media/media_internals.cc b/content/browser/media/media_internals.cc
index 4d600851783452b708edd2a04cb59edf7c2397e6..ab18b0ba5634669168dde25208d20d3472d40d6d 100644
--- a/content/browser/media/media_internals.cc
+++ b/content/browser/media/media_internals.cc
@@ -4,13 +4,18 @@
#include "content/browser/media/media_internals.h"
+#include "base/metrics/histogram.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_ui.h"
#include "media/audio/audio_parameters.h"
-#include "media/base/media_log.h"
#include "media/base/media_log_event.h"
namespace {
@@ -170,11 +175,165 @@ void AudioLogImpl::StoreComponentMetadata(int component_id,
dict->SetInteger("component_type", component_);
}
+class MediaInternals::MediaInternalsUMAHandler : public NotificationObserver {
+ public:
+ // NotificationObserver implementation.
+ void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) override;
+ void LogAndClearPlayersInRenderer(int render_process_id);
+
+ void SavePlayerState(const media::MediaLogEvent& event,
+ int render_process_id);
+ MediaInternalsUMAHandler();
DaleCurtis 2014/11/11 19:24:01 nit: constructor is usually first.
prabhur1 2014/11/12 21:32:37 Done.
+
+ private:
+ NotificationRegistrar registrar_;
+
+ struct PipelineInfo {
+ media::PipelineStatus last_pipeline_status;
+ bool has_audio;
+ bool has_video;
+ std::string audio_codec_name;
+ std::string video_codec_name;
+ std::string video_decoder;
+ PipelineInfo(): last_pipeline_status(media::PIPELINE_OK),
+ has_audio(false),
+ has_video(false) {}
+ };
+
+ // Key is playerid
+ typedef std::map<int, PipelineInfo> PlayerInfoMap;
+
+ // Key is renderer id
+ typedef std::map<int, PlayerInfoMap> RendererPlayerMap;
+
+ // Stores player information per renderer
+ RendererPlayerMap renderer_info;
DaleCurtis 2014/11/11 19:24:01 Member variables should end in an underscore.
prabhur1 2014/11/12 21:32:37 Done.
+
+ void ReportUMAForPipelineStatus(const PipelineInfo& player_info);
+};
DaleCurtis 2014/11/11 19:24:01 Add DISALLOW_COPY_AND_ASSIGN(...);
prabhur1 2014/11/12 21:32:37 Done.
+
+MediaInternals::MediaInternalsUMAHandler::MediaInternalsUMAHandler() {
+ registrar_.Add(this,
+ NOTIFICATION_RENDERER_PROCESS_TERMINATED,
+ NotificationService::AllBrowserContextsAndSources());
+}
+
+void MediaInternals::MediaInternalsUMAHandler::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_EQ(type, NOTIFICATION_RENDERER_PROCESS_TERMINATED);
+ RenderProcessHost* process = Source<RenderProcessHost>(source).ptr();
+ LogAndClearPlayersInRenderer(process->GetID());
+}
+
+void MediaInternals::MediaInternalsUMAHandler::SavePlayerState(
+ const media::MediaLogEvent& event, int render_process_id) {
+ PlayerInfoMap& player_info = renderer_info[render_process_id];
+ switch (event.type) {
+ case media::MediaLogEvent::WEBMEDIAPLAYER_CREATED: {
+ // Nothing to do here
+ break;
+ }
+ case media::MediaLogEvent::PIPELINE_ERROR: {
+ std::string status;
+ event.params.GetString("pipeline_error", &status);
+ media::MediaLog::StringToPipelineStatus(
+ status, player_info[event.id].last_pipeline_status);
+ break;
+ }
+ case media::MediaLogEvent::PROPERTY_CHANGE:
+ if (event.params.HasKey("found_audio_stream")) {
+ event.params.GetBoolean("found_audio_stream",
+ &player_info[event.id].has_audio);
+ }
+ if (event.params.HasKey("found_video_stream")) {
+ event.params.GetBoolean("found_video_stream",
+ &player_info[event.id].has_video);
+ }
+ if (event.params.HasKey("audio_codec_name")) {
+ event.params.GetString("audio_codec_name",
+ &player_info[event.id].audio_codec_name);
+ }
+ if (event.params.HasKey("video_codec_name")) {
+ event.params.GetString("video_codec_name",
+ &player_info[event.id].video_codec_name);
+ }
+ if (event.params.HasKey("video_decoder")) {
+ event.params.GetString("video_decoder",
+ &player_info[event.id].video_decoder);
+ }
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+void MediaInternals::MediaInternalsUMAHandler::ReportUMAForPipelineStatus(
DaleCurtis 2014/11/11 19:24:01 Did git cl format produce this formatting? It seem
prabhur1 2014/11/12 21:32:37 Done.
+ const PipelineInfo& player_info) {
+ if (player_info.has_video && player_info.has_audio) {
+ if (player_info.video_codec_name == "vp8") {
+ UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.VP8",
+ player_info.last_pipeline_status,
+ media::PIPELINE_STATUS_MAX + 1);
+ } else if (player_info.video_codec_name == "vp9") {
+ UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.VP9",
+ player_info.last_pipeline_status,
+ media::PIPELINE_STATUS_MAX + 1);
+ } else if (player_info.video_codec_name == "h264") {
+ if (player_info.video_decoder == "gpu") {
+ UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.HW.H264",
+ player_info.last_pipeline_status,
+ media::PIPELINE_STATUS_MAX + 1);
+ }
+ else {
+ UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo.SW.H264",
+ player_info.last_pipeline_status,
+ media::PIPELINE_STATUS_MAX + 1);
+ }
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.AudioVideo",
+ player_info.last_pipeline_status,
+ media::PIPELINE_STATUS_MAX + 1);
+ }
+ } else if (player_info.has_audio) {
+ UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Audio",
+ player_info.last_pipeline_status,
+ media::PIPELINE_STATUS_MAX + 1);
+ } else if (player_info.has_video) {
+ UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Video",
+ player_info.last_pipeline_status,
+ media::PIPELINE_STATUS_MAX + 1);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Unsupported",
+ player_info.last_pipeline_status,
+ media::PIPELINE_STATUS_MAX + 1);
+ }
+}
+
+void MediaInternals::MediaInternalsUMAHandler::LogAndClearPlayersInRenderer(
+ int render_process_id) {
+ auto players_it = renderer_info.find(render_process_id);
+ if (players_it == renderer_info.end())
+ return;
+ auto it = players_it->second.begin();
+ while (it != players_it->second.end()) {
DaleCurtis 2014/11/11 19:24:01 Note: You're modifying the structure you're iterat
prabhur1 2014/11/12 21:32:37 Acknowledged.
prabhur1 2014/11/12 21:32:37 Yep. it++ takes care of advancing the iterator bef
+ ReportUMAForPipelineStatus(it->second);
+ players_it->second.erase(it++);
+ }
+}
+
MediaInternals* MediaInternals::GetInstance() {
return g_media_internals.Pointer();
}
-MediaInternals::MediaInternals() : owner_ids_() {}
+MediaInternals::MediaInternals() : owner_ids_() {
+ uma_handler.reset(new MediaInternalsUMAHandler());
DaleCurtis 2014/11/11 19:24:01 Do this during the constructor variable initializa
prabhur1 2014/11/12 21:32:37 Done.
+}
+
MediaInternals::~MediaInternals() {}
void MediaInternals::OnMediaEvents(
@@ -195,6 +354,7 @@ void MediaInternals::OnMediaEvents(
dict.SetDouble("ticksMillis", ticks_millis);
dict.Set("params", event->params.DeepCopy());
SendUpdate(SerializeUpdate("media.onMediaEvent", &dict));
+ uma_handler->SavePlayerState(*event, render_process_id);
}
}

Powered by Google App Engine
This is Rietveld 408576698