Bug 1641161 - Bug 1285290 move AudioContextOperationControlMessage out of function scope r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 27 May 2020 08:45:01 +0000
changeset 532350 c17adfdc55cd8725c7187599cf93d439e1b7d764
parent 532349 a5931e2c9a139c93da3862f55048b960dd1f3d6a
child 532351 7bae1eadb123675a0b56815f8fe20002fc8f39cb
push id37454
push userccoroiu@mozilla.com
push dateWed, 27 May 2020 16:14:31 +0000
treeherdermozilla-central@a1dd9afbfdf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1641161, 1285290
milestone78.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 1641161 - Bug 1285290 move AudioContextOperationControlMessage out of function scope r=padenot This will permit passing an AudioContextOperationControlMessage* to other methods. Depends on D76798 Differential Revision: https://phabricator.services.mozilla.com/D76799
dom/media/MediaTrackGraph.cpp
--- a/dom/media/MediaTrackGraph.cpp
+++ b/dom/media/MediaTrackGraph.cpp
@@ -3561,47 +3561,50 @@ void MediaTrackGraphImpl::ApplyAudioCont
           "MediaTrackGraphImpl::ApplyAudioContextOperationImpl::Resolve3",
           [holder = std::move(aHolder), state]() mutable {
             holder.Resolve(state, __func__);
           }));
     }
   }
 }
 
+class AudioContextOperationControlMessage : public ControlMessage {
+  using AudioContextOperationPromise =
+      MediaTrackGraph::AudioContextOperationPromise;
+
+ public:
+  AudioContextOperationControlMessage(
+      MediaTrack* aDestinationTrack, const nsTArray<MediaTrack*>& aTracks,
+      AudioContextOperation aOperation,
+      MozPromiseHolder<AudioContextOperationPromise>&& aHolder)
+      : ControlMessage(aDestinationTrack),
+        mTracks(aTracks.Clone()),
+        mAudioContextOperation(aOperation),
+        mHolder(std::move(aHolder)) {}
+  void Run() override {
+    mTrack->GraphImpl()->ApplyAudioContextOperationImpl(
+        mTrack, mTracks, mAudioContextOperation, std::move(mHolder));
+  }
+  void RunDuringShutdown() override {
+    MOZ_ASSERT(mAudioContextOperation == AudioContextOperation::Close,
+               "We should be reviving the graph?");
+    mHolder.Resolve(AudioContextState::Closed, __func__);
+  }
+
+ private:
+  // We don't need strong references here for the same reason ControlMessage
+  // doesn't.
+  nsTArray<MediaTrack*> mTracks;
+  AudioContextOperation mAudioContextOperation;
+  MozPromiseHolder<AudioContextOperationPromise> mHolder;
+};
+
 auto MediaTrackGraph::ApplyAudioContextOperation(
     MediaTrack* aDestinationTrack, const nsTArray<MediaTrack*>& aTracks,
     AudioContextOperation aOperation) -> RefPtr<AudioContextOperationPromise> {
-  class AudioContextOperationControlMessage : public ControlMessage {
-   public:
-    AudioContextOperationControlMessage(
-        MediaTrack* aDestinationTrack, const nsTArray<MediaTrack*>& aTracks,
-        AudioContextOperation aOperation,
-        MozPromiseHolder<AudioContextOperationPromise>&& aHolder)
-        : ControlMessage(aDestinationTrack),
-          mTracks(aTracks.Clone()),
-          mAudioContextOperation(aOperation),
-          mHolder(std::move(aHolder)) {}
-    void Run() override {
-      mTrack->GraphImpl()->ApplyAudioContextOperationImpl(
-          mTrack, mTracks, mAudioContextOperation, std::move(mHolder));
-    }
-    void RunDuringShutdown() override {
-      MOZ_ASSERT(mAudioContextOperation == AudioContextOperation::Close,
-                 "We should be reviving the graph?");
-      mHolder.Resolve(AudioContextState::Closed, __func__);
-    }
-
-   private:
-    // We don't need strong references here for the same reason ControlMessage
-    // doesn't.
-    nsTArray<MediaTrack*> mTracks;
-    AudioContextOperation mAudioContextOperation;
-    MozPromiseHolder<AudioContextOperationPromise> mHolder;
-  };
-
   MozPromiseHolder<AudioContextOperationPromise> holder;
   RefPtr<AudioContextOperationPromise> p = holder.Ensure(__func__);
   MediaTrackGraphImpl* graphImpl = static_cast<MediaTrackGraphImpl*>(this);
   graphImpl->AppendMessage(MakeUnique<AudioContextOperationControlMessage>(
       aDestinationTrack, aTracks, aOperation, std::move(holder)));
   return p;
 }