Bug 1414121. P2 - let MediaDecoder::DumpDebugInfo() return a MozPromise. r=jya
authorJW Wang <jwwang@mozilla.com>
Fri, 03 Nov 2017 10:46:02 +0800
changeset 443539 694d4dc74495c0453fc63d15f6cbf9a77c6604e3
parent 443538 5dc63b15b7e29659a21b9d63563272045117b03d
child 443540 bf2259850d28be7dff3a0150381bc1085164d632
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1414121
milestone58.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 1414121. P2 - let MediaDecoder::DumpDebugInfo() return a MozPromise. r=jya MozReview-Commit-ID: Fau4ysdlwwa
dom/html/HTMLMediaElement.cpp
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1609,19 +1609,23 @@ already_AddRefed<Promise>
 HTMLMediaElement::MozDumpDebugInfo()
 {
   ErrorResult rv;
   RefPtr<Promise> promise = CreateDOMPromise(rv);
   if (NS_WARN_IF(rv.Failed())) {
     return nullptr;
   }
   if (mDecoder) {
-    mDecoder->DumpDebugInfo();
-  }
-  promise->MaybeResolveWithUndefined();
+    mDecoder->DumpDebugInfo()->Then(mAbstractMainThread,
+                                    __func__,
+                                    promise.get(),
+                                    &Promise::MaybeResolveWithUndefined);
+  } else {
+    promise->MaybeResolveWithUndefined();
+  }
   return promise.forget();
 }
 
 void
 HTMLMediaElement::SetVisible(bool aVisible)
 {
   if (!mDecoder) {
     return;
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1545,42 +1545,45 @@ MediaDecoder::GetDebugInfo()
     this,
     mInfo ? mInfo->mAudio.mChannels : 0,
     mInfo ? mInfo->mAudio.mRate : 0,
     mInfo ? mInfo->HasAudio() : 0,
     mInfo ? mInfo->HasVideo() : 0,
     PlayStateStr());
 }
 
-void
+RefPtr<GenericPromise>
 MediaDecoder::DumpDebugInfo()
 {
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
   nsCString str = GetDebugInfo();
 
   nsAutoCString readerStr;
   GetMozDebugReaderData(readerStr);
   if (!readerStr.IsEmpty()) {
     str += "\nreader data:\n";
     str += readerStr;
   }
 
   if (!GetStateMachine()) {
     DUMP("%s", str.get());
-    return;
+    return GenericPromise::CreateAndResolve(true, __func__);
   }
 
-  GetStateMachine()->RequestDebugInfo()->Then(
-    SystemGroup::AbstractMainThreadFor(TaskCategory::Other), __func__,
-    [str] (const nsACString& aString) {
+  return GetStateMachine()->RequestDebugInfo()->Then(
+    SystemGroup::AbstractMainThreadFor(TaskCategory::Other),
+    __func__,
+    [str](const nsACString& aString) {
       DUMP("%s", str.get());
       DUMP("%s", aString.Data());
+      return GenericPromise::CreateAndResolve(true, __func__);
     },
-    [str] () {
+    [str]() {
       DUMP("%s", str.get());
+      return GenericPromise::CreateAndResolve(true, __func__);
     });
 }
 
 RefPtr<MediaDecoder::DebugInfoPromise>
 MediaDecoder::RequestDebugInfo()
 {
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
 
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -385,17 +385,17 @@ private:
   }
 
   virtual MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus();
 
   // Returns a string describing the state of the media player internal
   // data. Used for debugging purposes.
   virtual void GetMozDebugReaderData(nsACString& aString);
 
-  virtual void DumpDebugInfo();
+  RefPtr<GenericPromise> DumpDebugInfo();
 
   using DebugInfoPromise = MozPromise<nsCString, bool, true>;
   RefPtr<DebugInfoPromise> RequestDebugInfo();
 
 protected:
   virtual ~MediaDecoder();
 
   // Called when the first audio and/or video from the media file has been loaded