Bug 1514016 - Add DispatchEventRunnable to media recorder to aid with dispatching different named events. r=pehrsons, a=RyanVM
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 14 Jan 2019 18:32:52 +0000
changeset 506730 7746b834faec4a5d29d7fd1e53b935402306dac9
parent 506729 cf7d4022338c51b2d114d32d6b25ce91e1650af3
child 506731 eb356ac31743336120bf89d3d61e01d4193c2c83
push id10530
push userryanvm@gmail.com
push dateWed, 16 Jan 2019 14:53:15 +0000
treeherdermozilla-beta@944e9c24989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons, RyanVM
bugs1514016
milestone65.0
Bug 1514016 - Add DispatchEventRunnable to media recorder to aid with dispatching different named events. r=pehrsons, a=RyanVM 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 {