Bug 1271483 - p12. Use StringListContains to filter notifications - r=cpearce
Using string-list iterator instead of bespoke code, to go through the decoder
doctor notifications-allowed pref.
MozReview-Commit-ID: 8sxopvlRrz7
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -416,32 +416,18 @@ DecoderDoctorDocumentWatcher::ReportAnal
// may be dispatched to the front-end. It either contains:
// - '*' -> Allow everything.
// - Comma-separater list of ids -> Allow if aReportStringId (from
// dom.properties) is one of them.
// - Nothing (missing or empty) -> Disable everything.
nsAdoptingCString filter =
Preferences::GetCString("media.decoder-doctor.notifications-allowed");
filter.StripWhitespace();
- bool allowed = false;
- if (!filter || filter.IsEmpty()) {
- // Allow nothing.
- } else if (filter.EqualsLiteral("*")) {
- allowed = true;
- } else for (uint32_t start = 0; start < filter.Length(); ) {
- int32_t comma = filter.FindChar(',', start);
- uint32_t end = (comma >= 0) ? uint32_t(comma) : filter.Length();
- if (strncmp(aReportStringId, filter.Data() + start, end - start) == 0) {
- allowed = true;
- break;
- }
- // Skip comma. End of line will be caught in for 'while' clause.
- start = end + 1;
- }
- if (allowed) {
+ if (filter.EqualsLiteral("*")
+ || StringListContains(filter, aReportStringId)) {
DispatchNotification(
mDocument->GetInnerWindow(),
aNotificationType, aIsSolved, aReportStringId, aParams);
}
}
enum SilverlightPresence {
eNoSilverlight,