OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "media/blink/watch_time_reporter.h" | 5 #include "media/blink/watch_time_reporter.h" |
6 | 6 |
7 #include "base/power_monitor/power_monitor.h" | 7 #include "base/power_monitor/power_monitor.h" |
8 | 8 |
9 namespace media { | 9 namespace media { |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 const GetMediaTimeCB& get_media_time_cb) | 31 const GetMediaTimeCB& get_media_time_cb) |
32 : has_audio_(has_audio), | 32 : has_audio_(has_audio), |
33 has_video_(has_video), | 33 has_video_(has_video), |
34 is_mse_(is_mse), | 34 is_mse_(is_mse), |
35 is_encrypted_(is_encrypted), | 35 is_encrypted_(is_encrypted), |
36 media_log_(std::move(media_log)), | 36 media_log_(std::move(media_log)), |
37 initial_video_size_(initial_video_size), | 37 initial_video_size_(initial_video_size), |
38 get_media_time_cb_(get_media_time_cb) { | 38 get_media_time_cb_(get_media_time_cb) { |
39 DCHECK(!get_media_time_cb_.is_null()); | 39 DCHECK(!get_media_time_cb_.is_null()); |
40 DCHECK(has_audio_ || has_video_); | 40 DCHECK(has_audio_ || has_video_); |
41 if (has_video_) | 41 |
42 DCHECK(!initial_video_size_.IsEmpty()); | 42 // TODO(tguilbert): For-reviewers -- Any suggested way to deal with the |
| 43 // watchtime reporter for HLS playback? It runs into this DCHECK due to the |
| 44 // fact that we don't know the size of the video until we start playing. I |
| 45 // tried circumventing this by creating the watchtime reporter later, but ran |
| 46 // into another plethora of DCHECKs instead. |
| 47 // |
| 48 // Considering the fact that we don't report the video anyways if it's smaller |
| 49 // than (200, 200), I am considering just removing the DCHECK I commented |
| 50 // below. |
| 51 // if (has_video_) |
| 52 // DCHECK(!initial_video_size_.IsEmpty()); |
43 | 53 |
44 if (base::PowerMonitor* pm = base::PowerMonitor::Get()) | 54 if (base::PowerMonitor* pm = base::PowerMonitor::Get()) |
45 pm->AddObserver(this); | 55 pm->AddObserver(this); |
46 } | 56 } |
47 | 57 |
48 WatchTimeReporter::~WatchTimeReporter() { | 58 WatchTimeReporter::~WatchTimeReporter() { |
49 // If the timer is still running, finalize immediately, this is our last | 59 // If the timer is still running, finalize immediately, this is our last |
50 // chance to capture metrics. | 60 // chance to capture metrics. |
51 if (reporting_timer_.IsRunning()) | 61 if (reporting_timer_.IsRunning()) |
52 MaybeFinalizeWatchTime(FinalizeTime::IMMEDIATELY); | 62 MaybeFinalizeWatchTime(FinalizeTime::IMMEDIATELY); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 263 } |
254 | 264 |
255 // Stop the timer if this is supposed to be our last tick. | 265 // Stop the timer if this is supposed to be our last tick. |
256 if (is_finalizing) { | 266 if (is_finalizing) { |
257 end_timestamp_ = kNoTimestamp; | 267 end_timestamp_ = kNoTimestamp; |
258 reporting_timer_.Stop(); | 268 reporting_timer_.Stop(); |
259 } | 269 } |
260 } | 270 } |
261 | 271 |
262 } // namespace media | 272 } // namespace media |
OLD | NEW |