Bug 1343161 - DecoderDoctorDiagnostics::StoreDecodeError/Warning - r=jya

Code to capture decode errors/warnings in Decoder Doctor.
No analysis yet.

MozReview-Commit-ID: 8Aim7vv72xE

--HG--
extra : rebase_source : 95de63b365549369043a4d20a80963227efcc0be
This commit is contained in:
Gerald Squelart 2017-02-21 14:07:23 +11:00
Родитель 560863b7ed
Коммит b949250f8c
2 изменённых файлов: 128 добавлений и 6 удалений

Просмотреть файл

@ -454,11 +454,14 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
case DecoderDoctorDiagnostics::eEvent:
MOZ_ASSERT_UNREACHABLE("Events shouldn't be stored for processing.");
break;
case DecoderDoctorDiagnostics::eDecodeError:
// TODO
break;
case DecoderDoctorDiagnostics::eDecodeWarning:
// TODO
break;
default:
MOZ_ASSERT(diag.mDecoderDoctorDiagnostics.Type()
== DecoderDoctorDiagnostics::eFormatSupportCheck
|| diag.mDecoderDoctorDiagnostics.Type()
== DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest);
MOZ_ASSERT_UNREACHABLE("Unhandled DecoderDoctorDiagnostics type");
break;
}
}
@ -779,6 +782,88 @@ DecoderDoctorDiagnostics::StoreEvent(nsIDocument* aDocument,
#endif // MOZ_PULSEAUDIO
}
void
DecoderDoctorDiagnostics::StoreDecodeError(nsIDocument* aDocument,
const MediaResult& aError,
const nsString& aMediaSrc,
const char* aCallSite)
{
MOZ_ASSERT(NS_IsMainThread());
// Make sure we only store once.
MOZ_ASSERT(mDiagnosticsType == eUnsaved);
mDiagnosticsType = eDecodeError;
if (NS_WARN_IF(!aDocument)) {
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreDecodeError("
"nsIDocument* aDocument=nullptr, aError=%s,"
" aMediaSrc=<provided>, call site '%s')",
this, aError.Description().get(), aCallSite);
return;
}
RefPtr<DecoderDoctorDocumentWatcher> watcher =
DecoderDoctorDocumentWatcher::RetrieveOrCreate(aDocument);
if (NS_WARN_IF(!watcher)) {
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreDecodeError("
"nsIDocument* aDocument=%p, aError='%s', aMediaSrc=<provided>,"
" call site '%s') - Could not create document watcher",
this, aDocument, aError.Description().get(), aCallSite);
return;
}
mDecodeIssue = aError;
mDecodeIssueMediaSrc = aMediaSrc;
// StoreDecodeError should only be called once, after all data is
// available, so it is safe to Move() from this object.
watcher->AddDiagnostics(Move(*this), aCallSite);
// Even though it's moved-from, the type should stay set
// (Only used to ensure that we do store only once.)
MOZ_ASSERT(mDiagnosticsType == eDecodeError);
}
void
DecoderDoctorDiagnostics::StoreDecodeWarning(nsIDocument* aDocument,
const MediaResult& aWarning,
const nsString& aMediaSrc,
const char* aCallSite)
{
MOZ_ASSERT(NS_IsMainThread());
// Make sure we only store once.
MOZ_ASSERT(mDiagnosticsType == eUnsaved);
mDiagnosticsType = eDecodeWarning;
if (NS_WARN_IF(!aDocument)) {
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreDecodeWarning("
"nsIDocument* aDocument=nullptr, aWarning=%s,"
" aMediaSrc=<provided>, call site '%s')",
this, aWarning.Description().get(), aCallSite);
return;
}
RefPtr<DecoderDoctorDocumentWatcher> watcher =
DecoderDoctorDocumentWatcher::RetrieveOrCreate(aDocument);
if (NS_WARN_IF(!watcher)) {
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreDecodeWarning("
"nsIDocument* aDocument=%p, aWarning='%s', aMediaSrc=<provided>,"
" call site '%s') - Could not create document watcher",
this, aDocument, aWarning.Description().get(), aCallSite);
return;
}
mDecodeIssue = aWarning;
mDecodeIssueMediaSrc = aMediaSrc;
// StoreDecodeWarning should only be called once, after all data is
// available, so it is safe to Move() from this object.
watcher->AddDiagnostics(Move(*this), aCallSite);
// Even though it's moved-from, the type should stay set
// (Only used to ensure that we do store only once.)
MOZ_ASSERT(mDiagnosticsType == eDecodeWarning);
}
static const char*
EventDomainString(DecoderDoctorEvent::Domain aDomain)
{
@ -837,6 +922,20 @@ DecoderDoctorDiagnostics::GetDescription() const
s = nsPrintfCString("event domain %s result=%" PRIu32,
EventDomainString(mEvent.mDomain), static_cast<uint32_t>(mEvent.mResult));
break;
case eDecodeError:
s = "decode error: ";
s += mDecodeIssue.Description();
s += ", src='";
s += mDecodeIssueMediaSrc.IsEmpty() ? "<none>" : "<provided>";
s += "'";
break;
case eDecodeWarning:
s = "decode warning: ";
s += mDecodeIssue.Description();
s += ", src='";
s += mDecodeIssueMediaSrc.IsEmpty() ? "<none>" : "<provided>";
s += "'";
break;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected DiagnosticsType");
s = "?";

Просмотреть файл

@ -7,6 +7,7 @@
#ifndef DecoderDoctorDiagnostics_h_
#define DecoderDoctorDiagnostics_h_
#include "MediaResult.h"
#include "nsString.h"
class nsIDocument;
@ -57,11 +58,24 @@ public:
const DecoderDoctorEvent& aEvent,
const char* aCallSite);
enum DiagnosticsType {
void StoreDecodeError(nsIDocument* aDocument,
const MediaResult& aError,
const nsString& aMediaSrc,
const char* aCallSite);
void StoreDecodeWarning(nsIDocument* aDocument,
const MediaResult& aWarning,
const nsString& aMediaSrc,
const char* aCallSite);
enum DiagnosticsType
{
eUnsaved,
eFormatSupportCheck,
eMediaKeySystemAccessRequest,
eEvent
eEvent,
eDecodeError,
eDecodeWarning
};
DiagnosticsType Type() const { return mDiagnosticsType; }
@ -108,6 +122,12 @@ public:
return mEvent;
}
const MediaResult& DecodeIssue() const { return mDecodeIssue; }
const nsString& DecodeIssueMediaSrc() const
{
return mDecodeIssueMediaSrc;
}
private:
// Currently-known type of diagnostics. Set from one of the 'Store...' methods.
// This helps ensure diagnostics are only stored once,
@ -130,6 +150,9 @@ private:
KeySystemIssue mKeySystemIssue = eUnset;
DecoderDoctorEvent mEvent;
MediaResult mDecodeIssue = NS_OK;
nsString mDecodeIssueMediaSrc;
};
} // namespace mozilla