зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1247056 - Refactor ReportToConsole and ReportAnalysis to be static - r=jwwang
This will be useful to call them from outside of DecoderDoctorWatcher. MozReview-Commit-ID: C7Hq8kwONQO --HG-- extra : histedit_source : 785c370c638555ecd31fd64e59bf532d32547d4a
This commit is contained in:
Родитель
f03575180b
Коммит
e2a781b6dd
|
@ -80,10 +80,6 @@ private:
|
|||
static const uint32_t sAnalysisPeriod_ms = 1000;
|
||||
void EnsureTimerIsStarted();
|
||||
|
||||
void ReportAnalysis(const NotificationAndReportStringId& aNotification,
|
||||
bool aIsSolved,
|
||||
const nsAString& aFormats);
|
||||
|
||||
void SynthesizeAnalysis();
|
||||
|
||||
// Raw pointer to an nsIDocument.
|
||||
|
@ -311,32 +307,43 @@ DispatchNotification(nsISupports* aSubject,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
DecoderDoctorDocumentWatcher::ReportAnalysis(
|
||||
const NotificationAndReportStringId& aNotification,
|
||||
bool aIsSolved,
|
||||
const nsAString& aParams)
|
||||
static void
|
||||
ReportToConsole(nsIDocument* aDocument,
|
||||
const char* aConsoleStringId,
|
||||
const nsAString& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aDocument);
|
||||
|
||||
// 'params' will only be forwarded for non-empty strings.
|
||||
const char16_t* params[1] = { aParams.Data() };
|
||||
DD_DEBUG("DecoderDoctorDiagnostics.cpp:ReportToConsole(doc=%p) ReportToConsole - aMsg='%s' params[0]='%s'",
|
||||
aDocument, aConsoleStringId,
|
||||
aParams.IsEmpty() ? "<no params>" : NS_ConvertUTF16toUTF8(params[0]).get());
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
||||
NS_LITERAL_CSTRING("Media"),
|
||||
aDocument,
|
||||
nsContentUtils::eDOM_PROPERTIES,
|
||||
aConsoleStringId,
|
||||
aParams.IsEmpty() ? nullptr : params,
|
||||
aParams.IsEmpty() ? 0 : 1);
|
||||
}
|
||||
|
||||
static void
|
||||
ReportAnalysis(nsIDocument* aDocument,
|
||||
const NotificationAndReportStringId& aNotification,
|
||||
bool aIsSolved,
|
||||
const nsAString& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!mDocument) {
|
||||
if (!aDocument) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Report non-solved issues to console.
|
||||
if (!aIsSolved) {
|
||||
// 'params' will only be forwarded for non-empty strings.
|
||||
const char16_t* params[1] = { aParams.Data() };
|
||||
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::ReportAnalysis() ReportToConsole - aMsg='%s' params[0]='%s'",
|
||||
this, mDocument, aNotification.mReportStringId,
|
||||
aParams.IsEmpty() ? "<no params>" : NS_ConvertUTF16toUTF8(params[0]).get());
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
||||
NS_LITERAL_CSTRING("Media"),
|
||||
mDocument,
|
||||
nsContentUtils::eDOM_PROPERTIES,
|
||||
aNotification.mReportStringId,
|
||||
aParams.IsEmpty() ? nullptr : params,
|
||||
aParams.IsEmpty() ? 0 : 1);
|
||||
ReportToConsole(aDocument, aNotification.mReportStringId, aParams);
|
||||
}
|
||||
|
||||
// "media.decoder-doctor.notifications-allowed" controls which notifications
|
||||
|
@ -351,7 +358,7 @@ DecoderDoctorDocumentWatcher::ReportAnalysis(
|
|||
if (filter.EqualsLiteral("*")
|
||||
|| StringListContains(filter, aNotification.mReportStringId)) {
|
||||
DispatchNotification(
|
||||
mDocument->GetInnerWindow(), aNotification, aIsSolved, aParams);
|
||||
aDocument->GetInnerWindow(), aNotification, aIsSolved, aParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,7 +514,7 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
|
|||
NS_ConvertUTF16toUTF8(workingFormat).get(),
|
||||
formatsPref.Data(),
|
||||
NS_ConvertUTF16toUTF8(formatsWithIssues).get());
|
||||
ReportAnalysis(*id, true, workingFormat);
|
||||
ReportAnalysis(mDocument, *id, true, workingFormat);
|
||||
// This particular Notification&ReportId has been solved, no need
|
||||
// to keep looking at other keysys/formats that might solve it too.
|
||||
solved = true;
|
||||
|
@ -534,8 +541,8 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
|
|||
if (CheckSilverlight() != eSilverlightEnabled) {
|
||||
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unsupported key systems: %s, widevine without WMF nor Silverlight",
|
||||
this, mDocument, NS_ConvertUTF16toUTF8(unsupportedKeySystems).get());
|
||||
ReportAnalysis(
|
||||
sMediaWidevineNoWMFNoSilverlight, false, unsupportedKeySystems);
|
||||
ReportAnalysis(mDocument, sMediaWidevineNoWMFNoSilverlight,
|
||||
false, unsupportedKeySystems);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -555,11 +562,12 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
|
|||
if (IsVistaOrLater()) {
|
||||
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because WMF was not found",
|
||||
this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringWMF).get());
|
||||
ReportAnalysis(sMediaWMFNeeded, false, formatsRequiringWMF);
|
||||
ReportAnalysis(mDocument, sMediaWMFNeeded, false, formatsRequiringWMF);
|
||||
} else {
|
||||
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media before Windows Vista",
|
||||
this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringWMF).get());
|
||||
ReportAnalysis(sMediaUnsupportedBeforeWindowsVista, false, formatsRequiringWMF);
|
||||
ReportAnalysis(mDocument, sMediaUnsupportedBeforeWindowsVista,
|
||||
false, formatsRequiringWMF);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -568,21 +576,22 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
|
|||
if (!formatsRequiringFFMpeg.IsEmpty()) {
|
||||
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
|
||||
this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringFFMpeg).get());
|
||||
ReportAnalysis(sMediaPlatformDecoderNotFound,
|
||||
ReportAnalysis(mDocument, sMediaPlatformDecoderNotFound,
|
||||
false, formatsRequiringFFMpeg);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
|
||||
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
|
||||
ReportAnalysis(sMediaCannotPlayNoDecoders, false, unplayableFormats);
|
||||
ReportAnalysis(mDocument, sMediaCannotPlayNoDecoders,
|
||||
false, unplayableFormats);
|
||||
return;
|
||||
}
|
||||
|
||||
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, but no decoders for some requested formats: %s",
|
||||
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
|
||||
if (Preferences::GetBool("media.decoder-doctor.verbose", false)) {
|
||||
ReportAnalysis(sMediaNoDecoders, false, unplayableFormats);
|
||||
ReportAnalysis(mDocument, sMediaNoDecoders, false, unplayableFormats);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче