Bug 1407810 - Implement HTMLMediaElement::Moz{Enable,Request}DebugLog - r=jwwang

MozReview-Commit-ID: 7Hhy6qBVjDk
This commit is contained in:
Gerald Squelart
2017-10-16 16:18:58 +11:00
parent b7ace0c452
commit b25c781d32
2 changed files with 33 additions and 0 deletions

View File

@@ -98,6 +98,7 @@
#include "nsIContentPolicy.h"
#include "mozilla/Telemetry.h"
#include "DecoderDoctorDiagnostics.h"
#include "DecoderDoctorLogger.h"
#include "DecoderTraits.h"
#include "MediaContainerType.h"
#include "MP4Decoder.h"
@@ -1608,6 +1609,31 @@ HTMLMediaElement::MozRequestDebugInfo(ErrorResult& aRv)
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()
{