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

Side by Side Diff: content/browser/media/media_internals.cc

Issue 2711803006: Merge M57: "Add metric for tracking media playback utilization." (Closed)
Patch Set: Created 3 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/media/media_internals.h" 5 #include "content/browser/media/media_internals.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 base::TimeDelta all_watch_time = media::kNoTimestamp; 297 base::TimeDelta all_watch_time = media::kNoTimestamp;
298 base::TimeDelta mse_watch_time = media::kNoTimestamp; 298 base::TimeDelta mse_watch_time = media::kNoTimestamp;
299 base::TimeDelta eme_watch_time = media::kNoTimestamp; 299 base::TimeDelta eme_watch_time = media::kNoTimestamp;
300 base::TimeDelta src_watch_time = media::kNoTimestamp; 300 base::TimeDelta src_watch_time = media::kNoTimestamp;
301 base::TimeDelta ac_watch_time = media::kNoTimestamp; 301 base::TimeDelta ac_watch_time = media::kNoTimestamp;
302 base::TimeDelta battery_watch_time = media::kNoTimestamp; 302 base::TimeDelta battery_watch_time = media::kNoTimestamp;
303 }; 303 };
304 304
305 struct PipelineInfo { 305 struct PipelineInfo {
306 bool has_pipeline = false; 306 bool has_pipeline = false;
307 bool has_ever_played = false;
308 bool has_reached_have_enough = false;
307 media::PipelineStatus last_pipeline_status = media::PIPELINE_OK; 309 media::PipelineStatus last_pipeline_status = media::PIPELINE_OK;
308 bool has_audio = false; 310 bool has_audio = false;
309 bool has_video = false; 311 bool has_video = false;
310 bool video_dds = false; 312 bool video_dds = false;
311 bool video_decoder_changed = false; 313 bool video_decoder_changed = false;
312 std::string audio_codec_name; 314 std::string audio_codec_name;
313 std::string video_codec_name; 315 std::string video_codec_name;
314 std::string video_decoder; 316 std::string video_decoder;
315 WatchTimeInfo watch_time_info; 317 WatchTimeInfo watch_time_info;
316 }; 318 };
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 395
394 MediaInternals::MediaInternalsUMAHandler::MediaInternalsUMAHandler() { 396 MediaInternals::MediaInternalsUMAHandler::MediaInternalsUMAHandler() {
395 } 397 }
396 398
397 void MediaInternals::MediaInternalsUMAHandler::SavePlayerState( 399 void MediaInternals::MediaInternalsUMAHandler::SavePlayerState(
398 int render_process_id, 400 int render_process_id,
399 const media::MediaLogEvent& event) { 401 const media::MediaLogEvent& event) {
400 DCHECK_CURRENTLY_ON(BrowserThread::UI); 402 DCHECK_CURRENTLY_ON(BrowserThread::UI);
401 PlayerInfoMap& player_info = renderer_info_[render_process_id]; 403 PlayerInfoMap& player_info = renderer_info_[render_process_id];
402 switch (event.type) { 404 switch (event.type) {
405 case media::MediaLogEvent::PLAY: {
406 player_info[event.id].has_ever_played = true;
407 break;
408 }
403 case media::MediaLogEvent::PIPELINE_STATE_CHANGED: { 409 case media::MediaLogEvent::PIPELINE_STATE_CHANGED: {
404 player_info[event.id].has_pipeline = true; 410 player_info[event.id].has_pipeline = true;
405 break; 411 break;
406 } 412 }
407 case media::MediaLogEvent::PIPELINE_ERROR: { 413 case media::MediaLogEvent::PIPELINE_ERROR: {
408 int status; 414 int status;
409 event.params.GetInteger("pipeline_error", &status); 415 event.params.GetInteger("pipeline_error", &status);
410 player_info[event.id].last_pipeline_status = 416 player_info[event.id].last_pipeline_status =
411 static_cast<media::PipelineStatus>(status); 417 static_cast<media::PipelineStatus>(status);
412 break; 418 break;
(...skipping 20 matching lines...) Expand all
433 event.params.GetString("video_decoder", 439 event.params.GetString("video_decoder",
434 &player_info[event.id].video_decoder); 440 &player_info[event.id].video_decoder);
435 if (!previous_video_decoder.empty() && 441 if (!previous_video_decoder.empty() &&
436 previous_video_decoder != player_info[event.id].video_decoder) { 442 previous_video_decoder != player_info[event.id].video_decoder) {
437 player_info[event.id].video_decoder_changed = true; 443 player_info[event.id].video_decoder_changed = true;
438 } 444 }
439 } 445 }
440 if (event.params.HasKey("video_dds")) { 446 if (event.params.HasKey("video_dds")) {
441 event.params.GetBoolean("video_dds", &player_info[event.id].video_dds); 447 event.params.GetBoolean("video_dds", &player_info[event.id].video_dds);
442 } 448 }
449 if (event.params.HasKey("pipeline_buffering_state")) {
450 std::string buffering_state;
451 event.params.GetString("pipeline_buffering_state", &buffering_state);
452 if (buffering_state == "BUFFERING_HAVE_ENOUGH")
453 player_info[event.id].has_reached_have_enough = true;
454 }
443 break; 455 break;
444 case media::MediaLogEvent::Type::WATCH_TIME_UPDATE: { 456 case media::MediaLogEvent::Type::WATCH_TIME_UPDATE: {
445 DVLOG(2) << "Processing watch time update."; 457 DVLOG(2) << "Processing watch time update.";
446 PipelineInfo& info = player_info[event.id]; 458 PipelineInfo& info = player_info[event.id];
447 WatchTimeInfo& wti = info.watch_time_info; 459 WatchTimeInfo& wti = info.watch_time_info;
448 // Save audio only watch time information. 460 // Save audio only watch time information.
449 MaybeSaveWatchTime(event, media::MediaLog::kWatchTimeAudioAll, 461 MaybeSaveWatchTime(event, media::MediaLog::kWatchTimeAudioAll,
450 &wti.all_watch_time); 462 &wti.all_watch_time);
451 MaybeSaveWatchTime(event, media::MediaLog::kWatchTimeAudioMse, 463 MaybeSaveWatchTime(event, media::MediaLog::kWatchTimeAudioMse,
452 &wti.mse_watch_time); 464 &wti.mse_watch_time);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Unsupported", 581 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Unsupported",
570 player_info.last_pipeline_status, 582 player_info.last_pipeline_status,
571 media::PIPELINE_STATUS_MAX + 1); 583 media::PIPELINE_STATUS_MAX + 1);
572 } 584 }
573 // Report whether video decoder fallback happened, but only if a video decoder 585 // Report whether video decoder fallback happened, but only if a video decoder
574 // was reported. 586 // was reported.
575 if (!player_info.video_decoder.empty()) { 587 if (!player_info.video_decoder.empty()) {
576 UMA_HISTOGRAM_BOOLEAN("Media.VideoDecoderFallback", 588 UMA_HISTOGRAM_BOOLEAN("Media.VideoDecoderFallback",
577 player_info.video_decoder_changed); 589 player_info.video_decoder_changed);
578 } 590 }
591
592 // Report whether this player ever saw a playback event. Used to measure the
593 // effectiveness of efforts to reduce loaded-but-never-used players.
594 if (player_info.has_reached_have_enough)
595 UMA_HISTOGRAM_BOOLEAN("Media.HasEverPlayed", player_info.has_ever_played);
579 } 596 }
580 597
581 void MediaInternals::MediaInternalsUMAHandler::OnProcessTerminated( 598 void MediaInternals::MediaInternalsUMAHandler::OnProcessTerminated(
582 int render_process_id) { 599 int render_process_id) {
583 DCHECK_CURRENTLY_ON(BrowserThread::UI); 600 DCHECK_CURRENTLY_ON(BrowserThread::UI);
584 601
585 auto players_it = renderer_info_.find(render_process_id); 602 auto players_it = renderer_info_.find(render_process_id);
586 if (players_it == renderer_info_.end()) 603 if (players_it == renderer_info_.end())
587 return; 604 return;
588 auto it = players_it->second.begin(); 605 auto it = players_it->second.begin();
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); 863 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict));
847 existing_dict->MergeDictionary(value); 864 existing_dict->MergeDictionary(value);
848 } 865 }
849 } 866 }
850 867
851 if (CanUpdate()) 868 if (CanUpdate())
852 SendUpdate(SerializeUpdate(function, value)); 869 SendUpdate(SerializeUpdate(function, value));
853 } 870 }
854 871
855 } // namespace content 872 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698