Bug 1514016 - Replace DispatchStartEventRunnable with DispatchEventRunnable. r=pehrsons
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 14 Jan 2019 18:32:53 +0000
changeset 510898 e19d8db0f4d1339707222f05ce9dea97afcab1f2
parent 510897 7a0378016cf9dab373a6218f600020894cbcd81e
child 510899 8f1376f47212a9d5252fe1f030a2b940af301d59
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1514016
milestone66.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 1514016 - Replace DispatchStartEventRunnable with DispatchEventRunnable. r=pehrsons 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() {