Bug 1286444 - Use correct types to construct VideoPlaybackQuality - r=kinetik draft
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 14 Jul 2016 15:18:36 +1000
changeset 387544 f8d673db0cd45d2b3ae03c092dff217e5d7ebbee
parent 387543 ed1e745c7d69babe6875677e3c8a16a9d6f3172c
child 387545 704d7664a3462f68f2c495e3b5d66f71180d290b
push id22984
push usergsquelart@mozilla.com
push dateThu, 14 Jul 2016 07:12:57 +0000
reviewerskinetik
bugs1286444
milestone50.0a1
Bug 1286444 - Use correct types to construct VideoPlaybackQuality - r=kinetik VideoPlaybackQuality was fed uint64_t's, now it should be given uint32_t's. Note that FrameStatistics currently provide uint32_t's, so we are fine now; nevertheless I added a static_assert to verify that and ensure it stays true. MozReview-Commit-ID: I0dgP1K4lg3
dom/html/HTMLVideoElement.cpp
--- a/dom/html/HTMLVideoElement.cpp
+++ b/dom/html/HTMLVideoElement.cpp
@@ -224,30 +224,32 @@ HTMLVideoElement::NotifyOwnerDocumentAct
   UpdateScreenWakeLock();
   return pauseElement;
 }
 
 already_AddRefed<VideoPlaybackQuality>
 HTMLVideoElement::GetVideoPlaybackQuality()
 {
   DOMHighResTimeStamp creationTime = 0;
-  uint64_t totalFrames = 0;
-  uint64_t droppedFrames = 0;
-  uint64_t corruptedFrames = 0;
+  uint32_t totalFrames = 0;
+  uint32_t droppedFrames = 0;
+  uint32_t corruptedFrames = 0;
 
   if (sVideoStatsEnabled) {
     if (nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow()) {
       Performance* perf = window->GetPerformance();
       if (perf) {
         creationTime = perf->Now();
       }
     }
 
     if (mDecoder) {
       FrameStatistics& stats = mDecoder->GetFrameStatistics();
+      static_assert(sizeof(uint32_t) >= sizeof (stats.GetParsedFrames()),
+                    "possible truncation from FrameStatistics to VideoPlaybackQuality");
       totalFrames = stats.GetParsedFrames();
       droppedFrames = stats.GetDroppedFrames();
       corruptedFrames = 0;
     }
   }
 
   RefPtr<VideoPlaybackQuality> playbackQuality =
     new VideoPlaybackQuality(this, creationTime, totalFrames, droppedFrames,