Bug 1407810 - Implement HTMLMediaElement::Moz{Enable,Request}DebugLog - r=jwwang
MozReview-Commit-ID: 7Hhy6qBVjDk
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -93,16 +93,17 @@
#include "mozilla/dom/AudioTrackList.h"
#include "mozilla/dom/MediaErrorBinding.h"
#include "mozilla/dom/VideoTrack.h"
#include "mozilla/dom/VideoTrackList.h"
#include "mozilla/dom/TextTrack.h"
#include "nsIContentPolicy.h"
#include "mozilla/Telemetry.h"
#include "DecoderDoctorDiagnostics.h"
+#include "DecoderDoctorLogger.h"
#include "DecoderTraits.h"
#include "MediaContainerType.h"
#include "MP4Decoder.h"
#include "FrameStatistics.h"
#include "nsIFrame.h"
#include "nsDisplayList.h"
#include "SVGObserverUtils.h"
@@ -1603,16 +1604,41 @@ HTMLMediaElement::MozRequestDebugInfo(Er
});
} else {
promise->MaybeResolve(result);
}
return promise.forget();
}
+/* static */ void
+HTMLMediaElement::MozEnableDebugLog(const GlobalObject&)
+{
+ DecoderDoctorLogger::EnableLogging();
+}
+
+already_AddRefed<Promise>
+HTMLMediaElement::MozRequestDebugLog(ErrorResult& aRv)
+{
+ RefPtr<Promise> promise = CreateDOMPromise(aRv);
+ if (NS_WARN_IF(aRv.Failed())) {
+ return nullptr;
+ }
+
+ DecoderDoctorLogger::RetrieveMessages(this)->Then(
+ mAbstractMainThread,
+ __func__,
+ [promise](const nsACString& aString) {
+ promise->MaybeResolve(NS_ConvertUTF8toUTF16(aString));
+ },
+ [promise](nsresult rv) { promise->MaybeReject(rv); });
+
+ return promise.forget();
+}
+
already_AddRefed<Promise>
HTMLMediaElement::MozDumpDebugInfo()
{
ErrorResult rv;
RefPtr<Promise> promise = CreateDOMPromise(rv);
if (NS_WARN_IF(rv.Failed())) {
return nullptr;
}
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -626,16 +626,23 @@ public:
// 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> MozRequestDebugInfo(ErrorResult& aRv);
+ // Enables DecoderDoctorLogger logging. Used for debugging purposes.
+ static void MozEnableDebugLog(const GlobalObject&);
+
+ // Returns a promise which will be resolved after collecting debugging
+ // log associated with this element. Used for debugging purposes.
+ already_AddRefed<Promise> MozRequestDebugLog(ErrorResult& aRv);
+
already_AddRefed<Promise> MozDumpDebugInfo();
// For use by mochitests. Enabling pref "media.test.video-suspend"
void SetVisible(bool aVisible);
// For use by mochitests. Enabling pref "media.test.video-suspend"
bool HasSuspendTaint() const;