Bug 1316211. P8 - fix MDSM::SizeOf{Audio,Video}Queue which should count its own queues. r=gerald
authorJW Wang <jwwang@mozilla.com>
Wed, 19 Jul 2017 15:02:33 +0800
changeset 418807 0bac6fca55b51a85ae4894a16dd8e328c966276a
parent 418806 569f0d24bfda2c49dda381cd6714e52eaf4ab2cc
child 418808 3e10f80060f91578aea2d954ef6601fe6f1bafa9
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1316211
milestone56.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 1316211. P8 - fix MDSM::SizeOf{Audio,Video}Queue which should count its own queues. r=gerald MozReview-Commit-ID: HMtkZpMSf3L
dom/media/MediaDecoderReader.cpp
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderReader.cpp
+++ b/dom/media/MediaDecoderReader.cpp
@@ -32,47 +32,16 @@ extern LazyLogModule gMediaDecoderLog;
 #undef FMT
 #undef DECODER_LOG
 #undef DECODER_WARN
 
 #define FMT(x, ...) "Decoder=%p " x, mDecoder, ##__VA_ARGS__
 #define DECODER_LOG(...) MOZ_LOG(gMediaDecoderLog, LogLevel::Debug,   (FMT(__VA_ARGS__)))
 #define DECODER_WARN(...) NS_WARNING(nsPrintfCString(FMT(__VA_ARGS__)).get())
 
-class VideoQueueMemoryFunctor : public nsDequeFunctor {
-public:
-  VideoQueueMemoryFunctor() : mSize(0) {}
-
-  MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf);
-
-  virtual void* operator()(void* aObject) {
-    const VideoData* v = static_cast<const VideoData*>(aObject);
-    mSize += v->SizeOfIncludingThis(MallocSizeOf);
-    return nullptr;
-  }
-
-  size_t mSize;
-};
-
-
-class AudioQueueMemoryFunctor : public nsDequeFunctor {
-public:
-  AudioQueueMemoryFunctor() : mSize(0) {}
-
-  MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf);
-
-  virtual void* operator()(void* aObject) {
-    const AudioData* audioData = static_cast<const AudioData*>(aObject);
-    mSize += audioData->SizeOfIncludingThis(MallocSizeOf);
-    return nullptr;
-  }
-
-  size_t mSize;
-};
-
 MediaDecoderReader::MediaDecoderReader(MediaDecoderReaderInit& aInit)
   : mDecoder(aInit.mDecoder)
   , mTaskQueue(new TaskQueue(
       GetMediaThreadPool(MediaThreadType::PLAYBACK),
       "MediaDecoderReader::mTaskQueue",
       /* aSupportsTailDispatch = */ true))
   , mBuffered(mTaskQueue, TimeIntervals(), "MediaDecoderReader::mBuffered (Canonical)")
   , mShutdown(false)
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3983,26 +3983,70 @@ void MediaDecoderStateMachine::RemoveOut
       NewRunnableMethod<bool>("MediaDecoderStateMachine::SetAudioCaptured",
                               this,
                               &MediaDecoderStateMachine::SetAudioCaptured,
                               false);
     OwnerThread()->Dispatch(r.forget());
   }
 }
 
+class VideoQueueMemoryFunctor : public nsDequeFunctor
+{
+public:
+  VideoQueueMemoryFunctor()
+    : mSize(0)
+  {
+  }
+
+  MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf);
+
+  virtual void* operator()(void* aObject)
+  {
+    const VideoData* v = static_cast<const VideoData*>(aObject);
+    mSize += v->SizeOfIncludingThis(MallocSizeOf);
+    return nullptr;
+  }
+
+  size_t mSize;
+};
+
+class AudioQueueMemoryFunctor : public nsDequeFunctor
+{
+public:
+  AudioQueueMemoryFunctor()
+    : mSize(0)
+  {
+  }
+
+  MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf);
+
+  virtual void* operator()(void* aObject)
+  {
+    const AudioData* audioData = static_cast<const AudioData*>(aObject);
+    mSize += audioData->SizeOfIncludingThis(MallocSizeOf);
+    return nullptr;
+  }
+
+  size_t mSize;
+};
+
 size_t
 MediaDecoderStateMachine::SizeOfVideoQueue() const
 {
-  return mReader->SizeOfVideoQueueInBytes();
+  VideoQueueMemoryFunctor functor;
+  mVideoQueue.LockedForEach(functor);
+  return functor.mSize;
 }
 
 size_t
 MediaDecoderStateMachine::SizeOfAudioQueue() const
 {
-  return mReader->SizeOfAudioQueueInBytes();
+  AudioQueueMemoryFunctor functor;
+  mAudioQueue.LockedForEach(functor);
+  return functor.mSize;
 }
 
 AbstractCanonical<media::TimeIntervals>*
 MediaDecoderStateMachine::CanonicalBuffered() const
 {
   return mReader->CanonicalBuffered();
 }