Bug 1298275 - Make ~AutoByteReader non-virtual - r=jya
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 26 Aug 2016 17:27:23 +1000
changeset 311502 a9b5e8c3cd847feb7d94103fc1abd3ff5fee4241
parent 311501 af2d7437a1c5032951886895e0915029c6eddcb3
child 311503 1f302a3d9df01298f7e6f50333bdfdafe7dd0c00
push id30614
push userryanvm@gmail.com
push dateMon, 29 Aug 2016 16:22:36 +0000
treeherdermozilla-central@12fa18765018 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1298275
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1298275 - Make ~AutoByteReader non-virtual - r=jya Also ByteReader and AutoByteReader are marked RAII, to help prevent misuses. MozReview-Commit-ID: 7oklXs4QMnq
dom/media/flac/FlacFrameParser.cpp
dom/media/platforms/agnostic/WAVDecoder.cpp
dom/media/wave/WaveDemuxer.cpp
media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
--- a/dom/media/flac/FlacFrameParser.cpp
+++ b/dom/media/flac/FlacFrameParser.cpp
@@ -8,25 +8,25 @@
 #include "mp4_demuxer/ByteReader.h"
 #include "nsTArray.h"
 #include "OggCodecState.h"
 #include "VideoUtils.h"
 
 namespace mozilla
 {
 
-class AutoByteReader : public mp4_demuxer::ByteReader
+class MOZ_RAII AutoByteReader : public mp4_demuxer::ByteReader
 {
 public:
   AutoByteReader(const uint8_t* aData, size_t aSize)
     : mp4_demuxer::ByteReader(aData, aSize)
   {
 
   }
-  virtual ~AutoByteReader()
+  ~AutoByteReader()
   {
     DiscardRemaining();
   }
 };
 
 #define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F
 #define FLAC_STREAMINFO_SIZE   34
 
--- a/dom/media/platforms/agnostic/WAVDecoder.cpp
+++ b/dom/media/platforms/agnostic/WAVDecoder.cpp
@@ -71,17 +71,17 @@ WaveDataDecoder::Input(MediaRawData* aSa
   }
   return NS_OK;
 }
 
 bool
 WaveDataDecoder::DoDecode(MediaRawData* aSample)
 {
   size_t aLength = aSample->Size();
-  ByteReader aReader = ByteReader(aSample->Data(), aLength);
+  ByteReader aReader(aSample->Data(), aLength);
   int64_t aOffset = aSample->mOffset;
   uint64_t aTstampUsecs = aSample->mTime;
 
   int32_t frames = aLength * 8 / mInfo.mBitDepth / mInfo.mChannels;
 
   AlignedAudioBuffer buffer(frames * mInfo.mChannels);
   if (!buffer) {
     return false;
--- a/dom/media/wave/WaveDemuxer.cpp
+++ b/dom/media/wave/WaveDemuxer.cpp
@@ -165,56 +165,55 @@ WAVTrackDemuxer::Init()
 
 bool
 WAVTrackDemuxer::RIFFParserInit()
 {
   RefPtr<MediaRawData> riffHeader = GetFileHeader(FindRIFFHeader());
   if (!riffHeader) {
     return false;
   }
-  ByteReader RIFFReader = ByteReader(riffHeader->Data(), 12);
+  ByteReader RIFFReader(riffHeader->Data(), 12);
   mRIFFParser.Parse(RIFFReader);
   return mRIFFParser.RiffHeader().IsValid(11);
 }
 
 bool
 WAVTrackDemuxer::HeaderParserInit()
 {
   RefPtr<MediaRawData> header = GetFileHeader(FindChunkHeader());
   if (!header) {
     return false;
   }
-  ByteReader HeaderReader = ByteReader(header->Data(), 8);
+  ByteReader HeaderReader(header->Data(), 8);
   mHeaderParser.Parse(HeaderReader);
   return true;
 }
 
 bool
 WAVTrackDemuxer::FmtChunkParserInit()
 {
   RefPtr<MediaRawData> fmtChunk = GetFileHeader(FindFmtChunk());
   if (!fmtChunk) {
     return false;
   }
-  ByteReader fmtReader = ByteReader(fmtChunk->Data(),
-                                    mHeaderParser.GiveHeader().ChunkSize());
+  ByteReader fmtReader(fmtChunk->Data(), mHeaderParser.GiveHeader().ChunkSize());
   mFmtParser.Parse(fmtReader);
   return true;
 }
 
 bool
 WAVTrackDemuxer::ListChunkParserInit(uint32_t aChunkSize)
 {
   uint32_t bytesRead = 0;
 
   RefPtr<MediaRawData> infoTag = GetFileHeader(FindInfoTag());
   if (!infoTag) {
     return false;
   }
-  ByteReader infoTagReader = ByteReader(infoTag->Data(), 4);
+  ByteReader infoTagReader(infoTag->Data(), 4);
   if (!infoTagReader.CanRead32() || infoTagReader.ReadU32() != INFO_CODE) {
     return false;
   }
 
   bytesRead += 4;
 
   while (bytesRead < aChunkSize) {
     if (!HeaderParserInit()) {
--- a/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/ByteReader.h
@@ -7,17 +7,17 @@
 
 #include "mozilla/EndianUtils.h"
 #include "mozilla/Vector.h"
 #include "nsTArray.h"
 #include "MediaData.h"
 
 namespace mp4_demuxer {
 
-class ByteReader
+class MOZ_RAII ByteReader
 {
 public:
   ByteReader() : mPtr(nullptr), mRemaining(0) {}
   explicit ByteReader(const mozilla::Vector<uint8_t>& aData)
     : mPtr(aData.begin()), mRemaining(aData.length()), mLength(aData.length())
   {
   }
   ByteReader(const uint8_t* aData, size_t aSize)