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

Unified Diff: media/blink/watch_time_reporter.cc

Issue 2517313002: Merge M56: "Add audio only watch time metrics." (Closed)
Patch Set: Created 4 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
« no previous file with comments | « media/blink/watch_time_reporter.h ('k') | media/blink/watch_time_reporter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/watch_time_reporter.cc
diff --git a/media/blink/watch_time_reporter.cc b/media/blink/watch_time_reporter.cc
index fb41e69d05edc3ef267bf9856acaafeb31d281c8..e9872cb71895f1f200e775f6d9644fac3d462281 100644
--- a/media/blink/watch_time_reporter.cc
+++ b/media/blink/watch_time_reporter.cc
@@ -88,11 +88,17 @@ void WatchTimeReporter::OnVolumeChange(double volume) {
}
void WatchTimeReporter::OnShown() {
+ if (!has_video_)
+ return;
+
is_visible_ = true;
MaybeStartReportingTimer(get_media_time_cb_.Run());
}
void WatchTimeReporter::OnHidden() {
+ if (!has_video_)
+ return;
+
is_visible_ = false;
MaybeFinalizeWatchTime(FinalizeTime::ON_NEXT_UPDATE);
}
@@ -116,11 +122,12 @@ void WatchTimeReporter::OnPowerStateChange(bool on_battery_power) {
}
bool WatchTimeReporter::ShouldReportWatchTime() {
- // Only report watch time for media of sufficient size with both audio and
- // video tracks present.
- return has_audio_ && has_video_ &&
- initial_video_size_.height() >= kMinimumVideoSize.height() &&
- initial_video_size_.width() >= kMinimumVideoSize.width();
+ // Report listen time or watch time only for tracks that are audio-only or
+ // have both an audio and video track of sufficient size.
+ return (!has_video_ && has_audio_) ||
+ (has_video_ && has_audio_ &&
+ initial_video_size_.height() >= kMinimumVideoSize.height() &&
+ initial_video_size_.width() >= kMinimumVideoSize.width());
}
void WatchTimeReporter::MaybeStartReportingTimer(
@@ -199,17 +206,25 @@ void WatchTimeReporter::UpdateWatchTime() {
media_log_->CreateEvent(MediaLogEvent::Type::WATCH_TIME_UPDATE);
log_event->params.SetDoubleWithoutPathExpansion(
- MediaLog::kWatchTimeAudioVideoAll, elapsed.InSecondsF());
+ has_video_ ? MediaLog::kWatchTimeAudioVideoAll
+ : MediaLog::kWatchTimeAudioAll,
+ elapsed.InSecondsF());
if (is_mse_) {
log_event->params.SetDoubleWithoutPathExpansion(
- MediaLog::kWatchTimeAudioVideoMse, elapsed.InSecondsF());
+ has_video_ ? MediaLog::kWatchTimeAudioVideoMse
+ : MediaLog::kWatchTimeAudioMse,
+ elapsed.InSecondsF());
} else {
log_event->params.SetDoubleWithoutPathExpansion(
- MediaLog::kWatchTimeAudioVideoSrc, elapsed.InSecondsF());
+ has_video_ ? MediaLog::kWatchTimeAudioVideoSrc
+ : MediaLog::kWatchTimeAudioSrc,
+ elapsed.InSecondsF());
}
if (is_encrypted_) {
log_event->params.SetDoubleWithoutPathExpansion(
- MediaLog::kWatchTimeAudioVideoEme, elapsed.InSecondsF());
+ has_video_ ? MediaLog::kWatchTimeAudioVideoEme
+ : MediaLog::kWatchTimeAudioEme,
+ elapsed.InSecondsF());
}
// Record watch time using the last known value for |is_on_battery_power_|;
@@ -225,10 +240,14 @@ void WatchTimeReporter::UpdateWatchTime() {
if (elapsed_power >= kMinimumElapsedWatchTime) {
if (is_on_battery_power_) {
log_event->params.SetDoubleWithoutPathExpansion(
- MediaLog::kWatchTimeAudioVideoBattery, elapsed_power.InSecondsF());
+ has_video_ ? MediaLog::kWatchTimeAudioVideoBattery
+ : MediaLog::kWatchTimeAudioBattery,
+ elapsed_power.InSecondsF());
} else {
log_event->params.SetDoubleWithoutPathExpansion(
- MediaLog::kWatchTimeAudioVideoAc, elapsed_power.InSecondsF());
+ has_video_ ? MediaLog::kWatchTimeAudioVideoAc
+ : MediaLog::kWatchTimeAudioAc,
+ elapsed_power.InSecondsF());
}
}
« no previous file with comments | « media/blink/watch_time_reporter.h ('k') | media/blink/watch_time_reporter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698