Bug 1363915 - Add a runnable to fire arbitrary named events for the MediaRecorder. draft
authorBryce Van Dyk <bvandyk@mozilla.com>
Fri, 12 May 2017 11:55:09 +1200
changeset 576647 648f875c7092b42832f8587b8d534563d4a70974
parent 575938 d8762cb967423618ff0a488f14745f60964e5c49
child 576648 655c7dae857bb6c0839717ce9ebb39e8463cce76
push id58437
push userbvandyk@mozilla.com
push dateFri, 12 May 2017 01:15:25 +0000
bugs1363915
milestone55.0a1
Bug 1363915 - Add a runnable to fire arbitrary named events for the MediaRecorder. MozReview-Commit-ID: BAzxqQQMCZz
dom/media/MediaRecorder.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -225,16 +225,42 @@ class MediaRecorder::Session: public nsI
       }
       return NS_OK;
     }
 
   private:
     RefPtr<Session> mSession;
   };
 
+  // Fire a named event, run in main thread task.
+  class DispatchEventRunnable : public Runnable
+  {
+  public:
+    DispatchEventRunnable(Session* aSession, const nsAString & aEventName)
+      : mSession(aSession)
+      , mEventName(aEventName)
+    { }
+
+    NS_IMETHOD Run() override
+    {
+      LOG(LogLevel::Debug, ("Session.DispatchEventRunnable s=(%p) e=(%s)", 
+                            mSession.get(), mEventName));
+      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:
     DispatchStartEventRunnable(Session* aSession, const nsAString & aEventName)
       : mSession(aSession)
       , mEventName(aEventName)
     { }