| OLD | NEW |
| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 base::TimeDelta all_watch_time = media::kNoTimestamp; | 294 base::TimeDelta all_watch_time = media::kNoTimestamp; |
| 295 base::TimeDelta mse_watch_time = media::kNoTimestamp; | 295 base::TimeDelta mse_watch_time = media::kNoTimestamp; |
| 296 base::TimeDelta eme_watch_time = media::kNoTimestamp; | 296 base::TimeDelta eme_watch_time = media::kNoTimestamp; |
| 297 base::TimeDelta src_watch_time = media::kNoTimestamp; | 297 base::TimeDelta src_watch_time = media::kNoTimestamp; |
| 298 base::TimeDelta ac_watch_time = media::kNoTimestamp; | 298 base::TimeDelta ac_watch_time = media::kNoTimestamp; |
| 299 base::TimeDelta battery_watch_time = media::kNoTimestamp; | 299 base::TimeDelta battery_watch_time = media::kNoTimestamp; |
| 300 }; | 300 }; |
| 301 | 301 |
| 302 struct PipelineInfo { | 302 struct PipelineInfo { |
| 303 bool has_pipeline = false; | 303 bool has_pipeline = false; |
| 304 bool has_ever_played = false; |
| 305 bool has_reached_have_enough = false; |
| 304 media::PipelineStatus last_pipeline_status = media::PIPELINE_OK; | 306 media::PipelineStatus last_pipeline_status = media::PIPELINE_OK; |
| 305 bool has_audio = false; | 307 bool has_audio = false; |
| 306 bool has_video = false; | 308 bool has_video = false; |
| 307 bool video_dds = false; | 309 bool video_dds = false; |
| 308 bool video_decoder_changed = false; | 310 bool video_decoder_changed = false; |
| 309 std::string audio_codec_name; | 311 std::string audio_codec_name; |
| 310 std::string video_codec_name; | 312 std::string video_codec_name; |
| 311 std::string video_decoder; | 313 std::string video_decoder; |
| 312 WatchTimeInfo watch_time_info; | 314 WatchTimeInfo watch_time_info; |
| 313 }; | 315 }; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 392 |
| 391 MediaInternals::MediaInternalsUMAHandler::MediaInternalsUMAHandler() { | 393 MediaInternals::MediaInternalsUMAHandler::MediaInternalsUMAHandler() { |
| 392 } | 394 } |
| 393 | 395 |
| 394 void MediaInternals::MediaInternalsUMAHandler::SavePlayerState( | 396 void MediaInternals::MediaInternalsUMAHandler::SavePlayerState( |
| 395 int render_process_id, | 397 int render_process_id, |
| 396 const media::MediaLogEvent& event) { | 398 const media::MediaLogEvent& event) { |
| 397 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 399 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 398 PlayerInfoMap& player_info = renderer_info_[render_process_id]; | 400 PlayerInfoMap& player_info = renderer_info_[render_process_id]; |
| 399 switch (event.type) { | 401 switch (event.type) { |
| 402 case media::MediaLogEvent::PLAY: { |
| 403 player_info[event.id].has_ever_played = true; |
| 404 break; |
| 405 } |
| 400 case media::MediaLogEvent::PIPELINE_STATE_CHANGED: { | 406 case media::MediaLogEvent::PIPELINE_STATE_CHANGED: { |
| 401 player_info[event.id].has_pipeline = true; | 407 player_info[event.id].has_pipeline = true; |
| 402 break; | 408 break; |
| 403 } | 409 } |
| 404 case media::MediaLogEvent::PIPELINE_ERROR: { | 410 case media::MediaLogEvent::PIPELINE_ERROR: { |
| 405 int status; | 411 int status; |
| 406 event.params.GetInteger("pipeline_error", &status); | 412 event.params.GetInteger("pipeline_error", &status); |
| 407 player_info[event.id].last_pipeline_status = | 413 player_info[event.id].last_pipeline_status = |
| 408 static_cast<media::PipelineStatus>(status); | 414 static_cast<media::PipelineStatus>(status); |
| 409 break; | 415 break; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 430 event.params.GetString("video_decoder", | 436 event.params.GetString("video_decoder", |
| 431 &player_info[event.id].video_decoder); | 437 &player_info[event.id].video_decoder); |
| 432 if (!previous_video_decoder.empty() && | 438 if (!previous_video_decoder.empty() && |
| 433 previous_video_decoder != player_info[event.id].video_decoder) { | 439 previous_video_decoder != player_info[event.id].video_decoder) { |
| 434 player_info[event.id].video_decoder_changed = true; | 440 player_info[event.id].video_decoder_changed = true; |
| 435 } | 441 } |
| 436 } | 442 } |
| 437 if (event.params.HasKey("video_dds")) { | 443 if (event.params.HasKey("video_dds")) { |
| 438 event.params.GetBoolean("video_dds", &player_info[event.id].video_dds); | 444 event.params.GetBoolean("video_dds", &player_info[event.id].video_dds); |
| 439 } | 445 } |
| 446 if (event.params.HasKey("pipeline_buffering_state")) { |
| 447 std::string buffering_state; |
| 448 event.params.GetString("pipeline_buffering_state", &buffering_state); |
| 449 if (buffering_state == "BUFFERING_HAVE_ENOUGH") |
| 450 player_info[event.id].has_reached_have_enough = true; |
| 451 } |
| 440 break; | 452 break; |
| 441 case media::MediaLogEvent::Type::WATCH_TIME_UPDATE: { | 453 case media::MediaLogEvent::Type::WATCH_TIME_UPDATE: { |
| 442 DVLOG(2) << "Processing watch time update."; | 454 DVLOG(2) << "Processing watch time update."; |
| 443 PipelineInfo& info = player_info[event.id]; | 455 PipelineInfo& info = player_info[event.id]; |
| 444 WatchTimeInfo& wti = info.watch_time_info; | 456 WatchTimeInfo& wti = info.watch_time_info; |
| 445 // Save audio only watch time information. | 457 // Save audio only watch time information. |
| 446 MaybeSaveWatchTime(event, media::MediaLog::kWatchTimeAudioAll, | 458 MaybeSaveWatchTime(event, media::MediaLog::kWatchTimeAudioAll, |
| 447 &wti.all_watch_time); | 459 &wti.all_watch_time); |
| 448 MaybeSaveWatchTime(event, media::MediaLog::kWatchTimeAudioMse, | 460 MaybeSaveWatchTime(event, media::MediaLog::kWatchTimeAudioMse, |
| 449 &wti.mse_watch_time); | 461 &wti.mse_watch_time); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Unsupported", | 578 UMA_HISTOGRAM_ENUMERATION("Media.PipelineStatus.Unsupported", |
| 567 player_info.last_pipeline_status, | 579 player_info.last_pipeline_status, |
| 568 media::PIPELINE_STATUS_MAX + 1); | 580 media::PIPELINE_STATUS_MAX + 1); |
| 569 } | 581 } |
| 570 // Report whether video decoder fallback happened, but only if a video decoder | 582 // Report whether video decoder fallback happened, but only if a video decoder |
| 571 // was reported. | 583 // was reported. |
| 572 if (!player_info.video_decoder.empty()) { | 584 if (!player_info.video_decoder.empty()) { |
| 573 UMA_HISTOGRAM_BOOLEAN("Media.VideoDecoderFallback", | 585 UMA_HISTOGRAM_BOOLEAN("Media.VideoDecoderFallback", |
| 574 player_info.video_decoder_changed); | 586 player_info.video_decoder_changed); |
| 575 } | 587 } |
| 588 |
| 589 // Report whether this player ever saw a playback event. Used to measure the |
| 590 // effectiveness of efforts to reduce loaded-but-never-used players. |
| 591 if (player_info.has_reached_have_enough) |
| 592 UMA_HISTOGRAM_BOOLEAN("Media.HasEverPlayed", player_info.has_ever_played); |
| 576 } | 593 } |
| 577 | 594 |
| 578 void MediaInternals::MediaInternalsUMAHandler::OnProcessTerminated( | 595 void MediaInternals::MediaInternalsUMAHandler::OnProcessTerminated( |
| 579 int render_process_id) { | 596 int render_process_id) { |
| 580 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 597 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 581 | 598 |
| 582 auto players_it = renderer_info_.find(render_process_id); | 599 auto players_it = renderer_info_.find(render_process_id); |
| 583 if (players_it == renderer_info_.end()) | 600 if (players_it == renderer_info_.end()) |
| 584 return; | 601 return; |
| 585 auto it = players_it->second.begin(); | 602 auto it = players_it->second.begin(); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); | 861 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); |
| 845 existing_dict->MergeDictionary(value); | 862 existing_dict->MergeDictionary(value); |
| 846 } | 863 } |
| 847 } | 864 } |
| 848 | 865 |
| 849 if (CanUpdate()) | 866 if (CanUpdate()) |
| 850 SendUpdate(SerializeUpdate(function, value)); | 867 SendUpdate(SerializeUpdate(function, value)); |
| 851 } | 868 } |
| 852 | 869 |
| 853 } // namespace content | 870 } // namespace content |
| OLD | NEW |