Bug 1514016 - Add DispatchEventRunnable to media recorder to aid with dispatching different named events. r=pehrsons
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 14 Jan 2019 18:32:52 +0000
changeset 513779 7a0378016cf9dab373a6218f600020894cbcd81e
parent 513778 c5ab98eeb9158bf7838878e9156f1aa4d9126baa
child 513780 e19d8db0f4d1339707222f05ce9dea97afcab1f2
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [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 - Add DispatchEventRunnable to media recorder to aid with dispatching different named events. r=pehrsons Differential Revision: https://phabricator.services.mozilla.com/D14486
dom/media/MediaRecorder.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -319,16 +319,42 @@ class MediaRecorder::Session : public Pr
       recorder->NotifyError(NS_ERROR_UNEXPECTED);
       return NS_OK;
     }
 
    private:
     RefPtr<Session> mSession;
   };
 
+  // Fire a named event, run in main thread task.
+  class DispatchEventRunnable : public Runnable {
+   public:
+    explicit DispatchEventRunnable(Session* aSession,
+                                   const nsAString& aEventName)
+        : Runnable("dom::MediaRecorder::Session::DispatchEventRunnable"),
+          mSession(aSession),
+          mEventName(aEventName) {}
+
+    NS_IMETHOD Run() override {
+      LOG(LogLevel::Debug,
+          ("Session.DispatchEventRunnable s=(%p) e=(%s)", mSession.get(),
+           NS_ConvertUTF16toUTF8(mEventName).get()));
+      MOZ_ASSERT(NS_IsMainThread());
+
+      NS_ENSURE_TRUE(mSession->mRecorder, NS_OK);
+      mSession->mRecorder->DispatchSimpleEvent(mEventName);
+
+      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 {