Bug 1514016 - Fire pause and resume events asynchronously. r=pehrsons, a=RyanVM
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 14 Jan 2019 18:32:53 +0000
changeset 509504 90eb6008a5ae479608d618f1f2dcb6b784795920
parent 509503 eb356ac31743336120bf89d3d61e01d4193c2c83
child 509505 5d242f707c4550a2f685d5b8571aea0789abe735
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 - Fire pause and resume events asynchronously. r=pehrsons, a=RyanVM Depends on D14487 Differential Revision: https://phabricator.services.mozilla.com/D14488
dom/media/MediaRecorder.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -588,28 +588,32 @@ class MediaRecorder::Session : public Pr
     LOG(LogLevel::Debug, ("Session.Pause"));
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!mEncoder) {
       return NS_ERROR_FAILURE;
     }
 
     mEncoder->Suspend(TimeStamp::Now());
+    NS_DispatchToMainThread(
+        new DispatchEventRunnable(this, NS_LITERAL_STRING("pause")));
     return NS_OK;
   }
 
   nsresult Resume() {
     LOG(LogLevel::Debug, ("Session.Resume"));
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!mEncoder) {
       return NS_ERROR_FAILURE;
     }
 
     mEncoder->Resume(TimeStamp::Now());
+    NS_DispatchToMainThread(
+        new DispatchEventRunnable(this, NS_LITERAL_STRING("resume")));
     return NS_OK;
   }
 
   nsresult RequestData() {
     LOG(LogLevel::Debug, ("Session.RequestData"));
     MOZ_ASSERT(NS_IsMainThread());
 
     if (NS_FAILED(
@@ -1345,17 +1349,16 @@ void MediaRecorder::Pause(ErrorResult& a
   MOZ_ASSERT(mSessions.Length() > 0);
   nsresult rv = mSessions.LastElement()->Pause();
   if (NS_FAILED(rv)) {
     NotifyError(rv);
     return;
   }
 
   mState = RecordingState::Paused;
-  DispatchSimpleEvent(NS_LITERAL_STRING("pause"));
 }
 
 void MediaRecorder::Resume(ErrorResult& aResult) {
   LOG(LogLevel::Debug, ("MediaRecorder.Resume"));
   if (mState == RecordingState::Inactive) {
     aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
@@ -1363,17 +1366,16 @@ void MediaRecorder::Resume(ErrorResult& 
   MOZ_ASSERT(mSessions.Length() > 0);
   nsresult rv = mSessions.LastElement()->Resume();
   if (NS_FAILED(rv)) {
     NotifyError(rv);
     return;
   }
 
   mState = RecordingState::Recording;
-  DispatchSimpleEvent(NS_LITERAL_STRING("resume"));
 }
 
 void MediaRecorder::RequestData(ErrorResult& aResult) {
   if (mState == RecordingState::Inactive) {
     aResult.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
   MOZ_ASSERT(mSessions.Length() > 0);