Bug 1514016 - Replace DispatchStartEventRunnable with DispatchEventRunnable. r=pehrsons, a=RyanVM
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 14 Jan 2019 18:32:53 +0000
changeset 509503 eb356ac31743336120bf89d3d61e01d4193c2c83
parent 509502 7746b834faec4a5d29d7fd1e53b935402306dac9
child 509504 90eb6008a5ae479608d618f1f2dcb6b784795920
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons, RyanVM
bugs1514016
milestone65.0
Bug 1514016 - Replace DispatchStartEventRunnable with DispatchEventRunnable. r=pehrsons, a=RyanVM Depends on D14486 Differential Revision: https://phabricator.services.mozilla.com/D14487
dom/media/MediaRecorder.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -345,40 +345,16 @@ class MediaRecorder::Session : public Pr
       return NS_OK;
     }
 
    private:
     RefPtr<Session> mSession;
     nsString mEventName;
   };
 
-  // Fire start event and set mimeType, run in main thread task.
-  class DispatchStartEventRunnable : public Runnable {
-   public:
-    explicit DispatchStartEventRunnable(Session* aSession)
-        : Runnable("dom::MediaRecorder::Session::DispatchStartEventRunnable"),
-          mSession(aSession) {}
-
-    NS_IMETHOD Run() override {
-      LOG(LogLevel::Debug,
-          ("Session.DispatchStartEventRunnable s=(%p)", mSession.get()));
-      MOZ_ASSERT(NS_IsMainThread());
-
-      NS_ENSURE_TRUE(mSession->mRecorder, NS_OK);
-      RefPtr<MediaRecorder> recorder = mSession->mRecorder;
-
-      recorder->DispatchSimpleEvent(NS_LITERAL_STRING("start"));
-
-      return NS_OK;
-    }
-
-   private:
-    RefPtr<Session> mSession;
-  };
-
   // Main thread task.
   // To delete RecordingSession object.
   class DestroyRunnable : public Runnable {
    public:
     explicit DestroyRunnable(Session* aSession)
         : Runnable("dom::MediaRecorder::Session::DestroyRunnable"),
           mSession(aSession) {}
 
@@ -1004,17 +980,18 @@ class MediaRecorder::Session : public Pr
         mRunningState.unwrap() == RunningState::Stopped) {
       // We have already ended gracefully.
       return;
     }
 
     if (mRunningState.isOk() &&
         (mRunningState.unwrap() == RunningState::Idling ||
          mRunningState.unwrap() == RunningState::Starting)) {
-      NS_DispatchToMainThread(new DispatchStartEventRunnable(this));
+      NS_DispatchToMainThread(
+          new DispatchEventRunnable(this, NS_LITERAL_STRING("start")));
     }
 
     if (rv == NS_OK) {
       mRunningState = RunningState::Stopped;
     } else {
       mRunningState = Err(rv);
     }
 
@@ -1071,17 +1048,18 @@ class MediaRecorder::Session : public Pr
             // We set it to Running in the runnable since we can only assign
             // mRunningState on main thread. We set it before running the start
             // event runnable since that dispatches synchronously (and may cause
             // js calls to methods depending on mRunningState).
             self->mRunningState = RunningState::Running;
           }
           self->mMimeType = mime;
           self->mRecorder->SetMimeType(self->mMimeType);
-          auto startEvent = MakeRefPtr<DispatchStartEventRunnable>(self);
+          auto startEvent = MakeRefPtr<DispatchEventRunnable>(
+              self, NS_LITERAL_STRING("start"));
           startEvent->Run();
         }
       }
       return NS_OK;
     }));
   }
 
   void MediaEncoderDataAvailable() {