Bug 1331862. Part 1 - add a function to the webidl to retrieve debugging data in an asynchronous way. r?bz draft
authorJW Wang <jwwang@mozilla.com>
Wed, 18 Jan 2017 16:14:57 +0800
changeset 463427 7c1de996eaa5989359debd34b4ec1a5af37f9ee7
parent 462935 463f36ecbcd49b04185bf73272ec99b6405ca06b
child 463428 c23fc2cea382627af8ff20ae3edea926eaa6d51a
push id42059
push userjwwang@mozilla.com
push dateThu, 19 Jan 2017 02:48:25 +0000
reviewersbz
bugs1331862
milestone53.0a1
Bug 1331862. Part 1 - add a function to the webidl to retrieve debugging data in an asynchronous way. r?bz MozReview-Commit-ID: AXTpOYaq56A
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
dom/webidl/HTMLMediaElement.webidl
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1446,16 +1446,32 @@ HTMLMediaElement::GetMozMediaSourceObjec
 void
 HTMLMediaElement::GetMozDebugReaderData(nsAString& aString)
 {
   if (mDecoder && !mSrcStream) {
     mDecoder->GetMozDebugReaderData(aString);
   }
 }
 
+already_AddRefed<Promise>
+HTMLMediaElement::MozRequestDebugReaderData()
+{
+  ErrorResult rv;
+  RefPtr<Promise> promise = CreateDOMPromise(rv);
+  if (NS_WARN_IF(rv.Failed())) {
+    return nullptr;
+  }
+
+  // TODO: collect data from MDSM which must be done off the main thread.
+  nsAutoString result;
+  GetMozDebugReaderData(result);
+  promise->MaybeResolve(result);
+  return promise.forget();
+}
+
 void
 HTMLMediaElement::MozDumpDebugInfo()
 {
   if (mDecoder) {
     mDecoder->DumpDebugInfo();
   }
 }
 
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -598,16 +598,20 @@ public:
     mIsCasting = aShow;
   }
 
   already_AddRefed<MediaSource> GetMozMediaSourceObject() const;
   // Returns a string describing the state of the media player internal
   // data. Used for debugging purposes.
   void GetMozDebugReaderData(nsAString& aString);
 
+  // Returns a promise which will be resolved after collecting debugging
+  // data from decoder/reader/MDSM. Used for debugging purposes.
+  already_AddRefed<Promise> MozRequestDebugReaderData();
+
   void MozDumpDebugInfo();
 
   void SetVisible(bool aVisible);
 
   already_AddRefed<DOMMediaStream> GetSrcObject() const;
   void SetSrcObject(DOMMediaStream& aValue);
   void SetSrcObject(DOMMediaStream* aValue);
 
--- a/dom/webidl/HTMLMediaElement.webidl
+++ b/dom/webidl/HTMLMediaElement.webidl
@@ -99,16 +99,18 @@ interface HTMLMediaElement : HTMLElement
 };
 
 // Mozilla extensions:
 partial interface HTMLMediaElement {
   [ChromeOnly]
   readonly attribute MediaSource? mozMediaSourceObject;
   [ChromeOnly]
   readonly attribute DOMString mozDebugReaderData;
+  //[ChromeOnly]
+  Promise<DOMString> mozRequestDebugReaderData();
 
   [Pref="media.test.dumpDebugInfo"]
   void mozDumpDebugInfo();
 
   attribute MediaStream? srcObject;
   // TODO: remove prefixed version soon (1183495).
   attribute MediaStream? mozSrcObject;