Bug 1519636 - clang-format-8: Reformat recent changes to the Google coding style r=Ehsan

clang-format-8 upstream had some improvements wrt macros
See: https://reviews.llvm.org/D33440
This is why the diff is bigger than usual

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D26098

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Sylvestre Ledru 2019-04-05 21:41:42 +00:00
parent 45ec6114d3
commit 03c8e8c2dd
188 changed files with 3102 additions and 2694 deletions

View File

@ -5,20 +5,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
MARKUPMAP(a,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Only some roles truly enjoy life as HTMLLinkAccessibles, for
// details see closed bug 494807.
const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement);
if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
roleMapEntry->role != roles::LINK) {
return new HyperTextAccessibleWrap(aElement,
aContext->Document());
}
MARKUPMAP(
a,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Only some roles truly enjoy life as HTMLLinkAccessibles, for
// details see closed bug 494807.
const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement);
if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
roleMapEntry->role != roles::LINK) {
return new HyperTextAccessibleWrap(aElement, aContext->Document());
}
return new HTMLLinkAccessible(aElement, aContext->Document());
},
roles::LINK)
return new HTMLLinkAccessible(aElement, aContext->Document());
},
roles::LINK)
MARKUPMAP(abbr, New_HyperText, 0)
@ -30,26 +30,27 @@ MARKUPMAP(aside, New_HyperText, roles::LANDMARK)
MARKUPMAP(blockquote, New_HyperText, roles::BLOCKQUOTE)
MARKUPMAP(button,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLButtonAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(
button,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLButtonAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(caption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTable()) {
dom::HTMLTableElement* tableEl =
dom::HTMLTableElement::FromNode(aContext->GetContent());
if (tableEl && tableEl == aElement->GetParent() &&
tableEl->GetCaption() == aElement) {
return new HTMLCaptionAccessible(aElement,
aContext->Document());
}
}
return nullptr;
},
0)
MARKUPMAP(
caption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTable()) {
dom::HTMLTableElement* tableEl =
dom::HTMLTableElement::FromNode(aContext->GetContent());
if (tableEl && tableEl == aElement->GetParent() &&
tableEl->GetCaption() == aElement) {
return new HTMLCaptionAccessible(aElement, aContext->Document());
}
}
return nullptr;
},
0)
MARKUPMAP(dd, New_HTMLDtOrDd<HyperTextAccessibleWrap>, roles::DEFINITION)
@ -120,51 +121,56 @@ MARKUPMAP(
},
roles::SECTION)
MARKUPMAP(dl,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::DEFINITION_LIST)
MARKUPMAP(
dl,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::DEFINITION_LIST)
MARKUPMAP(dt, New_HTMLDtOrDd<HTMLLIAccessible>, roles::TERM)
MARKUPMAP(figcaption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
},
roles::CAPTION)
MARKUPMAP(
figcaption,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
},
roles::CAPTION)
MARKUPMAP(figure,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigureAccessible(aElement, aContext->Document());
},
roles::FIGURE, Attr(xmlroles, figure))
MARKUPMAP(
figure,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFigureAccessible(aElement, aContext->Document());
},
roles::FIGURE, Attr(xmlroles, figure))
MARKUPMAP(fieldset,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLGroupboxAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(
fieldset,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLGroupboxAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(form,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFormAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(
form,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLFormAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(footer,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement,
aContext->Document());
},
0)
MARKUPMAP(
footer,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(header,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement,
aContext->Document());
},
0)
MARKUPMAP(
header,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(h1, New_HyperText, roles::HEADING)
@ -178,71 +184,75 @@ MARKUPMAP(h5, New_HyperText, roles::HEADING)
MARKUPMAP(h6, New_HyperText, roles::HEADING)
MARKUPMAP(hr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHRAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(
hr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLHRAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(input,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// TODO(emilio): This would be faster if it used
// HTMLInputElement's already-parsed representation.
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::checkbox, eIgnoreCase)) {
return new CheckboxAccessible(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::image, eIgnoreCase)) {
return new HTMLButtonAccessible(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::radio, eIgnoreCase)) {
return new HTMLRadioButtonAccessible(aElement,
aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::time, eIgnoreCase)) {
return new EnumRoleAccessible<roles::GROUPING>(
aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::date, eIgnoreCase)) {
return new EnumRoleAccessible<roles::DATE_EDITOR>(
aElement, aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(
input,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// TODO(emilio): This would be faster if it used
// HTMLInputElement's already-parsed representation.
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::checkbox, eIgnoreCase)) {
return new CheckboxAccessible(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::image, eIgnoreCase)) {
return new HTMLButtonAccessible(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::radio, eIgnoreCase)) {
return new HTMLRadioButtonAccessible(aElement, aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::time, eIgnoreCase)) {
return new EnumRoleAccessible<roles::GROUPING>(aElement,
aContext->Document());
}
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::date, eIgnoreCase)) {
return new EnumRoleAccessible<roles::DATE_EDITOR>(aElement,
aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(ins, New_HyperText, roles::CONTENT_INSERTION)
MARKUPMAP(label,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLabelAccessible(aElement, aContext->Document());
},
roles::LABEL)
MARKUPMAP(
label,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLabelAccessible(aElement, aContext->Document());
},
roles::LABEL)
MARKUPMAP(legend,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLegendAccessible(aElement, aContext->Document());
},
roles::LABEL)
MARKUPMAP(
legend,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLLegendAccessible(aElement, aContext->Document());
},
roles::LABEL)
MARKUPMAP(li,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// If list item is a child of accessible list then create an
// accessible for it unconditionally by tag name. nsBlockFrame
// creates the list item accessible for other elements styled as
// list items.
if (aContext->IsList() &&
aContext->GetContent() == aElement->GetParent()) {
return new HTMLLIAccessible(aElement, aContext->Document());
}
MARKUPMAP(
li,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// If list item is a child of accessible list then create an
// accessible for it unconditionally by tag name. nsBlockFrame
// creates the list item accessible for other elements styled as
// list items.
if (aContext->IsList() &&
aContext->GetContent() == aElement->GetParent()) {
return new HTMLLIAccessible(aElement, aContext->Document());
}
return nullptr;
},
0)
return nullptr;
},
0)
MARKUPMAP(main, New_HyperText, roles::LANDMARK)
@ -301,31 +311,34 @@ MARKUPMAP(munderover_, New_HyperText, roles::MATHML_UNDER_OVER,
MARKUPMAP(mmultiscripts_, New_HyperText, roles::MATHML_MULTISCRIPTS)
MARKUPMAP(mtable_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE, AttrFromDOM(align, align),
AttrFromDOM(columnlines_, columnlines_),
AttrFromDOM(rowlines_, rowlines_))
MARKUPMAP(
mtable_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE, AttrFromDOM(align, align),
AttrFromDOM(columnlines_, columnlines_), AttrFromDOM(rowlines_, rowlines_))
MARKUPMAP(mlabeledtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_LABELED_ROW)
MARKUPMAP(
mlabeledtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_LABELED_ROW)
MARKUPMAP(mtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE_ROW)
MARKUPMAP(
mtr_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableRowAccessible(aElement, aContext->Document());
},
roles::MATHML_TABLE_ROW)
MARKUPMAP(mtd_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableCellAccessible(aElement, aContext->Document());
},
roles::MATHML_CELL)
MARKUPMAP(
mtd_,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLTableCellAccessible(aElement, aContext->Document());
},
roles::MATHML_CELL)
MARKUPMAP(maction_, New_HyperText, roles::MATHML_ACTION,
AttrFromDOM(actiontype_, actiontype_),
@ -356,173 +369,183 @@ MARKUPMAP(msline_, New_HyperText, roles::MATHML_STACK_LINE,
MARKUPMAP(nav, New_HyperText, roles::LANDMARK)
MARKUPMAP(ol,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST)
MARKUPMAP(
ol,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST)
MARKUPMAP(option,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptionAccessible(aElement,
aContext->Document());
},
0)
MARKUPMAP(
option,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptionAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(optgroup,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptGroupAccessible(aElement,
aContext->Document());
},
0)
MARKUPMAP(
optgroup,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSelectOptGroupAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(output,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLOutputAccessible(aElement, aContext->Document());
},
roles::SECTION, Attr(live, polite))
MARKUPMAP(
output,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLOutputAccessible(aElement, aContext->Document());
},
roles::SECTION, Attr(live, polite))
MARKUPMAP(p, nullptr, roles::PARAGRAPH)
MARKUPMAP(progress,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLProgressAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(
progress,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLProgressAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(q, New_HyperText, 0)
MARKUPMAP(section,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSectionAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(
section,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSectionAccessible(aElement, aContext->Document());
},
0)
MARKUPMAP(summary,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSummaryAccessible(aElement, aContext->Document());
},
roles::SUMMARY)
MARKUPMAP(
summary,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLSummaryAccessible(aElement, aContext->Document());
},
roles::SUMMARY)
MARKUPMAP(table,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableType) {
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(
table,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableType) {
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(time, New_HyperText, 0, Attr(xmlroles, time),
AttrFromDOM(datetime, datetime))
MARKUPMAP(tbody,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Expose this as a grouping if its frame type is non-standard.
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
return nullptr;
}
return new HyperTextAccessibleWrap(aElement, aContext->Document());
},
roles::GROUPING)
MARKUPMAP(
tbody,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Expose this as a grouping if its frame type is non-standard.
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
return nullptr;
}
return new HyperTextAccessibleWrap(aElement, aContext->Document());
},
roles::GROUPING)
MARKUPMAP(td,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() &&
aContext->GetContent() == aElement->GetParent()) {
// If HTML:td element is part of its HTML:table, which has CSS
// display style other than 'table', then create a generic table
// cell accessible, because there's no underlying table layout and
// thus native HTML table cell class doesn't work. The same is
// true if the cell itself has CSS display:block;.
if (!aContext->IsHTMLTableRow() ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableCellType)) {
return new ARIAGridCellAccessibleWrap(aElement,
aContext->Document());
}
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
return new HTMLTableHeaderCellAccessibleWrap(
aElement, aContext->Document());
}
}
return nullptr;
},
0)
MARKUPMAP(
td,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() &&
aContext->GetContent() == aElement->GetParent()) {
// If HTML:td element is part of its HTML:table, which has CSS
// display style other than 'table', then create a generic table
// cell accessible, because there's no underlying table layout and
// thus native HTML table cell class doesn't work. The same is
// true if the cell itself has CSS display:block;.
if (!aContext->IsHTMLTableRow() ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableCellType)) {
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
}
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
return new HTMLTableHeaderCellAccessibleWrap(aElement,
aContext->Document());
}
}
return nullptr;
},
0)
MARKUPMAP(tfoot,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Expose this as a grouping if its frame type is non-standard.
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
return nullptr;
}
return new HyperTextAccessibleWrap(aElement, aContext->Document());
},
roles::GROUPING)
MARKUPMAP(
tfoot,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Expose this as a grouping if its frame type is non-standard.
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
return nullptr;
}
return new HyperTextAccessibleWrap(aElement, aContext->Document());
},
roles::GROUPING)
MARKUPMAP(th,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() &&
aContext->GetContent() == aElement->GetParent()) {
if (!aContext->IsHTMLTableRow()) {
return new ARIAGridCellAccessibleWrap(aElement,
aContext->Document());
}
return new HTMLTableHeaderCellAccessibleWrap(
aElement, aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(
th,
[](Element* aElement, Accessible* aContext) -> Accessible* {
if (aContext->IsTableRow() &&
aContext->GetContent() == aElement->GetParent()) {
if (!aContext->IsHTMLTableRow()) {
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
}
return new HTMLTableHeaderCellAccessibleWrap(aElement,
aContext->Document());
}
return nullptr;
},
0)
MARKUPMAP(tfoot,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Expose this as a grouping if its frame type is non-standard.
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
return nullptr;
}
return new HyperTextAccessibleWrap(aElement, aContext->Document());
},
roles::GROUPING)
MARKUPMAP(
tfoot,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Expose this as a grouping if its frame type is non-standard.
if (aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
return nullptr;
}
return new HyperTextAccessibleWrap(aElement, aContext->Document());
},
roles::GROUPING)
MARKUPMAP(tr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// If HTML:tr element is part of its HTML:table, which has CSS
// display style other than 'table', then create a generic table row
// accessible, because there's no underlying table layout and thus
// native HTML table row class doesn't work. Refer to
// CreateAccessibleByFrameType dual logic.
Accessible* table = aContext->IsTable() ? aContext : nullptr;
if (!table && aContext->Parent() && aContext->Parent()->IsTable()) {
table = aContext->Parent();
}
if (table) {
nsIContent* parentContent = aElement->GetParent();
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
if (parentFrame && !parentFrame->IsTableWrapperFrame()) {
parentContent = parentContent->GetParent();
parentFrame = parentContent->GetPrimaryFrame();
if (table->GetContent() == parentContent &&
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableRowType))) {
return new ARIARowAccessible(aElement, aContext->Document());
}
}
}
return nullptr;
},
0)
MARKUPMAP(
tr,
[](Element* aElement, Accessible* aContext) -> Accessible* {
// If HTML:tr element is part of its HTML:table, which has CSS
// display style other than 'table', then create a generic table row
// accessible, because there's no underlying table layout and thus
// native HTML table row class doesn't work. Refer to
// CreateAccessibleByFrameType dual logic.
Accessible* table = aContext->IsTable() ? aContext : nullptr;
if (!table && aContext->Parent() && aContext->Parent()->IsTable()) {
table = aContext->Parent();
}
if (table) {
nsIContent* parentContent = aElement->GetParent();
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
if (parentFrame && !parentFrame->IsTableWrapperFrame()) {
parentContent = parentContent->GetParent();
parentFrame = parentContent->GetPrimaryFrame();
if (table->GetContent() == parentContent &&
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
(aElement->GetPrimaryFrame() &&
aElement->GetPrimaryFrame()->AccessibleType() !=
eHTMLTableRowType))) {
return new ARIARowAccessible(aElement, aContext->Document());
}
}
}
return nullptr;
},
0)
MARKUPMAP(ul,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST)
MARKUPMAP(
ul,
[](Element* aElement, Accessible* aContext) -> Accessible* {
return new HTMLListAccessible(aElement, aContext->Document());
},
roles::LIST)

View File

@ -197,8 +197,7 @@ void AnonymousContent::GetComputedStylePropertyValue(
aRv = cs->GetPropertyValue(aPropertyName, aResult);
}
void AnonymousContent::GetTargetIdForEvent(Event& aEvent, DOMString& aResult)
{
void AnonymousContent::GetTargetIdForEvent(Event& aEvent, DOMString& aResult) {
nsCOMPtr<Element> el = do_QueryInterface(aEvent.GetOriginalTarget());
if (el && el->IsInNativeAnonymousSubtree() && mContentNode->Contains(el)) {
aResult.SetKnownLiveAtom(el->GetID(), DOMString::eTreatNullAsNull);

View File

@ -143,20 +143,21 @@ RefPtr<PerformanceInfoPromise> DocGroup::ReportPerformanceInfo() {
RefPtr<DocGroup> self = this;
return CollectMemoryInfo(top, mainThread)
->Then(mainThread, __func__,
[self, host, pid, windowID, duration, isTopLevel,
items](const PerformanceMemoryInfo& aMemoryInfo) {
PerformanceInfo info =
PerformanceInfo(host, pid, windowID, duration,
self->mPerformanceCounter->GetID(), false,
isTopLevel, aMemoryInfo, items);
->Then(
mainThread, __func__,
[self, host, pid, windowID, duration, isTopLevel,
items](const PerformanceMemoryInfo& aMemoryInfo) {
PerformanceInfo info =
PerformanceInfo(host, pid, windowID, duration,
self->mPerformanceCounter->GetID(), false,
isTopLevel, aMemoryInfo, items);
return PerformanceInfoPromise::CreateAndResolve(std::move(info),
__func__);
},
[self](const nsresult rv) {
return PerformanceInfoPromise::CreateAndReject(rv, __func__);
});
return PerformanceInfoPromise::CreateAndResolve(std::move(info),
__func__);
},
[self](const nsresult rv) {
return PerformanceInfoPromise::CreateAndReject(rv, __func__);
});
}
nsresult DocGroup::Dispatch(TaskCategory aCategory,

View File

@ -47,8 +47,7 @@ size_t TreeOrderedArray<Node>::Insert(Node& aNode) {
};
size_t idx;
BinarySearchIf(mList, 0, mList.Length(),
PositionComparator(aNode), &idx);
BinarySearchIf(mList, 0, mList.Length(), PositionComparator(aNode), &idx);
mList.InsertElementAt(idx, &aNode);
return idx;
}

View File

@ -51,8 +51,7 @@ void OnPrefChange(const char* aPrefName, void*) {
void UIDirectionManager::Initialize() {
DebugOnly<nsresult> rv =
Preferences::RegisterCallback(OnPrefChange, "intl.uidirection");
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"intl.uidirection\"");
MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"intl.uidirection\"");
}
/* static */

View File

@ -1646,7 +1646,9 @@ MiscContainer* nsAttrValue::ClearMiscContainer() {
delete cont->mValue.mIntMargin;
break;
}
default: { break; }
default: {
break;
}
}
}
ResetMiscAtomOrString();

View File

@ -243,7 +243,9 @@ inline void nsAttrValue::ToString(mozilla::dom::DOMString& aResult) const {
aResult.SetKnownLiveAtom(atom, mozilla::dom::DOMString::eNullNotExpected);
break;
}
default: { ToString(aResult.AsAString()); }
default: {
ToString(aResult.AsAString());
}
}
}

View File

@ -426,7 +426,9 @@ nsresult nsCCUncollectableMarker::Observe(nsISupports* aSubject,
xpc_UnmarkSkippableJSHolders();
break;
}
default: { break; }
default: {
break;
}
}
return NS_OK;

View File

@ -437,7 +437,9 @@ Context::QuotaInitRunnable::Run() {
}
// -----
case STATE_WAIT_FOR_DIRECTORY_LOCK:
default: { MOZ_CRASH("unexpected state in QuotaInitRunnable"); }
default: {
MOZ_CRASH("unexpected state in QuotaInitRunnable");
}
}
if (resolver->Resolved()) {

View File

@ -893,7 +893,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CanvasRenderingContext2D)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
CanvasRenderingContext2D::ContextState::ContextState() = default;
CanvasRenderingContext2D::ContextState::ContextState() = default;
CanvasRenderingContext2D::ContextState::ContextState(const ContextState& aOther)
: fontGroup(aOther.fontGroup),

View File

@ -402,8 +402,8 @@ void WebGLContext::VertexAttribAnyPointer(bool isFuncInt, GLuint index,
}
WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index];
vd.VertexAttribPointer(isFuncInt, buffer, AutoAssertCast(size), type, normalized, stride,
byteOffset);
vd.VertexAttribPointer(isFuncInt, buffer, AutoAssertCast(size), type,
normalized, stride, byteOffset);
mBoundVertexArray->InvalidateCaches();
}

View File

@ -962,7 +962,7 @@ MOZ_ALWAYS_INLINE void
pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::None, uint8_t,
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
*dst = uint16_t(((src[0] & 0xF8) << 8) | ((src[1] & 0xFC) << 3) |
((src[2] & 0xF8) >> 3));
((src[2] & 0xF8) >> 3));
}
template <>
@ -974,7 +974,8 @@ pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::Premultiply,
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3));
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) |
((srcB & 0xF8) >> 3));
}
// FIXME: this routine is lossy and must be removed.
@ -987,7 +988,8 @@ pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::Unpremultiply,
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3));
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) |
((srcB & 0xF8) >> 3));
}
template <>
@ -1121,8 +1123,8 @@ template <>
MOZ_ALWAYS_INLINE void
pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::None, uint8_t,
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
*dst = uint16_t(((src[0] & 0xF0) << 8) | ((src[1] & 0xF0) << 4) | (src[2] & 0xF0) |
(src[3] >> 4));
*dst = uint16_t(((src[0] & 0xF0) << 8) | ((src[1] & 0xF0) << 4) |
(src[2] & 0xF0) | (src[3] >> 4));
}
template <>
@ -1135,7 +1137,7 @@ pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::Premultiply,
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
*dst = uint16_t(((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) |
(src[3] >> 4));
(src[3] >> 4));
}
// FIXME: this routine is lossy and must be removed.
@ -1149,7 +1151,7 @@ pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::Unpremultiply,
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
*dst = uint16_t(((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) |
(src[3] >> 4));
(src[3] >> 4));
}
template <>
@ -1157,7 +1159,7 @@ MOZ_ALWAYS_INLINE void
pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::None, uint8_t,
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
*dst = uint16_t(((src[0] & 0xF8) << 8) | ((src[1] & 0xF8) << 3) |
((src[2] & 0xF8) >> 2) | (src[3] >> 7));
((src[2] & 0xF8) >> 2) | (src[3] >> 7));
}
template <>
@ -1169,8 +1171,8 @@ pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::Premultiply,
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) |
(src[3] >> 7));
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) |
((srcB & 0xF8) >> 2) | (src[3] >> 7));
}
// FIXME: this routine is lossy and must be removed.
@ -1183,8 +1185,8 @@ pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::Unpremultiply,
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) |
(src[3] >> 7));
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) |
((srcB & 0xF8) >> 2) | (src[3] >> 7));
}
template <>

View File

@ -270,7 +270,8 @@ class WebGLTexture final : public nsWrapperCache,
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
return AutoAssertCast(rawTexImageTarget - LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X);
return AutoAssertCast(rawTexImageTarget -
LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X);
default:
return 0;

View File

@ -60,14 +60,14 @@ inline void* calloc(const ForbidNarrowing<size_t> n,
namespace detail {
template<typename From>
template <typename From>
class AutoAssertCastT final {
const From mVal;
public:
explicit AutoAssertCastT(const From val) : mVal(val) { }
public:
explicit AutoAssertCastT(const From val) : mVal(val) {}
template<typename To>
template <typename To>
operator To() const {
return AssertedCast<To>(mVal);
}
@ -75,7 +75,7 @@ public:
} // namespace detail
template<typename From>
template <typename From>
inline auto AutoAssertCast(const From val) {
return detail::AutoAssertCastT<From>(val);
}

View File

@ -150,19 +150,20 @@ already_AddRefed<Promise> Client::Focus(ErrorResult& aRv) {
MakeRefPtr<DOMMozPromiseRequestHolder<ClientStatePromise>>(mGlobal);
mHandle->Focus()
->Then(mGlobal->EventTargetFor(TaskCategory::Other), __func__,
[ipcClientInfo, holder, outerPromise](const ClientState& aResult) {
holder->Complete();
NS_ENSURE_TRUE_VOID(holder->GetParentObject());
RefPtr<Client> newClient = new Client(
holder->GetParentObject(),
ClientInfoAndState(ipcClientInfo, aResult.ToIPC()));
outerPromise->MaybeResolve(newClient);
},
[holder, outerPromise](nsresult aResult) {
holder->Complete();
outerPromise->MaybeReject(aResult);
})
->Then(
mGlobal->EventTargetFor(TaskCategory::Other), __func__,
[ipcClientInfo, holder, outerPromise](const ClientState& aResult) {
holder->Complete();
NS_ENSURE_TRUE_VOID(holder->GetParentObject());
RefPtr<Client> newClient =
new Client(holder->GetParentObject(),
ClientInfoAndState(ipcClientInfo, aResult.ToIPC()));
outerPromise->MaybeResolve(newClient);
},
[holder, outerPromise](nsresult aResult) {
holder->Complete();
outerPromise->MaybeReject(aResult);
})
->Track(*holder);
return outerPromise.forget();

View File

@ -32,15 +32,16 @@ void StartClientManagerOp(Func aFunc, const Arg& aArg, nsIGlobalObject* aGlobal,
MakeRefPtr<DOMMozPromiseRequestHolder<ClientOpPromise>>(aGlobal);
aFunc(aArg, target)
->Then(target, __func__,
[aResolve, holder](const ClientOpResult& aResult) {
holder->Complete();
aResolve(aResult);
},
[aReject, holder](nsresult aResult) {
holder->Complete();
aReject(aResult);
})
->Then(
target, __func__,
[aResolve, holder](const ClientOpResult& aResult) {
holder->Complete();
aResolve(aResult);
},
[aReject, holder](nsresult aResult) {
holder->Complete();
aReject(aResult);
})
->Track(*holder);
}

View File

@ -80,30 +80,31 @@ already_AddRefed<Promise> Clients::Get(const nsAString& aClientID,
MakeRefPtr<DOMMozPromiseRequestHolder<ClientOpPromise>>(mGlobal);
innerPromise
->Then(target, __func__,
[outerPromise, holder, scope](const ClientOpResult& aResult) {
holder->Complete();
NS_ENSURE_TRUE_VOID(holder->GetParentObject());
RefPtr<Client> client = new Client(
holder->GetParentObject(), aResult.get_ClientInfoAndState());
if (client->GetStorageAccess() ==
nsContentUtils::StorageAccess::eAllow) {
outerPromise->MaybeResolve(std::move(client));
return;
}
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
"Clients::Get() storage denied", [scope] {
ServiceWorkerManager::LocalizeAndReportToAllClients(
scope, "ServiceWorkerGetClientStorageError",
nsTArray<nsString>());
});
SystemGroup::Dispatch(TaskCategory::Other, r.forget());
outerPromise->MaybeResolveWithUndefined();
},
[outerPromise, holder](nsresult aResult) {
holder->Complete();
outerPromise->MaybeResolveWithUndefined();
})
->Then(
target, __func__,
[outerPromise, holder, scope](const ClientOpResult& aResult) {
holder->Complete();
NS_ENSURE_TRUE_VOID(holder->GetParentObject());
RefPtr<Client> client = new Client(
holder->GetParentObject(), aResult.get_ClientInfoAndState());
if (client->GetStorageAccess() ==
nsContentUtils::StorageAccess::eAllow) {
outerPromise->MaybeResolve(std::move(client));
return;
}
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
"Clients::Get() storage denied", [scope] {
ServiceWorkerManager::LocalizeAndReportToAllClients(
scope, "ServiceWorkerGetClientStorageError",
nsTArray<nsString>());
});
SystemGroup::Dispatch(TaskCategory::Other, r.forget());
outerPromise->MaybeResolveWithUndefined();
},
[outerPromise, holder](nsresult aResult) {
holder->Complete();
outerPromise->MaybeResolveWithUndefined();
})
->Track(*holder);
return outerPromise.forget();

View File

@ -110,13 +110,14 @@ RefPtr<GenericPromise> ClientHandle::Control(
MOZ_RELEASE_ASSERT(ClientMatchPrincipalInfo(mClientInfo.PrincipalInfo(),
aServiceWorker.PrincipalInfo()));
StartOp(ClientControlledArgs(aServiceWorker.ToIPC()),
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Resolve(true, __func__);
},
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Reject(aResult.get_nsresult(), __func__);
});
StartOp(
ClientControlledArgs(aServiceWorker.ToIPC()),
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Resolve(true, __func__);
},
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Reject(aResult.get_nsresult(), __func__);
});
return outerPromise.forget();
}
@ -125,14 +126,15 @@ RefPtr<ClientStatePromise> ClientHandle::Focus() {
RefPtr<ClientStatePromise::Private> outerPromise =
new ClientStatePromise::Private(__func__);
StartOp(ClientFocusArgs(),
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Resolve(
ClientState::FromIPC(aResult.get_IPCClientState()), __func__);
},
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Reject(aResult.get_nsresult(), __func__);
});
StartOp(
ClientFocusArgs(),
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Resolve(
ClientState::FromIPC(aResult.get_IPCClientState()), __func__);
},
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Reject(aResult.get_nsresult(), __func__);
});
return outerPromise.forget();
}
@ -156,13 +158,14 @@ RefPtr<GenericPromise> ClientHandle::PostMessage(
RefPtr<GenericPromise::Private> outerPromise =
new GenericPromise::Private(__func__);
StartOp(args,
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Resolve(true, __func__);
},
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Reject(aResult.get_nsresult(), __func__);
});
StartOp(
args,
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Resolve(true, __func__);
},
[outerPromise](const ClientOpResult& aResult) {
outerPromise->Reject(aResult.get_nsresult(), __func__);
});
return outerPromise.forget();
}

View File

@ -62,15 +62,16 @@ void ClientHandleOpParent::Init(const ClientOpConstructorArgs& aArgs) {
// Capturing 'this' is safe here because we disconnect the promise in
// ActorDestroy() which ensures neither lambda is called if the actor
// is destroyed before the source operation completes.
p->Then(GetCurrentThreadSerialEventTarget(), __func__,
[this](const ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
Unused << PClientHandleOpParent::Send__delete__(this, aResult);
},
[this](nsresult aRv) {
mPromiseRequestHolder.Complete();
Unused << PClientHandleOpParent::Send__delete__(this, aRv);
})
p->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[this](const ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
Unused << PClientHandleOpParent::Send__delete__(this, aResult);
},
[this](nsresult aRv) {
mPromiseRequestHolder.Complete();
Unused << PClientHandleOpParent::Send__delete__(this, aRv);
})
->Track(mPromiseRequestHolder);
}

View File

@ -24,15 +24,16 @@ void ClientManagerOpParent::DoServiceOp(Method aMethod, Args&&... aArgs) {
// Capturing `this` is safe here because we disconnect the promise in
// ActorDestroy() which ensures neither lambda is called if the actor
// is destroyed before the source operation completes.
p->Then(GetCurrentThreadSerialEventTarget(), __func__,
[this](const mozilla::dom::ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
Unused << PClientManagerOpParent::Send__delete__(this, aResult);
},
[this](nsresult aRv) {
mPromiseRequestHolder.Complete();
Unused << PClientManagerOpParent::Send__delete__(this, aRv);
})
p->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[this](const mozilla::dom::ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
Unused << PClientManagerOpParent::Send__delete__(this, aResult);
},
[this](nsresult aRv) {
mPromiseRequestHolder.Complete();
Unused << PClientManagerOpParent::Send__delete__(this, aRv);
})
->Track(mPromiseRequestHolder);
}

View File

@ -287,15 +287,16 @@ void ClientNavigateOpChild::Init(const ClientNavigateOpConstructorArgs& aArgs) {
// Capturing `this` is safe here since we clear the mPromiseRequestHolder in
// ActorDestroy.
promise
->Then(mSerialEventTarget, __func__,
[this](const ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
PClientNavigateOpChild::Send__delete__(this, aResult);
},
[this](nsresult aResult) {
mPromiseRequestHolder.Complete();
PClientNavigateOpChild::Send__delete__(this, aResult);
})
->Then(
mSerialEventTarget, __func__,
[this](const ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
PClientNavigateOpChild::Send__delete__(this, aResult);
},
[this](nsresult aResult) {
mPromiseRequestHolder.Complete();
PClientNavigateOpChild::Send__delete__(this, aResult);
})
->Track(mPromiseRequestHolder);
}

View File

@ -22,15 +22,16 @@ void ClientOpenWindowOpChild::ActorDestroy(ActorDestroyReason aReason) {
void ClientOpenWindowOpChild::Init(const ClientOpenWindowArgs& aArgs) {
DoOpenWindow(aArgs)
->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
[this](const ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
PClientOpenWindowOpChild::Send__delete__(this, aResult);
},
[this](nsresult aResult) {
mPromiseRequestHolder.Complete();
PClientOpenWindowOpChild::Send__delete__(this, aResult);
})
->Then(
SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
[this](const ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
PClientOpenWindowOpChild::Send__delete__(this, aResult);
},
[this](nsresult aResult) {
mPromiseRequestHolder.Complete();
PClientOpenWindowOpChild::Send__delete__(this, aResult);
})
->Track(mPromiseRequestHolder);
}

View File

@ -302,9 +302,10 @@ void WaitForLoad(const ClientOpenWindowArgs& aArgs,
}
// Hold the listener alive until the promise settles
ref->Then(aOuterWindow->EventTargetFor(TaskCategory::Other), __func__,
[listener](const ClientOpResult& aResult) {},
[listener](nsresult aResult) {});
ref->Then(
aOuterWindow->EventTargetFor(TaskCategory::Other), __func__,
[listener](const ClientOpResult& aResult) {},
[listener](nsresult aResult) {});
}
#ifdef MOZ_WIDGET_ANDROID

View File

@ -35,7 +35,9 @@ bool ClientMatchPrincipalInfo(const PrincipalInfo& aLeft,
// null principal never matches
return false;
}
default: { break; }
default: {
break;
}
}
// Clients (windows/workers) should never have an expanded principal type.

View File

@ -603,15 +603,16 @@ RefPtr<ClientOpPromise> ClientSource::Claim(const ClientClaimArgs& aArgs) {
auto holder = MakeRefPtr<DOMMozPromiseRequestHolder<GenericPromise>>(global);
innerPromise
->Then(mEventTarget, __func__,
[outerPromise, holder](bool aResult) {
holder->Complete();
outerPromise->Resolve(NS_OK, __func__);
},
[outerPromise, holder](nsresult aResult) {
holder->Complete();
outerPromise->Reject(aResult, __func__);
})
->Then(
mEventTarget, __func__,
[outerPromise, holder](bool aResult) {
holder->Complete();
outerPromise->Resolve(NS_OK, __func__);
},
[outerPromise, holder](nsresult aResult) {
holder->Complete();
outerPromise->Reject(aResult, __func__);
})
->Track(*holder);
return outerPromise.forget();

View File

@ -56,15 +56,16 @@ void ClientSourceOpChild::DoSourceOp(Method aMethod, const Args& aArgs) {
// If the ClientSource is doing something async it may throw away the
// promise on its side if the global is closed.
promise
->Then(target, __func__,
[this, promise](const mozilla::dom::ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
Unused << PClientSourceOpChild::Send__delete__(this, aResult);
},
[this, promise](nsresult aRv) {
mPromiseRequestHolder.Complete();
Unused << PClientSourceOpChild::Send__delete__(this, aRv);
})
->Then(
target, __func__,
[this, promise](const mozilla::dom::ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
Unused << PClientSourceOpChild::Send__delete__(this, aResult);
},
[this, promise](nsresult aRv) {
mPromiseRequestHolder.Complete();
Unused << PClientSourceOpChild::Send__delete__(this, aRv);
})
->Track(mPromiseRequestHolder);
}

View File

@ -68,8 +68,8 @@ class ClientThing {
// Conditionally execute the given callable based on the current state.
template <typename Callable>
void MaybeExecute(const Callable& aSuccess,
const std::function<void()>& aFailure = [] {}) {
void MaybeExecute(
const Callable& aSuccess, const std::function<void()>& aFailure = [] {}) {
AssertIsValid();
if (mShutdown) {
aFailure();

View File

@ -58,7 +58,9 @@ bool ClientIsValidPrincipalInfo(const PrincipalInfo& aPrincipalInfo) {
// cases in the future.
return specOrigin == originOrigin;
}
default: { break; }
default: {
break;
}
}
// Windows and workers should not have expanded URLs, etc.
@ -144,7 +146,9 @@ bool ClientIsValidCreationURL(const PrincipalInfo& aPrincipalInfo,
// queries anyway.
return true;
}
default: { break; }
default: {
break;
}
}
// Clients (windows/workers) should never have an expanded principal type.

View File

@ -29,11 +29,12 @@ static NotNull<const Encoding*> SearchEncodingProp(
const EncodingProp (&aProperties)[N], const nsACString& aKey) {
const nsCString& flat = PromiseFlatCString(aKey);
size_t index;
if (!BinarySearchIf(aProperties, 0, ArrayLength(aProperties),
[&flat](const EncodingProp& aProperty) {
return flat.Compare(aProperty.mKey);
},
&index)) {
if (!BinarySearchIf(
aProperties, 0, ArrayLength(aProperties),
[&flat](const EncodingProp& aProperty) {
return flat.Compare(aProperty.mKey);
},
&index)) {
return WINDOWS_1252_ENCODING;
}
return aProperties[index].mValue;

View File

@ -1296,7 +1296,9 @@ void EventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent,
remote->SendPluginEvent(*aEvent->AsPluginEvent());
return;
}
default: { MOZ_CRASH("Attempt to send non-whitelisted event?"); }
default: {
MOZ_CRASH("Attempt to send non-whitelisted event?");
}
}
}

View File

@ -6450,24 +6450,25 @@ bool HTMLMediaElement::TryRemoveMediaKeysAssociation() {
if (mDecoder) {
RefPtr<HTMLMediaElement> self = this;
mDecoder->SetCDMProxy(nullptr)
->Then(mAbstractMainThread, __func__,
[self]() {
self->mSetCDMRequest.Complete();
->Then(
mAbstractMainThread, __func__,
[self]() {
self->mSetCDMRequest.Complete();
self->RemoveMediaKeys();
if (self->AttachNewMediaKeys()) {
// No incoming MediaKeys object or MediaDecoder is not
// created yet.
self->MakeAssociationWithCDMResolved();
}
},
[self](const MediaResult& aResult) {
self->mSetCDMRequest.Complete();
// 5.2.4 If the preceding step failed, let this object's
// attaching media keys value be false and reject promise with
// a new DOMException whose name is the appropriate error name.
self->SetCDMProxyFailure(aResult);
})
self->RemoveMediaKeys();
if (self->AttachNewMediaKeys()) {
// No incoming MediaKeys object or MediaDecoder is not
// created yet.
self->MakeAssociationWithCDMResolved();
}
},
[self](const MediaResult& aResult) {
self->mSetCDMRequest.Complete();
// 5.2.4 If the preceding step failed, let this object's
// attaching media keys value be false and reject promise with
// a new DOMException whose name is the appropriate error name.
self->SetCDMProxyFailure(aResult);
})
->Track(mSetCDMRequest);
return false;
}
@ -6523,15 +6524,16 @@ bool HTMLMediaElement::TryMakeAssociationWithCDM(CDMProxy* aProxy) {
// HTMLMediaElement should resolve or reject the DOM promise.
RefPtr<HTMLMediaElement> self = this;
mDecoder->SetCDMProxy(aProxy)
->Then(mAbstractMainThread, __func__,
[self]() {
self->mSetCDMRequest.Complete();
self->MakeAssociationWithCDMResolved();
},
[self](const MediaResult& aResult) {
self->mSetCDMRequest.Complete();
self->SetCDMProxyFailure(aResult);
})
->Then(
mAbstractMainThread, __func__,
[self]() {
self->mSetCDMRequest.Complete();
self->MakeAssociationWithCDMResolved();
},
[self](const MediaResult& aResult) {
self->mSetCDMRequest.Complete();
self->SetCDMProxyFailure(aResult);
})
->Track(mSetCDMRequest);
return false;
}

View File

@ -1720,13 +1720,14 @@ mozilla::ipc::IPCResult BackgroundFactoryRequestChild::RecvPermissionChallenge(
IPC::Principal ipcPrincipal(principal);
tabChild->SendIndexedDBPermissionRequest(ipcPrincipal)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[this](const uint32_t& aPermission) {
this->AssertIsOnOwningThread();
MaybeCollectGarbageOnIPCMessage();
this->SendPermissionRetry();
},
[](const mozilla::ipc::ResponseRejectReason) {});
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[this](const uint32_t& aPermission) {
this->AssertIsOnOwningThread();
MaybeCollectGarbageOnIPCMessage();
this->SendPermissionRetry();
},
[](const mozilla::ipc::ResponseRejectReason) {});
return IPC_OK();
}

View File

@ -67,11 +67,12 @@ bool SharedStringMap::Get(const nsCString& aKey, nsAString& aValue) {
bool SharedStringMap::Find(const nsCString& aKey, size_t* aIndex) {
const auto& keys = KeyTable();
return BinarySearchIf(Entries(), 0, EntryCount(),
[&](const Entry& aEntry) {
return aKey.Compare(keys.GetBare(aEntry.mKey));
},
aIndex);
return BinarySearchIf(
Entries(), 0, EntryCount(),
[&](const Entry& aEntry) {
return aKey.Compare(keys.GetBare(aEntry.mKey));
},
aIndex);
}
void SharedStringMapBuilder::Add(const nsCString& aKey,

View File

@ -219,7 +219,9 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
break;
}
default: { MOZ_CRASH(); }
default: {
MOZ_CRASH();
}
}
bool rv;

View File

@ -158,7 +158,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabParent)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITabParent)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION(TabParent, mFrameElement, mBrowserDOMWindow, mLoadContext, mFrameLoader, mBrowsingContext)
NS_IMPL_CYCLE_COLLECTION(TabParent, mFrameElement, mBrowserDOMWindow,
mLoadContext, mFrameLoader, mBrowsingContext)
NS_IMPL_CYCLE_COLLECTING_ADDREF(TabParent)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TabParent)
@ -3047,18 +3048,19 @@ TabParent::GetContentBlockingLog(Promise** aPromise) {
copy.forget(aPromise);
auto cblPromise = SendGetContentBlockingLog();
cblPromise->Then(GetMainThreadSerialEventTarget(), __func__,
[jsPromise](Tuple<nsCString, bool>&& aResult) {
if (Get<1>(aResult)) {
NS_ConvertUTF8toUTF16 utf16(Get<0>(aResult));
jsPromise->MaybeResolve(std::move(utf16));
} else {
jsPromise->MaybeRejectWithUndefined();
}
},
[jsPromise](ResponseRejectReason&& aReason) {
jsPromise->MaybeRejectWithUndefined();
});
cblPromise->Then(
GetMainThreadSerialEventTarget(), __func__,
[jsPromise](Tuple<nsCString, bool>&& aResult) {
if (Get<1>(aResult)) {
NS_ConvertUTF8toUTF16 utf16(Get<0>(aResult));
jsPromise->MaybeResolve(std::move(utf16));
} else {
jsPromise->MaybeRejectWithUndefined();
}
},
[jsPromise](ResponseRejectReason&& aReason) {
jsPromise->MaybeRejectWithUndefined();
});
return NS_OK;
}
@ -3158,13 +3160,14 @@ void TabParent::RequestRootPaint(gfx::CrossProcessPaint* aPaint, IntRect aRect,
RefPtr<gfx::CrossProcessPaint> paint(aPaint);
TabId tabId(GetTabId());
promise->Then(GetMainThreadSerialEventTarget(), __func__,
[paint, tabId](PaintFragment&& aFragment) {
paint->ReceiveFragment(tabId, std::move(aFragment));
},
[paint, tabId](ResponseRejectReason&& aReason) {
paint->LostFragment(tabId);
});
promise->Then(
GetMainThreadSerialEventTarget(), __func__,
[paint, tabId](PaintFragment&& aFragment) {
paint->ReceiveFragment(tabId, std::move(aFragment));
},
[paint, tabId](ResponseRejectReason&& aReason) {
paint->LostFragment(tabId);
});
}
void TabParent::RequestSubPaint(gfx::CrossProcessPaint* aPaint, float aScale,
@ -3173,13 +3176,14 @@ void TabParent::RequestSubPaint(gfx::CrossProcessPaint* aPaint, float aScale,
RefPtr<gfx::CrossProcessPaint> paint(aPaint);
TabId tabId(GetTabId());
promise->Then(GetMainThreadSerialEventTarget(), __func__,
[paint, tabId](PaintFragment&& aFragment) {
paint->ReceiveFragment(tabId, std::move(aFragment));
},
[paint, tabId](ResponseRejectReason&& aReason) {
paint->LostFragment(tabId);
});
promise->Then(
GetMainThreadSerialEventTarget(), __func__,
[paint, tabId](PaintFragment&& aFragment) {
paint->ReceiveFragment(tabId, std::move(aFragment));
},
[paint, tabId](ResponseRejectReason&& aReason) {
paint->LostFragment(tabId);
});
}
mozilla::ipc::IPCResult TabParent::RecvPaintWhileInterruptingJSNoOp(

View File

@ -282,15 +282,15 @@ void BenchmarkPlayback::GlobalShutdown() {
if (mDecoder) {
RefPtr<Benchmark> ref(mGlobalState);
mDecoder->Flush()->Then(Thread(), __func__,
[ref, this]() {
mDecoder->Shutdown()->Then(
Thread(), __func__,
[ref, this]() { FinalizeShutdown(); },
[]() { MOZ_CRASH("not reached"); });
mDecoder = nullptr;
},
[]() { MOZ_CRASH("not reached"); });
mDecoder->Flush()->Then(
Thread(), __func__,
[ref, this]() {
mDecoder->Shutdown()->Then(
Thread(), __func__, [ref, this]() { FinalizeShutdown(); },
[]() { MOZ_CRASH("not reached"); });
mDecoder = nullptr;
},
[]() { MOZ_CRASH("not reached"); });
} else {
FinalizeShutdown();
}
@ -345,34 +345,36 @@ void BenchmarkPlayback::InputExhausted() {
mSampleIndex++;
if (mSampleIndex == mSamples.Length() && !ref->mParameters.mStopAtFrame) {
// Complete current frame decode then drain if still necessary.
p->Then(Thread(), __func__,
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
Output(std::move(aResults));
if (!mFinished) {
mDecoder->Drain()->Then(
Thread(), __func__,
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
mDrained = true;
Output(std::move(aResults));
MOZ_ASSERT(mFinished, "We must be done now");
},
[ref, this](const MediaResult& aError) { Error(aError); });
}
},
[ref, this](const MediaResult& aError) { Error(aError); });
p->Then(
Thread(), __func__,
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
Output(std::move(aResults));
if (!mFinished) {
mDecoder->Drain()->Then(
Thread(), __func__,
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
mDrained = true;
Output(std::move(aResults));
MOZ_ASSERT(mFinished, "We must be done now");
},
[ref, this](const MediaResult& aError) { Error(aError); });
}
},
[ref, this](const MediaResult& aError) { Error(aError); });
} else {
if (mSampleIndex == mSamples.Length() && ref->mParameters.mStopAtFrame) {
mSampleIndex = 0;
}
// Continue decoding
p->Then(Thread(), __func__,
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
Output(std::move(aResults));
if (!mFinished) {
InputExhausted();
}
},
[ref, this](const MediaResult& aError) { Error(aError); });
p->Then(
Thread(), __func__,
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
Output(std::move(aResults));
if (!mFinished) {
InputExhausted();
}
},
[ref, this](const MediaResult& aError) { Error(aError); });
}
}

View File

@ -387,19 +387,20 @@ void ChannelMediaDecoder::DownloadProgressed() {
MediaStatistics stats = GetStatistics(rate, res, pos);
return StatsPromise::CreateAndResolve(stats, __func__);
})
->Then(mAbstractMainThread, __func__,
[=, self = RefPtr<ChannelMediaDecoder>(this)](
MediaStatistics aStats) {
if (IsShutdown()) {
return;
}
mCanPlayThrough = aStats.CanPlayThrough();
GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough);
mResource->ThrottleReadahead(ShouldThrottleDownload(aStats));
// Update readyState since mCanPlayThrough might have changed.
GetOwner()->UpdateReadyState();
},
[]() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); });
->Then(
mAbstractMainThread, __func__,
[=,
self = RefPtr<ChannelMediaDecoder>(this)](MediaStatistics aStats) {
if (IsShutdown()) {
return;
}
mCanPlayThrough = aStats.CanPlayThrough();
GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough);
mResource->ThrottleReadahead(ShouldThrottleDownload(aStats));
// Update readyState since mCanPlayThrough might have changed.
GetOwner()->UpdateReadyState();
},
[]() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); });
}
/* static */ ChannelMediaDecoder::PlaybackRateInfo

View File

@ -1055,11 +1055,12 @@ void DOMMediaStream::BlockPlaybackTrack(TrackPort* aTrack) {
RefPtr<DOMMediaStream> that = this;
aTrack
->BlockSourceTrackId(aTrack->GetTrack()->mTrackID, BlockingMode::CREATION)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[this, that](bool aIgnore) { NotifyPlaybackTrackBlocked(); },
[](const nsresult& aIgnore) {
NS_ERROR("Could not remove track from MSG");
});
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[this, that](bool aIgnore) { NotifyPlaybackTrackBlocked(); },
[](const nsresult& aIgnore) {
NS_ERROR("Could not remove track from MSG");
});
}
void DOMMediaStream::NotifyPlaybackTrackBlocked() {

View File

@ -316,11 +316,12 @@ class MediaDecoderStateMachine::DecodeMetadataState
// a raw pointer here.
Reader()
->ReadMetadata()
->Then(OwnerThread(), __func__,
[this](MetadataHolder&& aMetadata) {
OnMetadataRead(std::move(aMetadata));
},
[this](const MediaResult& aError) { OnMetadataNotRead(aError); })
->Then(
OwnerThread(), __func__,
[this](MetadataHolder&& aMetadata) {
OnMetadataRead(std::move(aMetadata));
},
[this](const MediaResult& aError) { OnMetadataNotRead(aError); })
->Track(mMetadataRequest);
}
@ -710,12 +711,13 @@ class MediaDecoderStateMachine::DecodingState
TimeStamp target =
TimeStamp::Now() + TimeDuration::FromMilliseconds(timeout);
mDormantTimer.Ensure(target,
[this]() {
mDormantTimer.CompleteRequest();
SetState<DormantState>();
},
[this]() { mDormantTimer.CompleteRequest(); });
mDormantTimer.Ensure(
target,
[this]() {
mDormantTimer.CompleteRequest();
SetState<DormantState>();
},
[this]() { mDormantTimer.CompleteRequest(); });
}
// Time at which we started decoding.
@ -818,38 +820,39 @@ class MediaDecoderStateMachine::LoopingDecodingState
Reader()->ResetDecode(TrackInfo::kAudioTrack);
Reader()
->Seek(SeekTarget(media::TimeUnit::Zero(), SeekTarget::Accurate))
->Then(OwnerThread(), __func__,
[this]() -> void {
mAudioSeekRequest.Complete();
SLOG(
"seeking completed, start to request first sample, "
"queueing audio task - queued=%zu, decoder-queued=%zu",
AudioQueue().GetSize(),
Reader()->SizeOfAudioQueueInFrames());
->Then(
OwnerThread(), __func__,
[this]() -> void {
mAudioSeekRequest.Complete();
SLOG(
"seeking completed, start to request first sample, "
"queueing audio task - queued=%zu, decoder-queued=%zu",
AudioQueue().GetSize(), Reader()->SizeOfAudioQueueInFrames());
Reader()
->RequestAudioData()
->Then(OwnerThread(), __func__,
[this](RefPtr<AudioData> aAudio) {
mIsReachingAudioEOS = false;
mAudioDataRequest.Complete();
SLOG(
"got audio decoded sample "
"[%" PRId64 ",%" PRId64 "]",
aAudio->mTime.ToMicroseconds(),
aAudio->GetEndTime().ToMicroseconds());
HandleAudioDecoded(aAudio);
},
[this](const MediaResult& aError) {
mAudioDataRequest.Complete();
HandleError(aError);
})
->Track(mAudioDataRequest);
},
[this](const SeekRejectValue& aReject) -> void {
mAudioSeekRequest.Complete();
HandleError(aReject.mError);
})
Reader()
->RequestAudioData()
->Then(
OwnerThread(), __func__,
[this](RefPtr<AudioData> aAudio) {
mIsReachingAudioEOS = false;
mAudioDataRequest.Complete();
SLOG(
"got audio decoded sample "
"[%" PRId64 ",%" PRId64 "]",
aAudio->mTime.ToMicroseconds(),
aAudio->GetEndTime().ToMicroseconds());
HandleAudioDecoded(aAudio);
},
[this](const MediaResult& aError) {
mAudioDataRequest.Complete();
HandleError(aError);
})
->Track(mAudioDataRequest);
},
[this](const SeekRejectValue& aReject) -> void {
mAudioSeekRequest.Complete();
HandleError(aReject.mError);
})
->Track(mAudioSeekRequest);
}
@ -1233,17 +1236,18 @@ class MediaDecoderStateMachine::AccurateSeekingState
Reader()
->WaitForData(aReject.mType)
->Then(OwnerThread(), __func__,
[this](MediaData::Type aType) {
SLOG("OnSeekRejected wait promise resolved");
mWaitRequest.Complete();
DemuxerSeek();
},
[this](const WaitForDataRejectValue& aRejection) {
SLOG("OnSeekRejected wait promise rejected");
mWaitRequest.Complete();
mMaster->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
})
->Then(
OwnerThread(), __func__,
[this](MediaData::Type aType) {
SLOG("OnSeekRejected wait promise resolved");
mWaitRequest.Complete();
DemuxerSeek();
},
[this](const WaitForDataRejectValue& aRejection) {
SLOG("OnSeekRejected wait promise rejected");
mWaitRequest.Complete();
mMaster->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
})
->Track(mWaitRequest);
return;
}
@ -2131,9 +2135,10 @@ void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding(
RefPtr<AbstractThread> mainThread = mMaster->mAbstractMainThread;
SetSeekingState(std::move(seekJob), EventVisibility::Suppressed)
->Then(mainThread, __func__,
[start, info, hw]() { ReportRecoveryTelemetry(start, info, hw); },
[]() {});
->Then(
mainThread, __func__,
[start, info, hw]() { ReportRecoveryTelemetry(start, info, hw); },
[]() {});
}
RefPtr<MediaDecoder::SeekPromise>
@ -2968,9 +2973,9 @@ void MediaDecoderStateMachine::SetVideoDecodeModeInternal(
TimeStamp target = TimeStamp::Now() + SuspendBackgroundVideoDelay();
RefPtr<MediaDecoderStateMachine> self = this;
mVideoDecodeSuspendTimer.Ensure(target,
[=]() { self->OnSuspendTimerResolved(); },
[]() { MOZ_DIAGNOSTIC_ASSERT(false); });
mVideoDecodeSuspendTimer.Ensure(
target, [=]() { self->OnSuspendTimerResolved(); },
[]() { MOZ_DIAGNOSTIC_ASSERT(false); });
mOnPlaybackEvent.Notify(MediaPlaybackEvent::StartVideoSuspendTimer);
return;
}
@ -3064,36 +3069,37 @@ void MediaDecoderStateMachine::RequestAudioData() {
RefPtr<MediaDecoderStateMachine> self = this;
mReader->RequestAudioData()
->Then(OwnerThread(), __func__,
[this, self](RefPtr<AudioData> aAudio) {
MOZ_ASSERT(aAudio);
mAudioDataRequest.Complete();
// audio->GetEndTime() is not always mono-increasing in chained
// ogg.
mDecodedAudioEndTime =
std::max(aAudio->GetEndTime(), mDecodedAudioEndTime);
LOGV("OnAudioDecoded [%" PRId64 ",%" PRId64 "]",
aAudio->mTime.ToMicroseconds(),
aAudio->GetEndTime().ToMicroseconds());
mStateObj->HandleAudioDecoded(aAudio);
},
[this, self](const MediaResult& aError) {
LOGV("OnAudioNotDecoded aError=%s", aError.ErrorName().get());
mAudioDataRequest.Complete();
switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
mStateObj->HandleWaitingForAudio();
break;
case NS_ERROR_DOM_MEDIA_CANCELED:
mStateObj->HandleAudioCanceled();
break;
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
mStateObj->HandleEndOfAudio();
break;
default:
DecodeError(aError);
}
})
->Then(
OwnerThread(), __func__,
[this, self](RefPtr<AudioData> aAudio) {
MOZ_ASSERT(aAudio);
mAudioDataRequest.Complete();
// audio->GetEndTime() is not always mono-increasing in chained
// ogg.
mDecodedAudioEndTime =
std::max(aAudio->GetEndTime(), mDecodedAudioEndTime);
LOGV("OnAudioDecoded [%" PRId64 ",%" PRId64 "]",
aAudio->mTime.ToMicroseconds(),
aAudio->GetEndTime().ToMicroseconds());
mStateObj->HandleAudioDecoded(aAudio);
},
[this, self](const MediaResult& aError) {
LOGV("OnAudioNotDecoded aError=%s", aError.ErrorName().get());
mAudioDataRequest.Complete();
switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
mStateObj->HandleWaitingForAudio();
break;
case NS_ERROR_DOM_MEDIA_CANCELED:
mStateObj->HandleAudioCanceled();
break;
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
mStateObj->HandleEndOfAudio();
break;
default:
DecodeError(aError);
}
})
->Track(mAudioDataRequest);
}
@ -3112,35 +3118,36 @@ void MediaDecoderStateMachine::RequestVideoData(
TimeStamp videoDecodeStartTime = TimeStamp::Now();
RefPtr<MediaDecoderStateMachine> self = this;
mReader->RequestVideoData(aCurrentTime)
->Then(OwnerThread(), __func__,
[this, self, videoDecodeStartTime](RefPtr<VideoData> aVideo) {
MOZ_ASSERT(aVideo);
mVideoDataRequest.Complete();
// Handle abnormal or negative timestamps.
mDecodedVideoEndTime =
std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
LOGV("OnVideoDecoded [%" PRId64 ",%" PRId64 "]",
aVideo->mTime.ToMicroseconds(),
aVideo->GetEndTime().ToMicroseconds());
mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime);
},
[this, self](const MediaResult& aError) {
LOGV("OnVideoNotDecoded aError=%s", aError.ErrorName().get());
mVideoDataRequest.Complete();
switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
mStateObj->HandleWaitingForVideo();
break;
case NS_ERROR_DOM_MEDIA_CANCELED:
mStateObj->HandleVideoCanceled();
break;
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
mStateObj->HandleEndOfVideo();
break;
default:
DecodeError(aError);
}
})
->Then(
OwnerThread(), __func__,
[this, self, videoDecodeStartTime](RefPtr<VideoData> aVideo) {
MOZ_ASSERT(aVideo);
mVideoDataRequest.Complete();
// Handle abnormal or negative timestamps.
mDecodedVideoEndTime =
std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
LOGV("OnVideoDecoded [%" PRId64 ",%" PRId64 "]",
aVideo->mTime.ToMicroseconds(),
aVideo->GetEndTime().ToMicroseconds());
mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime);
},
[this, self](const MediaResult& aError) {
LOGV("OnVideoNotDecoded aError=%s", aError.ErrorName().get());
mVideoDataRequest.Complete();
switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
mStateObj->HandleWaitingForVideo();
break;
case NS_ERROR_DOM_MEDIA_CANCELED:
mStateObj->HandleVideoCanceled();
break;
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
mStateObj->HandleEndOfVideo();
break;
default:
DecodeError(aError);
}
})
->Track(mVideoDataRequest);
}
@ -3151,29 +3158,31 @@ void MediaDecoderStateMachine::WaitForData(MediaData::Type aType) {
RefPtr<MediaDecoderStateMachine> self = this;
if (aType == MediaData::Type::AUDIO_DATA) {
mReader->WaitForData(MediaData::Type::AUDIO_DATA)
->Then(OwnerThread(), __func__,
[self](MediaData::Type aType) {
self->mAudioWaitRequest.Complete();
MOZ_ASSERT(aType == MediaData::Type::AUDIO_DATA);
self->mStateObj->HandleAudioWaited(aType);
},
[self](const WaitForDataRejectValue& aRejection) {
self->mAudioWaitRequest.Complete();
self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
})
->Then(
OwnerThread(), __func__,
[self](MediaData::Type aType) {
self->mAudioWaitRequest.Complete();
MOZ_ASSERT(aType == MediaData::Type::AUDIO_DATA);
self->mStateObj->HandleAudioWaited(aType);
},
[self](const WaitForDataRejectValue& aRejection) {
self->mAudioWaitRequest.Complete();
self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
})
->Track(mAudioWaitRequest);
} else {
mReader->WaitForData(MediaData::Type::VIDEO_DATA)
->Then(OwnerThread(), __func__,
[self](MediaData::Type aType) {
self->mVideoWaitRequest.Complete();
MOZ_ASSERT(aType == MediaData::Type::VIDEO_DATA);
self->mStateObj->HandleVideoWaited(aType);
},
[self](const WaitForDataRejectValue& aRejection) {
self->mVideoWaitRequest.Complete();
self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
})
->Then(
OwnerThread(), __func__,
[self](MediaData::Type aType) {
self->mVideoWaitRequest.Complete();
MOZ_ASSERT(aType == MediaData::Type::VIDEO_DATA);
self->mStateObj->HandleVideoWaited(aType);
},
[self](const WaitForDataRejectValue& aRejection) {
self->mVideoWaitRequest.Complete();
self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
})
->Track(mVideoWaitRequest);
}
}
@ -3464,12 +3473,13 @@ void MediaDecoderStateMachine::ScheduleStateMachineIn(const TimeUnit& aTime) {
// It is OK to capture 'this' without causing UAF because the callback
// always happens before shutdown.
RefPtr<MediaDecoderStateMachine> self = this;
mDelayedScheduler.Ensure(target,
[self]() {
self->mDelayedScheduler.CompleteRequest();
self->RunStateMachine();
},
[]() { MOZ_DIAGNOSTIC_ASSERT(false); });
mDelayedScheduler.Ensure(
target,
[self]() {
self->mDelayedScheduler.CompleteRequest();
self->RunStateMachine();
},
[]() { MOZ_DIAGNOSTIC_ASSERT(false); });
}
bool MediaDecoderStateMachine::OnTaskQueue() const {

View File

@ -65,20 +65,21 @@ already_AddRefed<Promise> MediaDevices::GetUserMedia(
RefPtr<MediaDevices> self(this);
MediaManager::Get()
->GetUserMedia(GetOwner(), aConstraints, aCallerType)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
if (!GetWindowIfCurrent()) {
return; // Leave Promise pending after navigation by design.
}
p->MaybeResolve(std::move(aStream));
},
[this, self, p](const RefPtr<MediaMgrError>& error) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
if (!window) {
return; // Leave Promise pending after navigation by design.
}
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
});
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
if (!GetWindowIfCurrent()) {
return; // Leave Promise pending after navigation by design.
}
p->MaybeResolve(std::move(aStream));
},
[this, self, p](const RefPtr<MediaMgrError>& error) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
if (!window) {
return; // Leave Promise pending after navigation by design.
}
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
});
return p.forget();
}
@ -92,40 +93,41 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
RefPtr<MediaDevices> self(this);
MediaManager::Get()
->EnumerateDevices(GetOwner(), aCallerType)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[this, self,
p](RefPtr<MediaManager::MediaDeviceSetRefCnt>&& aDevices) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
if (!window) {
return; // Leave Promise pending after navigation by design.
}
auto windowId = window->WindowID();
nsTArray<RefPtr<MediaDeviceInfo>> infos;
for (auto& device : *aDevices) {
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
device->mKind == dom::MediaDeviceKind::Videoinput ||
device->mKind == dom::MediaDeviceKind::Audiooutput);
// Include name only if page currently has a gUM stream active
// or persistent permissions (audio or video) have been granted
nsString label;
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
windowId) ||
Preferences::GetBool("media.navigator.permission.disabled",
false)) {
label = device->mName;
}
infos.AppendElement(MakeRefPtr<MediaDeviceInfo>(
device->mID, device->mKind, label, device->mGroupID));
}
p->MaybeResolve(std::move(infos));
},
[this, self, p](const RefPtr<MediaMgrError>& error) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
if (!window) {
return; // Leave Promise pending after navigation by design.
}
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
});
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[this, self,
p](RefPtr<MediaManager::MediaDeviceSetRefCnt>&& aDevices) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
if (!window) {
return; // Leave Promise pending after navigation by design.
}
auto windowId = window->WindowID();
nsTArray<RefPtr<MediaDeviceInfo>> infos;
for (auto& device : *aDevices) {
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
device->mKind == dom::MediaDeviceKind::Videoinput ||
device->mKind == dom::MediaDeviceKind::Audiooutput);
// Include name only if page currently has a gUM stream active
// or persistent permissions (audio or video) have been granted
nsString label;
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
windowId) ||
Preferences::GetBool("media.navigator.permission.disabled",
false)) {
label = device->mName;
}
infos.AppendElement(MakeRefPtr<MediaDeviceInfo>(
device->mID, device->mKind, label, device->mGroupID));
}
p->MaybeResolve(std::move(infos));
},
[this, self, p](const RefPtr<MediaMgrError>& error) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
if (!window) {
return; // Leave Promise pending after navigation by design.
}
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
});
return p.forget();
}
@ -139,20 +141,21 @@ already_AddRefed<Promise> MediaDevices::GetDisplayMedia(
RefPtr<MediaDevices> self(this);
MediaManager::Get()
->GetDisplayMedia(GetOwner(), aConstraints, aCallerType)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
if (!GetWindowIfCurrent()) {
return; // leave promise pending after navigation.
}
p->MaybeResolve(std::move(aStream));
},
[this, self, p](RefPtr<MediaMgrError>&& error) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
if (!window) {
return; // leave promise pending after navigation.
}
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
});
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
if (!GetWindowIfCurrent()) {
return; // leave promise pending after navigation.
}
p->MaybeResolve(std::move(aStream));
},
[this, self, p](RefPtr<MediaMgrError>&& error) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
if (!window) {
return; // leave promise pending after navigation.
}
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
});
return p.forget();
}

View File

@ -336,17 +336,18 @@ void MediaFormatReader::DecoderFactory::RunStage(Data& aData) {
case Stage::None: {
MOZ_ASSERT(!aData.mToken);
aData.mPolicy->Alloc()
->Then(mOwner->OwnerThread(), __func__,
[this, &aData](RefPtr<Token> aToken) {
aData.mTokenRequest.Complete();
aData.mToken = aToken.forget();
aData.mStage = Stage::CreateDecoder;
RunStage(aData);
},
[&aData]() {
aData.mTokenRequest.Complete();
aData.mStage = Stage::None;
})
->Then(
mOwner->OwnerThread(), __func__,
[this, &aData](RefPtr<Token> aToken) {
aData.mTokenRequest.Complete();
aData.mToken = aToken.forget();
aData.mStage = Stage::CreateDecoder;
RunStage(aData);
},
[&aData]() {
aData.mTokenRequest.Complete();
aData.mStage = Stage::None;
})
->Track(aData.mTokenRequest);
aData.mStage = Stage::WaitForToken;
break;
@ -475,33 +476,33 @@ void MediaFormatReader::DecoderFactory::DoInitDecoder(Data& aData) {
DDLOGEX2("MediaFormatReader::DecoderFactory", this, DDLogCategory::Log,
"initialize_decoder", DDNoValue{});
aData.mDecoder->Init()
->Then(mOwner->OwnerThread(), __func__,
[this, &aData, &ownerData](TrackType aTrack) {
aData.mInitRequest.Complete();
aData.mStage = Stage::None;
MutexAutoLock lock(ownerData.mMutex);
ownerData.mDecoder = aData.mDecoder.forget();
ownerData.mDescription =
ownerData.mDecoder->GetDescriptionName();
DDLOGEX2("MediaFormatReader::DecoderFactory", this,
DDLogCategory::Log, "decoder_initialized", DDNoValue{});
DecoderDoctorLogger::LinkParentAndChild(
"MediaFormatReader::DecoderData", &ownerData, "decoder",
ownerData.mDecoder.get());
mOwner->SetVideoDecodeThreshold();
mOwner->ScheduleUpdate(aTrack);
},
[this, &aData, &ownerData](const MediaResult& aError) {
aData.mInitRequest.Complete();
MOZ_RELEASE_ASSERT(!ownerData.mDecoder,
"Can't have a decoder already set");
aData.mStage = Stage::None;
mOwner->mShutdownPromisePool->ShutdownDecoder(
aData.mDecoder.forget());
DDLOGEX2("MediaFormatReader::DecoderFactory", this,
DDLogCategory::Log, "initialize_decoder_error", aError);
mOwner->NotifyError(aData.mTrack, aError);
})
->Then(
mOwner->OwnerThread(), __func__,
[this, &aData, &ownerData](TrackType aTrack) {
aData.mInitRequest.Complete();
aData.mStage = Stage::None;
MutexAutoLock lock(ownerData.mMutex);
ownerData.mDecoder = aData.mDecoder.forget();
ownerData.mDescription = ownerData.mDecoder->GetDescriptionName();
DDLOGEX2("MediaFormatReader::DecoderFactory", this,
DDLogCategory::Log, "decoder_initialized", DDNoValue{});
DecoderDoctorLogger::LinkParentAndChild(
"MediaFormatReader::DecoderData", &ownerData, "decoder",
ownerData.mDecoder.get());
mOwner->SetVideoDecodeThreshold();
mOwner->ScheduleUpdate(aTrack);
},
[this, &aData, &ownerData](const MediaResult& aError) {
aData.mInitRequest.Complete();
MOZ_RELEASE_ASSERT(!ownerData.mDecoder,
"Can't have a decoder already set");
aData.mStage = Stage::None;
mOwner->mShutdownPromisePool->ShutdownDecoder(
aData.mDecoder.forget());
DDLOGEX2("MediaFormatReader::DecoderFactory", this,
DDLogCategory::Log, "initialize_decoder_error", aError);
mOwner->NotifyError(aData.mTrack, aError);
})
->Track(aData.mInitRequest);
}
@ -653,15 +654,16 @@ class MediaFormatReader::DemuxerProxy::Wrapper : public MediaTrackDemuxer {
return InvokeAsync(
mTaskQueue, __func__,
[self, aTime]() { return self->mTrackDemuxer->Seek(aTime); })
->Then(mTaskQueue, __func__,
[self](const TimeUnit& aTime) {
self->UpdateRandomAccessPoint();
return SeekPromise::CreateAndResolve(aTime, __func__);
},
[self](const MediaResult& aError) {
self->UpdateRandomAccessPoint();
return SeekPromise::CreateAndReject(aError, __func__);
});
->Then(
mTaskQueue, __func__,
[self](const TimeUnit& aTime) {
self->UpdateRandomAccessPoint();
return SeekPromise::CreateAndResolve(aTime, __func__);
},
[self](const MediaResult& aError) {
self->UpdateRandomAccessPoint();
return SeekPromise::CreateAndReject(aError, __func__);
});
}
RefPtr<SamplesPromise> GetSamples(int32_t aNumSamples) override {
@ -670,16 +672,17 @@ class MediaFormatReader::DemuxerProxy::Wrapper : public MediaTrackDemuxer {
[self, aNumSamples]() {
return self->mTrackDemuxer->GetSamples(aNumSamples);
})
->Then(mTaskQueue, __func__,
[self](RefPtr<SamplesHolder> aSamples) {
self->UpdateRandomAccessPoint();
return SamplesPromise::CreateAndResolve(aSamples.forget(),
__func__);
},
[self](const MediaResult& aError) {
self->UpdateRandomAccessPoint();
return SamplesPromise::CreateAndReject(aError, __func__);
});
->Then(
mTaskQueue, __func__,
[self](RefPtr<SamplesHolder> aSamples) {
self->UpdateRandomAccessPoint();
return SamplesPromise::CreateAndResolve(aSamples.forget(),
__func__);
},
[self](const MediaResult& aError) {
self->UpdateRandomAccessPoint();
return SamplesPromise::CreateAndReject(aError, __func__);
});
}
bool GetSamplesMayBlock() const override { return mGetSamplesMayBlock; }
@ -788,56 +791,57 @@ RefPtr<MediaDataDemuxer::InitPromise> MediaFormatReader::DemuxerProxy::Init() {
}
return data->mDemuxer->Init();
})
->Then(taskQueue, __func__,
[data, taskQueue]() {
if (!data->mDemuxer) { // Was shutdown.
return InitPromise::CreateAndReject(
NS_ERROR_DOM_MEDIA_CANCELED, __func__);
}
data->mNumAudioTrack =
data->mDemuxer->GetNumberTracks(TrackInfo::kAudioTrack);
if (data->mNumAudioTrack) {
RefPtr<MediaTrackDemuxer> d =
data->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0);
if (d) {
RefPtr<Wrapper> wrapper =
new DemuxerProxy::Wrapper(d, taskQueue);
wrapper->UpdateBuffered();
data->mAudioDemuxer = wrapper;
DecoderDoctorLogger::LinkParentAndChild(
data->mDemuxer.get(), "decoder factory wrapper",
"MediaFormatReader::DecoderFactory::Wrapper",
wrapper.get());
}
}
data->mNumVideoTrack =
data->mDemuxer->GetNumberTracks(TrackInfo::kVideoTrack);
if (data->mNumVideoTrack) {
RefPtr<MediaTrackDemuxer> d =
data->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
if (d) {
RefPtr<Wrapper> wrapper =
new DemuxerProxy::Wrapper(d, taskQueue);
wrapper->UpdateBuffered();
data->mVideoDemuxer = wrapper;
DecoderDoctorLogger::LinkParentAndChild(
data->mDemuxer.get(), "decoder factory wrapper",
"MediaFormatReader::DecoderFactory::Wrapper",
wrapper.get());
}
}
data->mCrypto = data->mDemuxer->GetCrypto();
data->mSeekable = data->mDemuxer->IsSeekable();
data->mSeekableOnlyInBufferedRange =
data->mDemuxer->IsSeekableOnlyInBufferedRanges();
data->mShouldComputeStartTime =
data->mDemuxer->ShouldComputeStartTime();
data->mInitDone = true;
return InitPromise::CreateAndResolve(NS_OK, __func__);
},
[](const MediaResult& aError) {
return InitPromise::CreateAndReject(aError, __func__);
});
->Then(
taskQueue, __func__,
[data, taskQueue]() {
if (!data->mDemuxer) { // Was shutdown.
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
__func__);
}
data->mNumAudioTrack =
data->mDemuxer->GetNumberTracks(TrackInfo::kAudioTrack);
if (data->mNumAudioTrack) {
RefPtr<MediaTrackDemuxer> d =
data->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0);
if (d) {
RefPtr<Wrapper> wrapper =
new DemuxerProxy::Wrapper(d, taskQueue);
wrapper->UpdateBuffered();
data->mAudioDemuxer = wrapper;
DecoderDoctorLogger::LinkParentAndChild(
data->mDemuxer.get(), "decoder factory wrapper",
"MediaFormatReader::DecoderFactory::Wrapper",
wrapper.get());
}
}
data->mNumVideoTrack =
data->mDemuxer->GetNumberTracks(TrackInfo::kVideoTrack);
if (data->mNumVideoTrack) {
RefPtr<MediaTrackDemuxer> d =
data->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
if (d) {
RefPtr<Wrapper> wrapper =
new DemuxerProxy::Wrapper(d, taskQueue);
wrapper->UpdateBuffered();
data->mVideoDemuxer = wrapper;
DecoderDoctorLogger::LinkParentAndChild(
data->mDemuxer.get(), "decoder factory wrapper",
"MediaFormatReader::DecoderFactory::Wrapper",
wrapper.get());
}
}
data->mCrypto = data->mDemuxer->GetCrypto();
data->mSeekable = data->mDemuxer->IsSeekable();
data->mSeekableOnlyInBufferedRange =
data->mDemuxer->IsSeekableOnlyInBufferedRanges();
data->mShouldComputeStartTime =
data->mDemuxer->ShouldComputeStartTime();
data->mInitDone = true;
return InitPromise::CreateAndResolve(NS_OK, __func__);
},
[](const MediaResult& aError) {
return InitPromise::CreateAndReject(aError, __func__);
});
}
RefPtr<MediaFormatReader::NotifyDataArrivedPromise>
@ -1444,20 +1448,20 @@ void MediaFormatReader::DoDemuxVideo() {
if (mVideo.mFirstDemuxedSampleTime.isNothing()) {
RefPtr<MediaFormatReader> self = this;
p = p->Then(OwnerThread(), __func__,
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxed",
DDNoValue{});
self->OnFirstDemuxCompleted(TrackInfo::kVideoTrack, aSamples);
return SamplesPromise::CreateAndResolve(aSamples.forget(),
__func__);
},
[self](const MediaResult& aError) {
DDLOGEX(self.get(), DDLogCategory::Log,
"video_first_demuxing_error", aError);
self->OnFirstDemuxFailed(TrackInfo::kVideoTrack, aError);
return SamplesPromise::CreateAndReject(aError, __func__);
});
p = p->Then(
OwnerThread(), __func__,
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxed",
DDNoValue{});
self->OnFirstDemuxCompleted(TrackInfo::kVideoTrack, aSamples);
return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__);
},
[self](const MediaResult& aError) {
DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxing_error",
aError);
self->OnFirstDemuxFailed(TrackInfo::kVideoTrack, aError);
return SamplesPromise::CreateAndReject(aError, __func__);
});
}
p->Then(OwnerThread(), __func__, this,
@ -1522,20 +1526,20 @@ void MediaFormatReader::DoDemuxAudio() {
if (mAudio.mFirstDemuxedSampleTime.isNothing()) {
RefPtr<MediaFormatReader> self = this;
p = p->Then(OwnerThread(), __func__,
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxed",
DDNoValue{});
self->OnFirstDemuxCompleted(TrackInfo::kAudioTrack, aSamples);
return SamplesPromise::CreateAndResolve(aSamples.forget(),
__func__);
},
[self](const MediaResult& aError) {
DDLOGEX(self.get(), DDLogCategory::Log,
"audio_first_demuxing_error", aError);
self->OnFirstDemuxFailed(TrackInfo::kAudioTrack, aError);
return SamplesPromise::CreateAndReject(aError, __func__);
});
p = p->Then(
OwnerThread(), __func__,
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxed",
DDNoValue{});
self->OnFirstDemuxCompleted(TrackInfo::kAudioTrack, aSamples);
return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__);
},
[self](const MediaResult& aError) {
DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxing_error",
aError);
self->OnFirstDemuxFailed(TrackInfo::kAudioTrack, aError);
return SamplesPromise::CreateAndReject(aError, __func__);
});
}
p->Then(OwnerThread(), __func__, this,
@ -1993,46 +1997,47 @@ void MediaFormatReader::InternalSeek(TrackType aTrack,
DDLOG(DDLogCategory::Log, "seeking", DDNoValue{});
RefPtr<MediaFormatReader> self = this;
decoder.mTrackDemuxer->Seek(decoder.mTimeThreshold.ref().Time())
->Then(OwnerThread(), __func__,
[self, aTrack](TimeUnit aTime) {
DDLOGEX(self.get(), DDLogCategory::Log, "seeked", DDNoValue{});
auto& decoder = self->GetDecoderData(aTrack);
decoder.mSeekRequest.Complete();
MOZ_ASSERT(decoder.mTimeThreshold,
"Seek promise must be disconnected when "
"timethreshold is reset");
decoder.mTimeThreshold.ref().mHasSeeked = true;
self->SetVideoDecodeThreshold();
self->ScheduleUpdate(aTrack);
},
[self, aTrack](const MediaResult& aError) {
auto& decoder = self->GetDecoderData(aTrack);
decoder.mSeekRequest.Complete();
switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
DDLOGEX(self.get(), DDLogCategory::Log,
"seeking_interrupted", aError);
self->NotifyWaitingForData(aTrack);
break;
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
DDLOGEX(self.get(), DDLogCategory::Log,
"seeking_interrupted", aError);
decoder.mTimeThreshold.reset();
self->NotifyEndOfStream(aTrack);
break;
case NS_ERROR_DOM_MEDIA_CANCELED:
DDLOGEX(self.get(), DDLogCategory::Log,
"seeking_interrupted", aError);
decoder.mTimeThreshold.reset();
break;
default:
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_error",
aError);
decoder.mTimeThreshold.reset();
self->NotifyError(aTrack, aError);
break;
}
})
->Then(
OwnerThread(), __func__,
[self, aTrack](TimeUnit aTime) {
DDLOGEX(self.get(), DDLogCategory::Log, "seeked", DDNoValue{});
auto& decoder = self->GetDecoderData(aTrack);
decoder.mSeekRequest.Complete();
MOZ_ASSERT(decoder.mTimeThreshold,
"Seek promise must be disconnected when "
"timethreshold is reset");
decoder.mTimeThreshold.ref().mHasSeeked = true;
self->SetVideoDecodeThreshold();
self->ScheduleUpdate(aTrack);
},
[self, aTrack](const MediaResult& aError) {
auto& decoder = self->GetDecoderData(aTrack);
decoder.mSeekRequest.Complete();
switch (aError.Code()) {
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted",
aError);
self->NotifyWaitingForData(aTrack);
break;
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted",
aError);
decoder.mTimeThreshold.reset();
self->NotifyEndOfStream(aTrack);
break;
case NS_ERROR_DOM_MEDIA_CANCELED:
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted",
aError);
decoder.mTimeThreshold.reset();
break;
default:
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_error",
aError);
decoder.mTimeThreshold.reset();
self->NotifyError(aTrack, aError);
break;
}
})
->Track(decoder.mSeekRequest);
}
@ -2869,17 +2874,18 @@ void MediaFormatReader::NotifyDataArrived() {
RefPtr<MediaFormatReader> self = this;
mDemuxer->NotifyDataArrived()
->Then(OwnerThread(), __func__,
[self]() {
self->mNotifyDataArrivedPromise.Complete();
self->UpdateBuffered();
self->NotifyTrackDemuxers();
if (self->mPendingNotifyDataArrived) {
self->mPendingNotifyDataArrived = false;
self->NotifyDataArrived();
}
},
[self]() { self->mNotifyDataArrivedPromise.Complete(); })
->Then(
OwnerThread(), __func__,
[self]() {
self->mNotifyDataArrivedPromise.Complete();
self->UpdateBuffered();
self->NotifyTrackDemuxers();
if (self->mPendingNotifyDataArrived) {
self->mPendingNotifyDataArrived = false;
self->NotifyDataArrived();
}
},
[self]() { self->mNotifyDataArrivedPromise.Complete(); })
->Track(mNotifyDataArrivedPromise);
}

View File

@ -3139,46 +3139,46 @@ RefPtr<MediaManager::MgrPromise> MediaManager::EnumerateDevicesImpl(
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
__func__);
})
->Then(GetMainThreadSerialEventTarget(), __func__,
[aWindowId, originKey, aVideoInputEnumType, aAudioInputEnumType,
aVideoInputType, aAudioInputType, aOutDevices](bool) {
// Only run if window is still on our active list.
MediaManager* mgr = MediaManager::GetIfExists();
if (!mgr || !mgr->IsWindowStillActive(aWindowId)) {
return MgrPromise::CreateAndReject(
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
__func__);
}
->Then(
GetMainThreadSerialEventTarget(), __func__,
[aWindowId, originKey, aVideoInputEnumType, aAudioInputEnumType,
aVideoInputType, aAudioInputType, aOutDevices](bool) {
// Only run if window is still on our active list.
MediaManager* mgr = MediaManager::GetIfExists();
if (!mgr || !mgr->IsWindowStillActive(aWindowId)) {
return MgrPromise::CreateAndReject(
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
__func__);
}
// If we fetched any real cameras or mics, remove the
// "default" part of their IDs.
if (aVideoInputType == MediaSourceEnum::Camera &&
aAudioInputType == MediaSourceEnum::Microphone &&
(aVideoInputEnumType != DeviceEnumerationType::Fake ||
aAudioInputEnumType != DeviceEnumerationType::Fake)) {
mgr->mDeviceIDs.Clear();
for (auto& device : *aOutDevices) {
nsString id;
device->GetId(id);
id.ReplaceSubstring(NS_LITERAL_STRING("default: "),
NS_LITERAL_STRING(""));
if (!mgr->mDeviceIDs.Contains(id)) {
mgr->mDeviceIDs.AppendElement(id);
}
}
}
if (!mgr->IsWindowStillActive(aWindowId)) {
return MgrPromise::CreateAndReject(
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
__func__);
}
MediaManager::AnonymizeDevices(*aOutDevices, *originKey,
aWindowId);
return MgrPromise::CreateAndResolve(false, __func__);
},
[](RefPtr<MediaMgrError>&& aError) {
return MgrPromise::CreateAndReject(std::move(aError), __func__);
});
// If we fetched any real cameras or mics, remove the
// "default" part of their IDs.
if (aVideoInputType == MediaSourceEnum::Camera &&
aAudioInputType == MediaSourceEnum::Microphone &&
(aVideoInputEnumType != DeviceEnumerationType::Fake ||
aAudioInputEnumType != DeviceEnumerationType::Fake)) {
mgr->mDeviceIDs.Clear();
for (auto& device : *aOutDevices) {
nsString id;
device->GetId(id);
id.ReplaceSubstring(NS_LITERAL_STRING("default: "),
NS_LITERAL_STRING(""));
if (!mgr->mDeviceIDs.Contains(id)) {
mgr->mDeviceIDs.AppendElement(id);
}
}
}
if (!mgr->IsWindowStillActive(aWindowId)) {
return MgrPromise::CreateAndReject(
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
__func__);
}
MediaManager::AnonymizeDevices(*aOutDevices, *originKey, aWindowId);
return MgrPromise::CreateAndResolve(false, __func__);
},
[](RefPtr<MediaMgrError>&& aError) {
return MgrPromise::CreateAndReject(std::move(aError), __func__);
});
}
RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
@ -3250,21 +3250,21 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
MediaSourceEnum::Microphone, audioOutputType,
videoEnumerationType, audioEnumerationType, false,
devices)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[windowListener, sourceListener, devices](bool) {
DebugOnly<bool> rv = windowListener->Remove(sourceListener);
MOZ_ASSERT(rv);
return DevicesPromise::CreateAndResolve(devices, __func__);
},
[windowListener, sourceListener](RefPtr<MediaMgrError>&& aError) {
// This may fail, if a new doc has been set the OnNavigation
// method should have removed all previous active listeners.
// Attempt to clean it here, just in case, but ignore the return
// value.
Unused << windowListener->Remove(sourceListener);
return DevicesPromise::CreateAndReject(std::move(aError),
__func__);
});
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[windowListener, sourceListener, devices](bool) {
DebugOnly<bool> rv = windowListener->Remove(sourceListener);
MOZ_ASSERT(rv);
return DevicesPromise::CreateAndResolve(devices, __func__);
},
[windowListener, sourceListener](RefPtr<MediaMgrError>&& aError) {
// This may fail, if a new doc has been set the OnNavigation
// method should have removed all previous active listeners.
// Attempt to clean it here, just in case, but ignore the return
// value.
Unused << windowListener->Remove(sourceListener);
return DevicesPromise::CreateAndReject(std::move(aError), __func__);
});
}
RefPtr<SinkInfoPromise> MediaManager::GetSinkDevice(nsPIDOMWindowInner* aWindow,
@ -3298,31 +3298,32 @@ RefPtr<SinkInfoPromise> MediaManager::GetSinkDevice(nsPIDOMWindowInner* aWindow,
MediaSourceEnum::Other, MediaSinkEnum::Speaker,
DeviceEnumerationType::Normal,
DeviceEnumerationType::Normal, true, devices)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[aDeviceId, isSecure, devices](bool) {
for (RefPtr<MediaDevice>& device : *devices) {
if (aDeviceId.IsEmpty() && device->mSinkInfo->Preferred()) {
return SinkInfoPromise::CreateAndResolve(device->mSinkInfo,
__func__);
}
if (device->mID.Equals(aDeviceId)) {
// TODO: Check if the application is authorized to play audio
// through this device (Bug 1493982).
if (isSecure || device->mSinkInfo->Preferred()) {
return SinkInfoPromise::CreateAndResolve(device->mSinkInfo,
__func__);
}
return SinkInfoPromise::CreateAndReject(
NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR, __func__);
}
}
return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__);
},
[](RefPtr<MediaMgrError>&& aError) {
return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__);
});
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[aDeviceId, isSecure, devices](bool) {
for (RefPtr<MediaDevice>& device : *devices) {
if (aDeviceId.IsEmpty() && device->mSinkInfo->Preferred()) {
return SinkInfoPromise::CreateAndResolve(device->mSinkInfo,
__func__);
}
if (device->mID.Equals(aDeviceId)) {
// TODO: Check if the application is authorized to play audio
// through this device (Bug 1493982).
if (isSecure || device->mSinkInfo->Preferred()) {
return SinkInfoPromise::CreateAndResolve(device->mSinkInfo,
__func__);
}
return SinkInfoPromise::CreateAndReject(
NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR, __func__);
}
}
return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__);
},
[](RefPtr<MediaMgrError>&& aError) {
return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__);
});
}
/*
@ -4174,49 +4175,50 @@ SourceListener::InitializeAsync() {
LOG("started all sources");
aHolder.Resolve(true, __func__);
})
->Then(GetMainThreadSerialEventTarget(), __func__,
[self = RefPtr<SourceListener>(this), this]() {
if (mStopped) {
// We were shut down during the async init
return SourceListenerPromise::CreateAndResolve(true, __func__);
}
->Then(
GetMainThreadSerialEventTarget(), __func__,
[self = RefPtr<SourceListener>(this), this]() {
if (mStopped) {
// We were shut down during the async init
return SourceListenerPromise::CreateAndResolve(true, __func__);
}
for (DeviceState* state :
{mAudioDeviceState.get(), mVideoDeviceState.get()}) {
if (!state) {
continue;
}
MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
for (DeviceState* state :
{mAudioDeviceState.get(), mVideoDeviceState.get()}) {
if (!state) {
continue;
}
MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
state->mDeviceEnabled = true;
state->mTrackEnabled = true;
state->mTrackEnabledTime = TimeStamp::Now();
}
return SourceListenerPromise::CreateAndResolve(true, __func__);
},
[self = RefPtr<SourceListener>(this),
this](RefPtr<MediaMgrError>&& aResult) {
if (mStopped) {
return SourceListenerPromise::CreateAndReject(
std::move(aResult), __func__);
}
state->mDeviceEnabled = true;
state->mTrackEnabled = true;
state->mTrackEnabledTime = TimeStamp::Now();
}
return SourceListenerPromise::CreateAndResolve(true, __func__);
},
[self = RefPtr<SourceListener>(this),
this](RefPtr<MediaMgrError>&& aResult) {
if (mStopped) {
return SourceListenerPromise::CreateAndReject(std::move(aResult),
__func__);
}
for (DeviceState* state :
{mAudioDeviceState.get(), mVideoDeviceState.get()}) {
if (!state) {
continue;
}
MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
for (DeviceState* state :
{mAudioDeviceState.get(), mVideoDeviceState.get()}) {
if (!state) {
continue;
}
MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
state->mStopped = true;
}
return SourceListenerPromise::CreateAndReject(std::move(aResult),
__func__);
});
state->mStopped = true;
}
return SourceListenerPromise::CreateAndReject(std::move(aResult),
__func__);
});
}
void SourceListener::Stop() {

View File

@ -884,13 +884,14 @@ class MediaRecorder::Session : public PrincipalChangeObserver<MediaStreamTrack>,
}
gSessions.Clear();
ShutdownPromise::All(GetCurrentThreadSerialEventTarget(), promises)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[ticket]() mutable {
MOZ_ASSERT(gSessions.Count() == 0);
// Unblock shutdown
ticket = nullptr;
},
[]() { MOZ_CRASH("Not reached"); });
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[ticket]() mutable {
MOZ_ASSERT(gSessions.Count() == 0);
// Unblock shutdown
ticket = nullptr;
},
[]() { MOZ_CRASH("Not reached"); });
return NS_OK;
}
};
@ -1714,15 +1715,16 @@ RefPtr<MediaRecorder::SizeOfPromise> MediaRecorder::SizeOfExcludingThis(
}
SizeOfPromise::All(GetCurrentThreadSerialEventTarget(), promises)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[holder](const nsTArray<size_t>& sizes) {
size_t total = 0;
for (const size_t& size : sizes) {
total += size;
}
holder->Resolve(total, __func__);
},
[]() { MOZ_CRASH("Unexpected reject"); });
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[holder](const nsTArray<size_t>& sizes) {
size_t total = 0;
for (const size_t& size : sizes) {
total += size;
}
holder->Resolve(total, __func__);
},
[]() { MOZ_CRASH("Unexpected reject"); });
return promise;
}

View File

@ -80,18 +80,19 @@ RefPtr<ReaderProxy::VideoDataPromise> ReaderProxy::RequestVideoData(
int64_t startTime = StartTime().ToMicroseconds();
return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
&MediaFormatReader::RequestVideoData, threshold)
->Then(mOwnerThread, __func__,
[startTime](RefPtr<VideoData> aVideo) {
aVideo->AdjustForStartTime(startTime);
return aVideo->mTime.IsValid()
? VideoDataPromise::CreateAndResolve(aVideo.forget(),
__func__)
: VideoDataPromise::CreateAndReject(
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, __func__);
},
[](const MediaResult& aError) {
return VideoDataPromise::CreateAndReject(aError, __func__);
});
->Then(
mOwnerThread, __func__,
[startTime](RefPtr<VideoData> aVideo) {
aVideo->AdjustForStartTime(startTime);
return aVideo->mTime.IsValid()
? VideoDataPromise::CreateAndResolve(aVideo.forget(),
__func__)
: VideoDataPromise::CreateAndReject(
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, __func__);
},
[](const MediaResult& aError) {
return VideoDataPromise::CreateAndReject(aError, __func__);
});
}
RefPtr<ReaderProxy::SeekPromise> ReaderProxy::Seek(const SeekTarget& aTarget) {

View File

@ -93,13 +93,14 @@ class VideoFrameConverter {
mLastFrameQueuedForPacing = t;
mPacingTimer->WaitUntil(t, __func__)
->Then(mTaskQueue, __func__,
[self = RefPtr<VideoFrameConverter>(this), this,
image = RefPtr<layers::Image>(aChunk.mFrame.GetImage()), t,
size, aForceBlack]() mutable {
QueueForProcessing(std::move(image), t, size, aForceBlack);
},
[] {});
->Then(
mTaskQueue, __func__,
[self = RefPtr<VideoFrameConverter>(this), this,
image = RefPtr<layers::Image>(aChunk.mFrame.GetImage()), t, size,
aForceBlack]() mutable {
QueueForProcessing(std::move(image), t, size, aForceBlack);
},
[] {});
}
void SetTrackEnabled(bool aEnabled) {

View File

@ -793,7 +793,9 @@ static bool CheckRequirement(const MediaKeysRequirement aRequirement,
}
break;
}
default: { return false; }
default: {
return false;
}
}
// Set the requirement member of accumulated configuration to equal

View File

@ -233,7 +233,9 @@ nsresult VP8TrackEncoder::GetEncodedPartitions(EncodedFrameContainer& aData) {
pkt->data.frame.sz);
break;
}
default: { break; }
default: {
break;
}
}
// End of frame
if ((pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT) == 0) {

View File

@ -392,15 +392,16 @@ mozilla::ipc::IPCResult ChromiumCDMChild::RecvInit(
mPersistentStateAllowed = aAllowPersistentState;
RefPtr<ChromiumCDMChild::InitPromise> promise = mInitPromise.Ensure(__func__);
promise->Then(mPlugin->GMPMessageLoop()->SerialEventTarget(), __func__,
[aResolver](bool /* unused */) { aResolver(true); },
[aResolver](nsresult rv) {
GMP_LOG(
"ChromiumCDMChild::RecvInit() init promise rejected with "
"rv=%" PRIu32,
static_cast<uint32_t>(rv));
aResolver(false);
});
promise->Then(
mPlugin->GMPMessageLoop()->SerialEventTarget(), __func__,
[aResolver](bool /* unused */) { aResolver(true); },
[aResolver](nsresult rv) {
GMP_LOG(
"ChromiumCDMChild::RecvInit() init promise rejected with "
"rv=%" PRIu32,
static_cast<uint32_t>(rv));
aResolver(false);
});
if (mCDM) {
// Once the CDM is initialized we expect it to resolve mInitPromise via

View File

@ -93,20 +93,21 @@ void ChromiumCDMProxy::Init(PromiseId aPromiseId, const nsAString& aOrigin,
cdm->Init(self->mCallback.get(),
self->mDistinctiveIdentifierRequired,
self->mPersistentStateRequired, self->mMainThread)
->Then(thread, __func__,
[self, aPromiseId, cdm](bool /* unused */) {
// CDM init succeeded
{
MutexAutoLock lock(self->mCDMMutex);
self->mCDM = cdm;
}
self->OnCDMCreated(aPromiseId);
},
[self, aPromiseId](MediaResult aResult) {
// CDM init failed
self->RejectPromise(aPromiseId, aResult.Code(),
aResult.Message());
});
->Then(
thread, __func__,
[self, aPromiseId, cdm](bool /* unused */) {
// CDM init succeeded
{
MutexAutoLock lock(self->mCDMMutex);
self->mCDM = cdm;
}
self->OnCDMCreated(aPromiseId);
},
[self, aPromiseId](MediaResult aResult) {
// CDM init failed
self->RejectPromise(aPromiseId, aResult.Code(),
aResult.Message());
});
},
[self, aPromiseId](MediaResult rv) {
// service->GetCDM failed

View File

@ -355,24 +355,25 @@ GeckoMediaPluginService::GetDecryptingGMPVideoDecoder(
RefPtr<GMPCrashHelper> helper(aHelper);
GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
*aTags)
->Then(thread, __func__,
[rawCallback, helper,
aDecryptorId](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
RefPtr<GMPContentParent> parent = wrapper->mParent;
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
GMPVideoDecoderParent* actor = nullptr;
GMPVideoHostImpl* host = nullptr;
if (parent && NS_SUCCEEDED(parent->GetGMPVideoDecoder(
&actor, aDecryptorId))) {
host = &(actor->Host());
actor->SetCrashHelper(helper);
}
callback->Done(actor, host);
},
[rawCallback] {
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
callback->Done(nullptr, nullptr);
});
->Then(
thread, __func__,
[rawCallback, helper,
aDecryptorId](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
RefPtr<GMPContentParent> parent = wrapper->mParent;
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
GMPVideoDecoderParent* actor = nullptr;
GMPVideoHostImpl* host = nullptr;
if (parent && NS_SUCCEEDED(parent->GetGMPVideoDecoder(
&actor, aDecryptorId))) {
host = &(actor->Host());
actor->SetCrashHelper(helper);
}
callback->Done(actor, host);
},
[rawCallback] {
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
callback->Done(nullptr, nullptr);
});
return NS_OK;
}
@ -395,23 +396,24 @@ GeckoMediaPluginService::GetGMPVideoEncoder(
RefPtr<GMPCrashHelper> helper(aHelper);
GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_ENCODER),
*aTags)
->Then(thread, __func__,
[rawCallback,
helper](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
RefPtr<GMPContentParent> parent = wrapper->mParent;
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
GMPVideoEncoderParent* actor = nullptr;
GMPVideoHostImpl* host = nullptr;
if (parent && NS_SUCCEEDED(parent->GetGMPVideoEncoder(&actor))) {
host = &(actor->Host());
actor->SetCrashHelper(helper);
}
callback->Done(actor, host);
},
[rawCallback] {
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
callback->Done(nullptr, nullptr);
});
->Then(
thread, __func__,
[rawCallback,
helper](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
RefPtr<GMPContentParent> parent = wrapper->mParent;
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
GMPVideoEncoderParent* actor = nullptr;
GMPVideoHostImpl* host = nullptr;
if (parent && NS_SUCCEEDED(parent->GetGMPVideoEncoder(&actor))) {
host = &(actor->Host());
actor->SetCrashHelper(helper);
}
callback->Done(actor, host);
},
[rawCallback] {
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
callback->Done(nullptr, nullptr);
});
return NS_OK;
}

View File

@ -401,17 +401,18 @@ void GeckoMediaPluginServiceParent::InitializePlugins(
RefPtr<GenericPromise> p = mInitPromise.Ensure(__func__);
InvokeAsync(aAbstractGMPThread, this, __func__,
&GeckoMediaPluginServiceParent::LoadFromEnvironment)
->Then(aAbstractGMPThread, __func__,
[self]() -> void {
MonitorAutoLock lock(self->mInitPromiseMonitor);
self->mLoadPluginsFromDiskComplete = true;
self->mInitPromise.Resolve(true, __func__);
},
[self]() -> void {
MonitorAutoLock lock(self->mInitPromiseMonitor);
self->mLoadPluginsFromDiskComplete = true;
self->mInitPromise.Reject(NS_ERROR_FAILURE, __func__);
});
->Then(
aAbstractGMPThread, __func__,
[self]() -> void {
MonitorAutoLock lock(self->mInitPromiseMonitor);
self->mLoadPluginsFromDiskComplete = true;
self->mInitPromise.Resolve(true, __func__);
},
[self]() -> void {
MonitorAutoLock lock(self->mInitPromiseMonitor);
self->mLoadPluginsFromDiskComplete = true;
self->mInitPromise.Reject(NS_ERROR_FAILURE, __func__);
});
}
void GeckoMediaPluginServiceParent::NotifySyncShutdownComplete() {
@ -507,12 +508,12 @@ RefPtr<GenericPromise> GeckoMediaPluginServiceParent::LoadFromEnvironment() {
mScannedPluginOnDisk = true;
return GenericPromise::All(thread, promises)
->Then(thread, __func__,
[]() { return GenericPromise::CreateAndResolve(true, __func__); },
[]() {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE,
__func__);
});
->Then(
thread, __func__,
[]() { return GenericPromise::CreateAndResolve(true, __func__); },
[]() {
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
});
}
class NotifyObserversTask final : public mozilla::Runnable {
@ -612,23 +613,24 @@ RefPtr<GenericPromise> GeckoMediaPluginServiceParent::AsyncAddPluginDirectory(
RefPtr<GeckoMediaPluginServiceParent> self = this;
return InvokeAsync(thread, this, __func__,
&GeckoMediaPluginServiceParent::AddOnGMPThread, dir)
->Then(mMainThread, __func__,
[dir, self](bool aVal) {
LOGD(
("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s "
"succeeded",
NS_ConvertUTF16toUTF8(dir).get()));
MOZ_ASSERT(NS_IsMainThread());
self->UpdateContentProcessGMPCapabilities();
return GenericPromise::CreateAndResolve(aVal, __func__);
},
[dir](nsresult aResult) {
LOGD(
("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s "
"failed",
NS_ConvertUTF16toUTF8(dir).get()));
return GenericPromise::CreateAndReject(aResult, __func__);
});
->Then(
mMainThread, __func__,
[dir, self](bool aVal) {
LOGD(
("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s "
"succeeded",
NS_ConvertUTF16toUTF8(dir).get()));
MOZ_ASSERT(NS_IsMainThread());
self->UpdateContentProcessGMPCapabilities();
return GenericPromise::CreateAndResolve(aVal, __func__);
},
[dir](nsresult aResult) {
LOGD(
("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s "
"failed",
NS_ConvertUTF16toUTF8(dir).get()));
return GenericPromise::CreateAndReject(aResult, __func__);
});
}
NS_IMETHODIMP

View File

@ -399,24 +399,26 @@ class CDMStorageTest {
RefPtr<gmp::GetCDMParentPromise> promise =
service->GetCDM(aNodeId, std::move(tags), nullptr);
auto thread = GetAbstractGMPThread();
promise->Then(thread, __func__,
[self, aUpdates, thread](RefPtr<gmp::ChromiumCDMParent> cdm) {
self->mCDM = cdm;
EXPECT_TRUE(!!self->mCDM);
self->mCallback.reset(new CallbackProxy(self));
nsCString failureReason;
self->mCDM
->Init(self->mCallback.get(), false, true,
GetMainThreadEventTarget())
->Then(thread, __func__,
[self, aUpdates] {
for (auto& update : aUpdates) {
self->Update(update);
}
},
[](MediaResult rv) { EXPECT_TRUE(false); });
promise->Then(
thread, __func__,
[self, aUpdates, thread](RefPtr<gmp::ChromiumCDMParent> cdm) {
self->mCDM = cdm;
EXPECT_TRUE(!!self->mCDM);
self->mCallback.reset(new CallbackProxy(self));
nsCString failureReason;
self->mCDM
->Init(self->mCallback.get(), false, true,
GetMainThreadEventTarget())
->Then(
thread, __func__,
[self, aUpdates] {
for (auto& update : aUpdates) {
self->Update(update);
}
},
[](MediaResult rv) { EXPECT_TRUE(false); });
},
[](MediaResult rv) { EXPECT_TRUE(false); });
}
void TestBasicStorage() {

View File

@ -153,15 +153,16 @@ TEST(MP4Demuxer, Seek) {
binding->mVideoTrack =
binding->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
binding->CheckTrackSamples(binding->mVideoTrack)
->Then(binding->mTaskQueue, __func__,
[binding]() {
binding->CheckTrackKeyFrame(binding->mVideoTrack)
->Then(
binding->mTaskQueue, __func__,
[binding]() { binding->mTaskQueue->BeginShutdown(); },
DO_FAIL);
},
DO_FAIL);
->Then(
binding->mTaskQueue, __func__,
[binding]() {
binding->CheckTrackKeyFrame(binding->mVideoTrack)
->Then(
binding->mTaskQueue, __func__,
[binding]() { binding->mTaskQueue->BeginShutdown(); },
DO_FAIL);
},
DO_FAIL);
});
}
@ -318,17 +319,17 @@ TEST(MP4Demuxer, CENCFragVideo) {
binding->mVideoTrack =
binding->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
binding->CheckTrackSamples(binding->mVideoTrack)
->Then(binding->mTaskQueue, __func__,
[binding, video]() {
for (uint32_t i = 0; i < binding->mSamples.Length(); i++) {
nsCString text =
ToCryptoString(binding->mSamples[i]->mCrypto);
EXPECT_STREQ(video[i++], text.get());
}
EXPECT_EQ(ArrayLength(video), binding->mSamples.Length());
binding->mTaskQueue->BeginShutdown();
},
DO_FAIL);
->Then(
binding->mTaskQueue, __func__,
[binding, video]() {
for (uint32_t i = 0; i < binding->mSamples.Length(); i++) {
nsCString text = ToCryptoString(binding->mSamples[i]->mCrypto);
EXPECT_STREQ(video[i++], text.get());
}
EXPECT_EQ(ArrayLength(video), binding->mSamples.Length());
binding->mTaskQueue->BeginShutdown();
},
DO_FAIL);
});
}
@ -531,18 +532,18 @@ TEST(MP4Demuxer, CENCFragAudio) {
binding->mAudioTrack =
binding->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0);
binding->CheckTrackSamples(binding->mAudioTrack)
->Then(binding->mTaskQueue, __func__,
[binding, audio]() {
EXPECT_TRUE(binding->mSamples.Length() > 1);
for (uint32_t i = 0; i < binding->mSamples.Length(); i++) {
nsCString text =
ToCryptoString(binding->mSamples[i]->mCrypto);
EXPECT_STREQ(audio[i++], text.get());
}
EXPECT_EQ(ArrayLength(audio), binding->mSamples.Length());
binding->mTaskQueue->BeginShutdown();
},
DO_FAIL);
->Then(
binding->mTaskQueue, __func__,
[binding, audio]() {
EXPECT_TRUE(binding->mSamples.Length() > 1);
for (uint32_t i = 0; i < binding->mSamples.Length(); i++) {
nsCString text = ToCryptoString(binding->mSamples[i]->mCrypto);
EXPECT_STREQ(audio[i++], text.get());
}
EXPECT_EQ(ArrayLength(audio), binding->mSamples.Length());
binding->mTaskQueue->BeginShutdown();
},
DO_FAIL);
});
}

View File

@ -85,15 +85,16 @@ void WaitForShutdown(RefPtr<MediaDataEncoder> aEncoder) {
Maybe<bool> result;
// media::Await() supports exclusive promises only, but ShutdownPromise is
// not.
aEncoder->Shutdown()->Then(AbstractThread::MainThread(), __func__,
[&result](bool rv) {
EXPECT_TRUE(rv);
result = Some(true);
},
[&result]() {
FAIL() << "Shutdown should never be rejected";
result = Some(false);
});
aEncoder->Shutdown()->Then(
AbstractThread::MainThread(), __func__,
[&result](bool rv) {
EXPECT_TRUE(rv);
result = Some(true);
},
[&result]() {
FAIL() << "Shutdown should never be rejected";
result = Some(false);
});
SpinEventLoopUntil([&result]() { return result; });
}
@ -115,12 +116,13 @@ static bool EnsureInit(RefPtr<MediaDataEncoder> aEncoder) {
}
bool succeeded;
media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Init(),
[&succeeded](TrackInfo::TrackType t) {
EXPECT_EQ(TrackInfo::TrackType::kVideoTrack, t);
succeeded = true;
},
[&succeeded](MediaResult r) { succeeded = false; });
media::Await(
GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Init(),
[&succeeded](TrackInfo::TrackType t) {
EXPECT_EQ(TrackInfo::TrackType::kVideoTrack, t);
succeeded = true;
},
[&succeeded](MediaResult r) { succeeded = false; });
return succeeded;
}
@ -149,13 +151,13 @@ static MediaDataEncoder::EncodedData Encode(
kImageSize, 0, TimeUnit::FromMicroseconds(i * 30000),
TimeUnit::FromMicroseconds(30000), img, (i & 0xF) == 0,
TimeUnit::FromMicroseconds(i * 30000));
media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK),
aEncoder->Encode(frame),
[&output, &succeeded](MediaDataEncoder::EncodedData encoded) {
output.AppendElements(std::move(encoded));
succeeded = true;
},
[&succeeded](MediaResult r) { succeeded = false; });
media::Await(
GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Encode(frame),
[&output, &succeeded](MediaDataEncoder::EncodedData encoded) {
output.AppendElements(std::move(encoded));
succeeded = true;
},
[&succeeded](MediaResult r) { succeeded = false; });
EXPECT_TRUE(succeeded);
if (!succeeded) {
return output;
@ -177,13 +179,13 @@ static MediaDataEncoder::EncodedData Encode(
}
if (pending > 0) {
media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK),
aEncoder->Drain(),
[&succeeded](MediaDataEncoder::EncodedData encoded) {
EXPECT_EQ(encoded.Length(), 0UL);
succeeded = true;
},
[&succeeded](MediaResult r) { succeeded = false; });
media::Await(
GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Drain(),
[&succeeded](MediaDataEncoder::EncodedData encoded) {
EXPECT_EQ(encoded.Length(), 0UL);
succeeded = true;
},
[&succeeded](MediaResult r) { succeeded = false; });
EXPECT_TRUE(succeeded);
}

View File

@ -65,8 +65,7 @@ already_AddRefed<MediaDataDecoder> RemoteDecoderModule::CreateAudioDecoder(
MediaResult result(NS_OK);
RefPtr<Runnable> task = NS_NewRunnableFunction(
"RemoteDecoderModule::CreateAudioDecoder", [&, child]() {
result = child->InitIPDL(aParams.AudioConfig(),
aParams.mOptions);
result = child->InitIPDL(aParams.AudioConfig(), aParams.mOptions);
});
SyncRunnable::DispatchToThread(RemoteDecoderManagerChild::GetManagerThread(),
task);
@ -100,8 +99,7 @@ already_AddRefed<MediaDataDecoder> RemoteDecoderModule::CreateVideoDecoder(
MediaResult result(NS_OK);
RefPtr<Runnable> task = NS_NewRunnableFunction(
"RemoteDecoderModule::CreateVideoDecoder", [&, child]() {
result = child->InitIPDL(aParams.VideoConfig(),
aParams.mRate.mValue,
result = child->InitIPDL(aParams.VideoConfig(), aParams.mRate.mValue,
aParams.mOptions);
});
SyncRunnable::DispatchToThread(RemoteDecoderManagerChild::GetManagerThread(),

View File

@ -41,21 +41,22 @@ void RemoteDecoderParent::Destroy() {
mozilla::ipc::IPCResult RemoteDecoderParent::RecvInit() {
MOZ_ASSERT(OnManagerThread());
RefPtr<RemoteDecoderParent> self = this;
mDecoder->Init()->Then(mManagerTaskQueue, __func__,
[self](TrackInfo::TrackType aTrack) {
MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack ||
aTrack == TrackInfo::kVideoTrack);
if (self->mDecoder) {
Unused << self->SendInitComplete(
aTrack, self->mDecoder->GetDescriptionName(),
self->mDecoder->NeedsConversion());
}
},
[self](MediaResult aReason) {
if (!self->mDestroyed) {
Unused << self->SendInitFailed(aReason);
}
});
mDecoder->Init()->Then(
mManagerTaskQueue, __func__,
[self](TrackInfo::TrackType aTrack) {
MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack ||
aTrack == TrackInfo::kVideoTrack);
if (self->mDecoder) {
Unused << self->SendInitComplete(aTrack,
self->mDecoder->GetDescriptionName(),
self->mDecoder->NeedsConversion());
}
},
[self](MediaResult aReason) {
if (!self->mDestroyed) {
Unused << self->SendInitFailed(aReason);
}
});
return IPC_OK();
}

View File

@ -44,18 +44,19 @@ RefPtr<MediaDataDecoder::InitPromise> RemoteMediaDataDecoder::Init() {
RefPtr<RemoteMediaDataDecoder> self = this;
return InvokeAsync(mAbstractManagerThread, __func__,
[self]() { return self->mChild->Init(); })
->Then(mAbstractManagerThread, __func__,
[self, this](TrackType aTrack) {
mDescription = mChild->GetDescriptionName() +
NS_LITERAL_CSTRING(" (remote)");
mIsHardwareAccelerated =
mChild->IsHardwareAccelerated(mHardwareAcceleratedReason);
mConversion = mChild->NeedsConversion();
return InitPromise::CreateAndResolve(aTrack, __func__);
},
[self](const MediaResult& aError) {
return InitPromise::CreateAndReject(aError, __func__);
});
->Then(
mAbstractManagerThread, __func__,
[self, this](TrackType aTrack) {
mDescription =
mChild->GetDescriptionName() + NS_LITERAL_CSTRING(" (remote)");
mIsHardwareAccelerated =
mChild->IsHardwareAccelerated(mHardwareAcceleratedReason);
mConversion = mChild->NeedsConversion();
return InitPromise::CreateAndResolve(aTrack, __func__);
},
[self](const MediaResult& aError) {
return InitPromise::CreateAndReject(aError, __func__);
});
}
RefPtr<MediaDataDecoder::DecodePromise> RemoteMediaDataDecoder::Decode(

View File

@ -262,21 +262,22 @@ nsresult VideoSink::Start(const TimeUnit& aStartTime, const MediaInfo& aInfo) {
RefPtr<EndedPromise> p = mAudioSink->OnEnded(TrackInfo::kVideoTrack);
if (p) {
RefPtr<VideoSink> self = this;
p->Then(mOwnerThread, __func__,
[self]() {
self->mVideoSinkEndRequest.Complete();
self->TryUpdateRenderedVideoFrames();
// It is possible the video queue size is 0 and we have no
// frames to render. However, we need to call
// MaybeResolveEndPromise() to ensure mEndPromiseHolder is
// resolved.
self->MaybeResolveEndPromise();
},
[self]() {
self->mVideoSinkEndRequest.Complete();
self->TryUpdateRenderedVideoFrames();
self->MaybeResolveEndPromise();
})
p->Then(
mOwnerThread, __func__,
[self]() {
self->mVideoSinkEndRequest.Complete();
self->TryUpdateRenderedVideoFrames();
// It is possible the video queue size is 0 and we have no
// frames to render. However, we need to call
// MaybeResolveEndPromise() to ensure mEndPromiseHolder is
// resolved.
self->MaybeResolveEndPromise();
},
[self]() {
self->mVideoSinkEndRequest.Complete();
self->TryUpdateRenderedVideoFrames();
self->MaybeResolveEndPromise();
})
->Track(mVideoSinkEndRequest);
}

View File

@ -328,12 +328,13 @@ void SourceBuffer::RangeRemoval(double aStart, double aEnd) {
RefPtr<SourceBuffer> self = this;
mTrackBuffersManager
->RangeRemoval(TimeUnit::FromSeconds(aStart), TimeUnit::FromSeconds(aEnd))
->Then(mAbstractMainThread, __func__,
[self](bool) {
self->mPendingRemoval.Complete();
self->StopUpdating();
},
[]() { MOZ_ASSERT(false); })
->Then(
mAbstractMainThread, __func__,
[self](bool) {
self->mPendingRemoval.Complete();
self->StopUpdating();
},
[]() { MOZ_ASSERT(false); })
->Track(mPendingRemoval);
}

View File

@ -811,19 +811,20 @@ void TrackBuffersManager::SegmentParserLoop() {
// run the coded frame processing algorithm.
RefPtr<TrackBuffersManager> self = this;
CodedFrameProcessing()
->Then(TaskQueueFromTaskQueue(), __func__,
[self](bool aNeedMoreData) {
self->mProcessingRequest.Complete();
if (aNeedMoreData) {
self->NeedMoreData();
} else {
self->ScheduleSegmentParserLoop();
}
},
[self](const MediaResult& aRejectValue) {
self->mProcessingRequest.Complete();
self->RejectAppend(aRejectValue, __func__);
})
->Then(
TaskQueueFromTaskQueue(), __func__,
[self](bool aNeedMoreData) {
self->mProcessingRequest.Complete();
if (aNeedMoreData) {
self->NeedMoreData();
} else {
self->ScheduleSegmentParserLoop();
}
},
[self](const MediaResult& aRejectValue) {
self->mProcessingRequest.Complete();
self->RejectAppend(aRejectValue, __func__);
})
->Track(mProcessingRequest);
return;
}

View File

@ -140,18 +140,19 @@ auto SingleAllocPolicy::Alloc() -> RefPtr<Promise> {
RefPtr<Promise> p = self->mPendingPromise.Ensure(__func__);
GlobalAllocPolicy::Instance(self->mTrack)
->Alloc()
->Then(self->mOwnerThread, __func__,
[self, localToken = std::move(localToken)](
RefPtr<Token> aToken) mutable {
self->mTokenRequest.Complete();
RefPtr<Token> combinedToken = new AutoDeallocCombinedToken(
localToken.forget(), aToken.forget());
self->mPendingPromise.Resolve(combinedToken, __func__);
},
[self]() {
self->mTokenRequest.Complete();
self->mPendingPromise.Reject(true, __func__);
})
->Then(
self->mOwnerThread, __func__,
[self, localToken = std::move(localToken)](
RefPtr<Token> aToken) mutable {
self->mTokenRequest.Complete();
RefPtr<Token> combinedToken = new AutoDeallocCombinedToken(
localToken.forget(), aToken.forget());
self->mPendingPromise.Resolve(combinedToken, __func__);
},
[self]() {
self->mTokenRequest.Complete();
self->mPendingPromise.Reject(true, __func__);
})
->Track(self->mTokenRequest);
return p;
},
@ -212,47 +213,47 @@ AllocationWrapper::CreateDecoder(const CreateDecoderParams& aParams,
RefPtr<AllocateDecoderPromise> p =
(aPolicy ? aPolicy : GlobalAllocPolicy::Instance(aParams.mType))
->Alloc()
->Then(AbstractThread::GetCurrent(), __func__,
[=](RefPtr<Token> aToken) {
// result may not always be updated by
// PDMFactory::CreateDecoder either when the creation
// succeeded or failed, as such it must be initialized to a
// fatal error by default.
MediaResult result =
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
nsPrintfCString("error creating %s decoder",
TrackTypeToStr(type)));
RefPtr<PDMFactory> pdm = new PDMFactory();
CreateDecoderParams params{*config,
taskQueue,
diagnostics,
imageContainer,
&result,
knowsCompositor,
crashHelper,
useNullDecoder,
noWrapper,
type,
onWaitingForKeyEvent,
options,
rate};
RefPtr<MediaDataDecoder> decoder =
pdm->CreateDecoder(params);
if (decoder) {
RefPtr<AllocationWrapper> wrapper = new AllocationWrapper(
decoder.forget(), aToken.forget());
return AllocateDecoderPromise::CreateAndResolve(wrapper,
__func__);
}
return AllocateDecoderPromise::CreateAndReject(result,
->Then(
AbstractThread::GetCurrent(), __func__,
[=](RefPtr<Token> aToken) {
// result may not always be updated by
// PDMFactory::CreateDecoder either when the creation
// succeeded or failed, as such it must be initialized to a
// fatal error by default.
MediaResult result =
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
nsPrintfCString("error creating %s decoder",
TrackTypeToStr(type)));
RefPtr<PDMFactory> pdm = new PDMFactory();
CreateDecoderParams params{*config,
taskQueue,
diagnostics,
imageContainer,
&result,
knowsCompositor,
crashHelper,
useNullDecoder,
noWrapper,
type,
onWaitingForKeyEvent,
options,
rate};
RefPtr<MediaDataDecoder> decoder = pdm->CreateDecoder(params);
if (decoder) {
RefPtr<AllocationWrapper> wrapper =
new AllocationWrapper(decoder.forget(), aToken.forget());
return AllocateDecoderPromise::CreateAndResolve(wrapper,
__func__);
},
[]() {
return AllocateDecoderPromise::CreateAndReject(
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
"Allocation policy expired"),
__func__);
});
}
return AllocateDecoderPromise::CreateAndReject(result,
__func__);
},
[]() {
return AllocateDecoderPromise::CreateAndReject(
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
"Allocation policy expired"),
__func__);
});
return p;
}

View File

@ -101,12 +101,13 @@ class EMEDecryptor : public MediaDataDecoder,
RefPtr<DecodePromise> p = mDecodePromise.Ensure(__func__);
mSamplesWaitingForKey->WaitIfKeyNotUsable(sample)
->Then(mTaskQueue, __func__,
[self](const RefPtr<MediaRawData>& aSample) {
self->mKeyRequest.Complete();
self->ThrottleDecode(aSample);
},
[self]() { self->mKeyRequest.Complete(); })
->Then(
mTaskQueue, __func__,
[self](const RefPtr<MediaRawData>& aSample) {
self->mKeyRequest.Complete();
self->ThrottleDecode(aSample);
},
[self]() { self->mKeyRequest.Complete(); })
->Track(mKeyRequest);
return p;
@ -118,12 +119,13 @@ class EMEDecryptor : public MediaDataDecoder,
RefPtr<EMEDecryptor> self = this;
mThroughputLimiter.Throttle(aSample)
->Then(mTaskQueue, __func__,
[self](RefPtr<MediaRawData> aSample) {
self->mThrottleRequest.Complete();
self->AttemptDecode(aSample);
},
[self]() { self->mThrottleRequest.Complete(); })
->Then(
mTaskQueue, __func__,
[self](RefPtr<MediaRawData> aSample) {
self->mThrottleRequest.Complete();
self->AttemptDecode(aSample);
},
[self]() { self->mThrottleRequest.Complete(); })
->Track(mThrottleRequest);
}
@ -311,24 +313,25 @@ RefPtr<MediaDataDecoder::DecodePromise> EMEMediaDataDecoderProxy::Decode(
return InvokeAsync(mThread, __func__, [self, this, sample]() {
RefPtr<DecodePromise> p = mDecodePromise.Ensure(__func__);
mSamplesWaitingForKey->WaitIfKeyNotUsable(sample)
->Then(mThread, __func__,
[self, this](RefPtr<MediaRawData> aSample) {
mKeyRequest.Complete();
->Then(
mThread, __func__,
[self, this](RefPtr<MediaRawData> aSample) {
mKeyRequest.Complete();
MediaDataDecoderProxy::Decode(aSample)
->Then(mThread, __func__,
[self, this](
DecodePromise::ResolveOrRejectValue&& aValue) {
mDecodeRequest.Complete();
mDecodePromise.ResolveOrReject(std::move(aValue),
__func__);
})
->Track(mDecodeRequest);
},
[self]() {
self->mKeyRequest.Complete();
MOZ_CRASH("Should never get here");
})
MediaDataDecoderProxy::Decode(aSample)
->Then(mThread, __func__,
[self,
this](DecodePromise::ResolveOrRejectValue&& aValue) {
mDecodeRequest.Complete();
mDecodePromise.ResolveOrReject(std::move(aValue),
__func__);
})
->Track(mDecodeRequest);
},
[self]() {
self->mKeyRequest.Complete();
MOZ_CRASH("Should never get here");
})
->Track(mKeyRequest);
return p;

View File

@ -139,15 +139,16 @@ RefPtr<MediaDataDecoder::InitPromise> OmxDataDecoder::Init() {
RefPtr<InitPromise> p = mInitPromise.Ensure(__func__);
mOmxLayer->Init(mTrackInfo.get())
->Then(mOmxTaskQueue, __func__,
[self, this]() {
// Omx state should be OMX_StateIdle.
mOmxState = mOmxLayer->GetState();
MOZ_ASSERT(mOmxState != OMX_StateIdle);
},
[self, this]() {
RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
});
->Then(
mOmxTaskQueue, __func__,
[self, this]() {
// Omx state should be OMX_StateIdle.
mOmxState = mOmxLayer->GetState();
MOZ_ASSERT(mOmxState != OMX_StateIdle);
},
[self, this]() {
RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
});
return p;
});
}
@ -211,39 +212,41 @@ RefPtr<ShutdownPromise> OmxDataDecoder::DoAsyncShutdown() {
// Flush to all ports, so all buffers can be returned from component.
RefPtr<OmxDataDecoder> self = this;
mOmxLayer->SendCommand(OMX_CommandFlush, OMX_ALL, nullptr)
->Then(mOmxTaskQueue, __func__,
[self]() -> RefPtr<OmxCommandPromise> {
LOGL("DoAsyncShutdown: flush complete");
return self->mOmxLayer->SendCommand(OMX_CommandStateSet,
OMX_StateIdle, nullptr);
},
[self](const OmxCommandFailureHolder& aError) {
self->mOmxLayer->Shutdown();
return OmxCommandPromise::CreateAndReject(aError, __func__);
})
->Then(mOmxTaskQueue, __func__,
[self]() -> RefPtr<OmxCommandPromise> {
RefPtr<OmxCommandPromise> p = self->mOmxLayer->SendCommand(
OMX_CommandStateSet, OMX_StateLoaded, nullptr);
->Then(
mOmxTaskQueue, __func__,
[self]() -> RefPtr<OmxCommandPromise> {
LOGL("DoAsyncShutdown: flush complete");
return self->mOmxLayer->SendCommand(OMX_CommandStateSet,
OMX_StateIdle, nullptr);
},
[self](const OmxCommandFailureHolder& aError) {
self->mOmxLayer->Shutdown();
return OmxCommandPromise::CreateAndReject(aError, __func__);
})
->Then(
mOmxTaskQueue, __func__,
[self]() -> RefPtr<OmxCommandPromise> {
RefPtr<OmxCommandPromise> p = self->mOmxLayer->SendCommand(
OMX_CommandStateSet, OMX_StateLoaded, nullptr);
// According to spec 3.1.1.2.2.1:
// OMX_StateLoaded needs to be sent before releasing buffers.
// And state transition from OMX_StateIdle to OMX_StateLoaded
// is completed when all of the buffers have been removed
// from the component.
// Here the buffer promises are not resolved due to displaying
// in layer, it needs to wait before the layer returns the
// buffers.
LOGL("DoAsyncShutdown: releasing buffers...");
self->ReleaseBuffers(OMX_DirInput);
self->ReleaseBuffers(OMX_DirOutput);
// According to spec 3.1.1.2.2.1:
// OMX_StateLoaded needs to be sent before releasing buffers.
// And state transition from OMX_StateIdle to OMX_StateLoaded
// is completed when all of the buffers have been removed
// from the component.
// Here the buffer promises are not resolved due to displaying
// in layer, it needs to wait before the layer returns the
// buffers.
LOGL("DoAsyncShutdown: releasing buffers...");
self->ReleaseBuffers(OMX_DirInput);
self->ReleaseBuffers(OMX_DirOutput);
return p;
},
[self](const OmxCommandFailureHolder& aError) {
self->mOmxLayer->Shutdown();
return OmxCommandPromise::CreateAndReject(aError, __func__);
})
return p;
},
[self](const OmxCommandFailureHolder& aError) {
self->mOmxLayer->Shutdown();
return OmxCommandPromise::CreateAndReject(aError, __func__);
})
->Then(
mOmxTaskQueue, __func__,
[self]() -> RefPtr<ShutdownPromise> {
@ -263,17 +266,18 @@ RefPtr<ShutdownPromise> OmxDataDecoder::DoAsyncShutdown() {
self->mMediaDataHelper = nullptr;
return ShutdownPromise::CreateAndReject(false, __func__);
})
->Then(mTaskQueue, __func__,
[self]() {
self->mOmxTaskQueue->BeginShutdown();
self->mOmxTaskQueue->AwaitShutdownAndIdle();
self->mShutdownPromise.Resolve(true, __func__);
},
[self]() {
self->mOmxTaskQueue->BeginShutdown();
self->mOmxTaskQueue->AwaitShutdownAndIdle();
self->mShutdownPromise.Resolve(true, __func__);
});
->Then(
mTaskQueue, __func__,
[self]() {
self->mOmxTaskQueue->BeginShutdown();
self->mOmxTaskQueue->AwaitShutdownAndIdle();
self->mShutdownPromise.Resolve(true, __func__);
},
[self]() {
self->mOmxTaskQueue->BeginShutdown();
self->mOmxTaskQueue->AwaitShutdownAndIdle();
self->mShutdownPromise.Resolve(true, __func__);
});
return mShutdownPromise.Ensure(__func__);
}
@ -325,18 +329,19 @@ void OmxDataDecoder::Output(BufferData* aData) {
RefPtr<OmxDataDecoder> self = this;
RefPtr<BufferData> buffer = aData;
p->Then(mOmxTaskQueue, __func__,
[self, buffer]() {
MOZ_RELEASE_ASSERT(buffer->mStatus ==
BufferData::BufferStatus::OMX_CLIENT_OUTPUT);
buffer->mStatus = BufferData::BufferStatus::FREE;
self->FillAndEmptyBuffers();
},
[buffer]() {
MOZ_RELEASE_ASSERT(buffer->mStatus ==
BufferData::BufferStatus::OMX_CLIENT_OUTPUT);
buffer->mStatus = BufferData::BufferStatus::FREE;
});
p->Then(
mOmxTaskQueue, __func__,
[self, buffer]() {
MOZ_RELEASE_ASSERT(buffer->mStatus ==
BufferData::BufferStatus::OMX_CLIENT_OUTPUT);
buffer->mStatus = BufferData::BufferStatus::FREE;
self->FillAndEmptyBuffers();
},
[buffer]() {
MOZ_RELEASE_ASSERT(buffer->mStatus ==
BufferData::BufferStatus::OMX_CLIENT_OUTPUT);
buffer->mStatus = BufferData::BufferStatus::FREE;
});
} else {
aData->mStatus = BufferData::BufferStatus::FREE;
}
@ -514,16 +519,16 @@ void OmxDataDecoder::OmxStateRunner() {
// Send OpenMax state command to OMX_StateIdle.
RefPtr<OmxDataDecoder> self = this;
mOmxLayer->SendCommand(OMX_CommandStateSet, OMX_StateIdle, nullptr)
->Then(mOmxTaskQueue, __func__,
[self]() {
// Current state should be OMX_StateIdle.
self->mOmxState = self->mOmxLayer->GetState();
MOZ_ASSERT(self->mOmxState == OMX_StateIdle);
},
[self]() {
self->RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR,
__func__);
});
->Then(
mOmxTaskQueue, __func__,
[self]() {
// Current state should be OMX_StateIdle.
self->mOmxState = self->mOmxLayer->GetState();
MOZ_ASSERT(self->mOmxState == OMX_StateIdle);
},
[self]() {
self->RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
});
// Allocate input and output buffers.
OMX_DIRTYPE types[] = {OMX_DIRTYPE::OMX_DirInput,
@ -538,17 +543,17 @@ void OmxDataDecoder::OmxStateRunner() {
} else if (mOmxState == OMX_StateIdle) {
RefPtr<OmxDataDecoder> self = this;
mOmxLayer->SendCommand(OMX_CommandStateSet, OMX_StateExecuting, nullptr)
->Then(mOmxTaskQueue, __func__,
[self]() {
self->mOmxState = self->mOmxLayer->GetState();
MOZ_ASSERT(self->mOmxState == OMX_StateExecuting);
->Then(
mOmxTaskQueue, __func__,
[self]() {
self->mOmxState = self->mOmxLayer->GetState();
MOZ_ASSERT(self->mOmxState == OMX_StateExecuting);
self->ResolveInitPromise(__func__);
},
[self]() {
self->RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR,
__func__);
});
self->ResolveInitPromise(__func__);
},
[self]() {
self->RejectInitPromise(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
});
} else if (mOmxState == OMX_StateExecuting) {
// Configure codec once it gets OMX_StateExecuting state.
FillCodecConfigDataToOmx();
@ -728,35 +733,36 @@ void OmxDataDecoder::PortSettingsChanged() {
LOG("PortSettingsChanged: disable port %lu", def.nPortIndex);
mOmxLayer
->SendCommand(OMX_CommandPortDisable, mPortSettingsChanged, nullptr)
->Then(mOmxTaskQueue, __func__,
[self, def]() -> RefPtr<OmxCommandPromise> {
// 3. enable port.
// Send enable port command.
RefPtr<OmxCommandPromise> p = self->mOmxLayer->SendCommand(
OMX_CommandPortEnable, self->mPortSettingsChanged,
nullptr);
->Then(
mOmxTaskQueue, __func__,
[self, def]() -> RefPtr<OmxCommandPromise> {
// 3. enable port.
// Send enable port command.
RefPtr<OmxCommandPromise> p = self->mOmxLayer->SendCommand(
OMX_CommandPortEnable, self->mPortSettingsChanged, nullptr);
// 4. allocate port buffers.
// Allocate new port buffers.
nsresult rv = self->AllocateBuffers(def.eDir);
if (NS_FAILED(rv)) {
self->NotifyError(OMX_ErrorUndefined, __func__);
}
// 4. allocate port buffers.
// Allocate new port buffers.
nsresult rv = self->AllocateBuffers(def.eDir);
if (NS_FAILED(rv)) {
self->NotifyError(OMX_ErrorUndefined, __func__);
}
return p;
},
[self](const OmxCommandFailureHolder& aError) {
self->NotifyError(OMX_ErrorUndefined, __func__);
return OmxCommandPromise::CreateAndReject(aError, __func__);
})
->Then(mOmxTaskQueue, __func__,
[self]() {
LOGL("PortSettingsChanged: port settings changed complete");
// finish port setting changed.
self->mPortSettingsChanged = -1;
self->FillAndEmptyBuffers();
},
[self]() { self->NotifyError(OMX_ErrorUndefined, __func__); });
return p;
},
[self](const OmxCommandFailureHolder& aError) {
self->NotifyError(OMX_ErrorUndefined, __func__);
return OmxCommandPromise::CreateAndReject(aError, __func__);
})
->Then(
mOmxTaskQueue, __func__,
[self]() {
LOGL("PortSettingsChanged: port settings changed complete");
// finish port setting changed.
self->mPortSettingsChanged = -1;
self->FillAndEmptyBuffers();
},
[self]() { self->NotifyError(OMX_ErrorUndefined, __func__); });
// 2. wait for port buffers return to client and then release these buffers.
//

View File

@ -298,7 +298,9 @@ bool OmxPromiseLayer::Event(OMX_EVENTTYPE aEvent, OMX_U32 aData1,
}
break;
}
default: { return false; }
default: {
return false;
}
}
return true;
}

View File

@ -36,9 +36,10 @@ class MFTDecoder final {
// - aOutputType needs at least major and minor types set.
// This is used to select the matching output type out
// of all the available output types of the MFT.
HRESULT SetMediaTypes(IMFMediaType* aInputType, IMFMediaType* aOutputType,
std::function<HRESULT(IMFMediaType*)>&& aCallback =
[](IMFMediaType* aOutput) { return S_OK; });
HRESULT SetMediaTypes(
IMFMediaType* aInputType, IMFMediaType* aOutputType,
std::function<HRESULT(IMFMediaType*)>&& aCallback =
[](IMFMediaType* aOutput) { return S_OK; });
// Returns the MFT's IMFAttributes object.
already_AddRefed<IMFAttributes> GetAttributes();

View File

@ -475,35 +475,36 @@ MediaResult MediaChangeMonitor::CreateDecoderAndInit(MediaRawData* aSample) {
RefPtr<MediaChangeMonitor> self = this;
RefPtr<MediaRawData> sample = aSample;
mDecoder->Init()
->Then(mTaskQueue, __func__,
[self, sample, this](const TrackType aTrackType) {
mInitPromiseRequest.Complete();
mConversionRequired = Some(mDecoder->NeedsConversion());
mCanRecycleDecoder = Some(CanRecycleDecoder());
->Then(
mTaskQueue, __func__,
[self, sample, this](const TrackType aTrackType) {
mInitPromiseRequest.Complete();
mConversionRequired = Some(mDecoder->NeedsConversion());
mCanRecycleDecoder = Some(CanRecycleDecoder());
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Resolve(true, __func__);
return;
}
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Resolve(true, __func__);
return;
}
DecodeFirstSample(sample);
},
[self, this](const MediaResult& aError) {
mInitPromiseRequest.Complete();
DecodeFirstSample(sample);
},
[self, this](const MediaResult& aError) {
mInitPromiseRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Reject(aError, __func__);
return;
}
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Reject(aError, __func__);
return;
}
mDecodePromise.Reject(
MediaResult(
NS_ERROR_DOM_MEDIA_FATAL_ERR,
RESULT_DETAIL("Unable to initialize H264 decoder")),
__func__);
})
mDecodePromise.Reject(
MediaResult(
NS_ERROR_DOM_MEDIA_FATAL_ERR,
RESULT_DETAIL("Unable to initialize H264 decoder")),
__func__);
})
->Track(mInitPromiseRequest);
return NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER;
}
@ -544,17 +545,18 @@ void MediaChangeMonitor::DecodeFirstSample(MediaRawData* aSample) {
RefPtr<MediaChangeMonitor> self = this;
mDecoder->Decode(aSample)
->Then(mTaskQueue, __func__,
[self, this](MediaDataDecoder::DecodedData&& aResults) {
mDecodePromiseRequest.Complete();
mPendingFrames.AppendElements(std::move(aResults));
mDecodePromise.Resolve(std::move(mPendingFrames), __func__);
mPendingFrames = DecodedData();
},
[self, this](const MediaResult& aError) {
mDecodePromiseRequest.Complete();
mDecodePromise.Reject(aError, __func__);
})
->Then(
mTaskQueue, __func__,
[self, this](MediaDataDecoder::DecodedData&& aResults) {
mDecodePromiseRequest.Complete();
mPendingFrames.AppendElements(std::move(aResults));
mDecodePromise.Resolve(std::move(mPendingFrames), __func__);
mPendingFrames = DecodedData();
},
[self, this](const MediaResult& aError) {
mDecodePromiseRequest.Complete();
mDecodePromise.Reject(aError, __func__);
})
->Track(mDecodePromiseRequest);
}
@ -589,32 +591,33 @@ void MediaChangeMonitor::DrainThenFlushDecoder(MediaRawData* aPendingSample) {
RefPtr<MediaRawData> sample = aPendingSample;
RefPtr<MediaChangeMonitor> self = this;
mDecoder->Drain()
->Then(mTaskQueue, __func__,
[self, sample, this](MediaDataDecoder::DecodedData&& aResults) {
mDrainRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Resolve(true, __func__);
return;
}
if (aResults.Length() > 0) {
mPendingFrames.AppendElements(std::move(aResults));
DrainThenFlushDecoder(sample);
return;
}
// We've completed the draining operation, we can now flush the
// decoder.
FlushThenShutdownDecoder(sample);
},
[self, this](const MediaResult& aError) {
mDrainRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Reject(aError, __func__);
return;
}
mDecodePromise.Reject(aError, __func__);
})
->Then(
mTaskQueue, __func__,
[self, sample, this](MediaDataDecoder::DecodedData&& aResults) {
mDrainRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Resolve(true, __func__);
return;
}
if (aResults.Length() > 0) {
mPendingFrames.AppendElements(std::move(aResults));
DrainThenFlushDecoder(sample);
return;
}
// We've completed the draining operation, we can now flush the
// decoder.
FlushThenShutdownDecoder(sample);
},
[self, this](const MediaResult& aError) {
mDrainRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Reject(aError, __func__);
return;
}
mDecodePromise.Reject(aError, __func__);
})
->Track(mDrainRequest);
}
@ -625,51 +628,53 @@ void MediaChangeMonitor::FlushThenShutdownDecoder(
RefPtr<MediaRawData> sample = aPendingSample;
RefPtr<MediaChangeMonitor> self = this;
mDecoder->Flush()
->Then(mTaskQueue, __func__,
[self, sample, this]() {
mFlushRequest.Complete();
->Then(
mTaskQueue, __func__,
[self, sample, this]() {
mFlushRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Resolve(true, __func__);
return;
}
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Resolve(true, __func__);
return;
}
mShutdownPromise = ShutdownDecoder();
mShutdownPromise
->Then(mTaskQueue, __func__,
[self, sample, this]() {
mShutdownRequest.Complete();
mShutdownPromise = nullptr;
mShutdownPromise = ShutdownDecoder();
mShutdownPromise
->Then(
mTaskQueue, __func__,
[self, sample, this]() {
mShutdownRequest.Complete();
mShutdownPromise = nullptr;
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current
// operation.
mFlushPromise.Resolve(true, __func__);
return;
}
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current
// operation.
mFlushPromise.Resolve(true, __func__);
return;
}
MediaResult rv = CreateDecoderAndInit(sample);
if (rv == NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER) {
// All good so far, will continue later.
return;
}
MOZ_ASSERT(NS_FAILED(rv));
mDecodePromise.Reject(rv, __func__);
return;
},
[] { MOZ_CRASH("Can't reach here'"); })
->Track(mShutdownRequest);
},
[self, this](const MediaResult& aError) {
mFlushRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Reject(aError, __func__);
return;
}
mDecodePromise.Reject(aError, __func__);
})
MediaResult rv = CreateDecoderAndInit(sample);
if (rv == NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER) {
// All good so far, will continue later.
return;
}
MOZ_ASSERT(NS_FAILED(rv));
mDecodePromise.Reject(rv, __func__);
return;
},
[] { MOZ_CRASH("Can't reach here'"); })
->Track(mShutdownRequest);
},
[self, this](const MediaResult& aError) {
mFlushRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Reject(aError, __func__);
return;
}
mDecodePromise.Reject(aError, __func__);
})
->Track(mFlushRequest);
}

View File

@ -224,19 +224,20 @@ Await(already_AddRefed<nsIEventTarget> aPool,
typename MozPromise<ResolveValueType, RejectValueType,
Excl>::ResolveOrRejectValue val;
aPromise->Then(taskQueue, __func__,
[&](ResolveValueType aResolveValue) {
val.SetResolve(std::move(aResolveValue));
MonitorAutoLock lock(mon);
done = true;
mon.Notify();
},
[&](RejectValueType aRejectValue) {
val.SetReject(std::move(aRejectValue));
MonitorAutoLock lock(mon);
done = true;
mon.Notify();
});
aPromise->Then(
taskQueue, __func__,
[&](ResolveValueType aResolveValue) {
val.SetResolve(std::move(aResolveValue));
MonitorAutoLock lock(mon);
done = true;
mon.Notify();
},
[&](RejectValueType aRejectValue) {
val.SetReject(std::move(aRejectValue));
MonitorAutoLock lock(mon);
done = true;
mon.Notify();
});
MonitorAutoLock lock(mon);
while (!done) {

View File

@ -107,18 +107,18 @@ class DenormalDisabler {
inline int getStatusWord() {
int result;
# if defined(__aarch64__)
asm volatile("mrs %x[result], FPCR" : [result] "=r"(result));
asm volatile("mrs %x[result], FPCR" : [ result ] "=r"(result));
# else
asm volatile("vmrs %[result], FPSCR" : [result] "=r"(result));
asm volatile("vmrs %[result], FPSCR" : [ result ] "=r"(result));
# endif
return result;
}
inline void setStatusWord(int a) {
# if defined(__aarch64__)
asm volatile("msr FPCR, %x[src]" : : [src] "r"(a));
asm volatile("msr FPCR, %x[src]" : : [ src ] "r"(a));
# else
asm volatile("vmsr FPSCR, %[src]" : : [src] "r"(a));
asm volatile("vmsr FPSCR, %[src]" : : [ src ] "r"(a));
# endif
}

View File

@ -538,7 +538,9 @@ int MediaEngineRemoteVideoSource::DeliverFrame(
}
break;
}
default: { break; }
default: {
break;
}
}
rtc::Callback0<void> callback_unused;

View File

@ -679,29 +679,30 @@ void SpeechRecognition::Start(const Optional<NonNull<DOMMediaStream>>& aStream,
RefPtr<SpeechRecognition> self(this);
MediaManager::Get()
->GetUserMedia(GetOwner(), constraints, aCallerType)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[this, self](RefPtr<DOMMediaStream>&& aStream) {
mStream = std::move(aStream);
mStream->RegisterTrackListener(this);
nsTArray<RefPtr<AudioStreamTrack>> tracks;
mStream->GetAudioTracks(tracks);
for (const RefPtr<AudioStreamTrack>& track : tracks) {
if (!track->Ended()) {
NotifyTrackAdded(track);
}
}
},
[this, self](RefPtr<MediaMgrError>&& error) {
SpeechRecognitionErrorCode errorCode;
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[this, self](RefPtr<DOMMediaStream>&& aStream) {
mStream = std::move(aStream);
mStream->RegisterTrackListener(this);
nsTArray<RefPtr<AudioStreamTrack>> tracks;
mStream->GetAudioTracks(tracks);
for (const RefPtr<AudioStreamTrack>& track : tracks) {
if (!track->Ended()) {
NotifyTrackAdded(track);
}
}
},
[this, self](RefPtr<MediaMgrError>&& error) {
SpeechRecognitionErrorCode errorCode;
if (error->mName == MediaMgrError::Name::NotAllowedError) {
errorCode = SpeechRecognitionErrorCode::Not_allowed;
} else {
errorCode = SpeechRecognitionErrorCode::Audio_capture;
}
DispatchError(SpeechRecognition::EVENT_AUDIO_ERROR, errorCode,
error->mMessage);
});
if (error->mName == MediaMgrError::Name::NotAllowedError) {
errorCode = SpeechRecognitionErrorCode::Not_allowed;
} else {
errorCode = SpeechRecognitionErrorCode::Audio_capture;
}
DispatchError(SpeechRecognition::EVENT_AUDIO_ERROR, errorCode,
error->mMessage);
});
}
RefPtr<SpeechEvent> event = new SpeechEvent(this, EVENT_START);

View File

@ -268,7 +268,9 @@ PaymentShowActionResponse::Init(const nsAString& aRequestId,
}
break;
}
default: { return NS_ERROR_FAILURE; }
default: {
return NS_ERROR_FAILURE;
}
}
}
mData = aData;

View File

@ -143,7 +143,9 @@ void PaymentMethodChangeEvent::GetMethodDetails(
aRetVal.set(&value.toObject());
break;
}
default: { break; }
default: {
break;
}
}
}

View File

@ -264,7 +264,9 @@ void ConvertResponseData(const IPCPaymentResponseData& aIPCData,
aData = bData;
break;
}
default: { break; }
default: {
break;
}
}
}
@ -301,7 +303,9 @@ void ConvertMethodChangeDetails(const IPCMethodChangeDetails& aIPCDetails,
aDetails = bDetails;
break;
}
default: { break; }
default: {
break;
}
}
}
} // end of namespace
@ -681,7 +685,9 @@ nsresult PaymentRequestManager::RespondPayment(
NotifyRequestDone(aRequest);
break;
}
default: { return NS_ERROR_FAILURE; }
default: {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}

View File

@ -178,7 +178,9 @@ nsresult PaymentRequestService::LaunchUIAction(const nsAString& aRequestId,
rv = uiService->ClosePayment(aRequestId);
break;
}
default: { return NS_ERROR_FAILURE; }
default: {
return NS_ERROR_FAILURE;
}
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -332,7 +334,9 @@ nsresult PaymentRequestService::RequestPayment(
aRequestId, IPCPaymentActionRequest::TIPCPaymentUpdateActionRequest);
break;
}
default: { return NS_ERROR_FAILURE; }
default: {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
@ -418,7 +422,9 @@ PaymentRequestService::RespondPayment(nsIPaymentActionResponse* aResponse) {
mRequestQueue.RemoveElement(request);
break;
}
default: { break; }
default: {
break;
}
}
return NS_OK;
}

View File

@ -66,7 +66,9 @@ mozilla::ipc::IPCResult PaymentRequestParent::RecvRequestPayment(
mRequestId = request.requestId();
break;
}
default: { return IPC_FAIL(this, "Unknown PaymentRequest action type"); }
default: {
return IPC_FAIL(this, "Unknown PaymentRequest action type");
}
}
nsCOMPtr<nsIPaymentRequestService> service =
do_GetService(NS_PAYMENT_REQUEST_SERVICE_CONTRACT_ID);
@ -176,7 +178,9 @@ nsresult PaymentRequestParent::RespondPayment(
}
break;
}
default: { return NS_ERROR_FAILURE; }
default: {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
@ -310,7 +314,9 @@ nsresult PaymentRequestParent::ChangePaymentMethod(
ipcChangeDetails = ipcBasicCardDetails;
break;
}
default: { return NS_ERROR_FAILURE; }
default: {
return NS_ERROR_FAILURE;
}
}
}
if (!SendChangePaymentMethod(requestId, methodName, ipcChangeDetails)) {
@ -454,7 +460,9 @@ nsresult PaymentRequestParent::SerializeResponseData(
aIPCData = data;
break;
}
default: { return NS_ERROR_FAILURE; }
default: {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}

View File

@ -5602,7 +5602,9 @@ bool QuotaManager::IsPrincipalInfoValid(const PrincipalInfo& aPrincipalInfo) {
return true;
}
default: { break; }
default: {
break;
}
}
// Null and expanded principals are not acceptable.
@ -5643,7 +5645,9 @@ void QuotaManager::GetInfoFromValidatedPrincipalInfo(
return;
}
default: { break; }
default: {
break;
}
}
MOZ_CRASH("Should never get here!");
@ -8237,7 +8241,9 @@ bool PrincipalVerifier::IsPrincipalInfoValid(
return true;
}
default: { break; }
default: {
break;
}
}
// Null and expanded principals are not acceptable.

View File

@ -54,17 +54,18 @@ void ServiceWorkerContainerImpl::Register(
global);
swm->Register(aClientInfo, aScopeURL, aScriptURL, aUpdateViaCache)
->Then(global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aResult) {
holder->Complete();
failureCB(CopyableErrorResult(aResult));
})
->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aResult) {
holder->Complete();
failureCB(CopyableErrorResult(aResult));
})
->Track(*holder);
}
@ -91,17 +92,18 @@ void ServiceWorkerContainerImpl::GetRegistration(
global);
swm->GetRegistration(aClientInfo, aURL)
->Then(global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aResult) {
holder->Complete();
failureCB(CopyableErrorResult(aResult));
})
->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aResult) {
holder->Complete();
failureCB(CopyableErrorResult(aResult));
})
->Track(*holder);
}
@ -127,17 +129,18 @@ void ServiceWorkerContainerImpl::GetRegistrations(
DOMMozPromiseRequestHolder<ServiceWorkerRegistrationListPromise>>(global);
swm->GetRegistrations(aClientInfo)
->Then(global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB), holder](
const nsTArray<ServiceWorkerRegistrationDescriptor>& aList) {
holder->Complete();
successCB(aList);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aResult) {
holder->Complete();
failureCB(CopyableErrorResult(aResult));
})
->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const nsTArray<ServiceWorkerRegistrationDescriptor>& aList) {
holder->Complete();
successCB(aList);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aResult) {
holder->Complete();
failureCB(CopyableErrorResult(aResult));
})
->Track(*holder);
}
@ -164,17 +167,18 @@ void ServiceWorkerContainerImpl::GetReady(
global);
swm->WhenReady(aClientInfo)
->Then(global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aResult) {
holder->Complete();
failureCB(CopyableErrorResult(aResult));
})
->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aResult) {
holder->Complete();
failureCB(CopyableErrorResult(aResult));
})
->Track(*holder);
}

View File

@ -79,18 +79,19 @@ IPCResult ServiceWorkerContainerParent::RecvGetRegistrations(
}
mProxy->GetRegistrations(ClientInfo(aClientInfo))
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[aResolver](
const nsTArray<ServiceWorkerRegistrationDescriptor>& aList) {
IPCServiceWorkerRegistrationDescriptorList ipcList;
for (auto& desc : aList) {
ipcList.values().AppendElement(desc.ToIPC());
}
aResolver(std::move(ipcList));
},
[aResolver](const CopyableErrorResult& aResult) {
aResolver(aResult);
});
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[aResolver](
const nsTArray<ServiceWorkerRegistrationDescriptor>& aList) {
IPCServiceWorkerRegistrationDescriptorList ipcList;
for (auto& desc : aList) {
ipcList.values().AppendElement(desc.ToIPC());
}
aResolver(std::move(ipcList));
},
[aResolver](const CopyableErrorResult& aResult) {
aResolver(aResult);
});
return IPC_OK();
}

View File

@ -2452,14 +2452,15 @@ void ServiceWorkerManager::UpdateClientControllers(
// If we fail to control the client, then automatically remove it
// from our list of controlled clients.
p->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
[](bool) {
// do nothing on success
},
[self, clientInfo = handle->Info()](nsresult aRv) {
// failed to control, forget about this client
self->StopControllingClient(clientInfo);
});
p->Then(
SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
[](bool) {
// do nothing on success
},
[self, clientInfo = handle->Info()](nsresult aRv) {
// failed to control, forget about this client
self->StopControllingClient(clientInfo);
});
}
}

View File

@ -504,17 +504,18 @@ void ServiceWorkerRegistrationMainThread::Update(
global);
cb->Promise()
->Then(global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aRv) {
holder->Complete();
failureCB(CopyableErrorResult(aRv));
})
->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aRv) {
holder->Complete();
failureCB(CopyableErrorResult(aRv));
})
->Track(*holder);
}
@ -555,15 +556,16 @@ void ServiceWorkerRegistrationMainThread::Unregister(
auto holder = MakeRefPtr<DOMMozPromiseRequestHolder<GenericPromise>>(global);
cb->Promise()
->Then(global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB), holder](bool aResult) {
holder->Complete();
successCB(aResult);
},
[failureCB = std::move(aFailureCB), holder](nsresult aRv) {
holder->Complete();
failureCB(CopyableErrorResult(aRv));
})
->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB), holder](bool aResult) {
holder->Complete();
successCB(aResult);
},
[failureCB = std::move(aFailureCB), holder](nsresult aRv) {
holder->Complete();
failureCB(CopyableErrorResult(aRv));
})
->Track(*holder);
}
@ -769,17 +771,18 @@ void ServiceWorkerRegistrationWorkerThread::Update(
global);
promise
->Then(global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aRv) {
holder->Complete();
failureCB(CopyableErrorResult(aRv));
})
->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB),
holder](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
holder->Complete();
successCB(aDescriptor);
},
[failureCB = std::move(aFailureCB),
holder](const CopyableErrorResult& aRv) {
holder->Complete();
failureCB(CopyableErrorResult(aRv));
})
->Track(*holder);
RefPtr<SWRUpdateRunnable> r = new SWRUpdateRunnable(
@ -824,15 +827,16 @@ void ServiceWorkerRegistrationWorkerThread::Unregister(
auto holder = MakeRefPtr<DOMMozPromiseRequestHolder<GenericPromise>>(global);
promise
->Then(global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB), holder](bool aResult) {
holder->Complete();
successCB(aResult);
},
[failureCB = std::move(aFailureCB), holder](nsresult aRv) {
holder->Complete();
failureCB(CopyableErrorResult(aRv));
})
->Then(
global->EventTargetFor(TaskCategory::Other), __func__,
[successCB = std::move(aSuccessCB), holder](bool aResult) {
holder->Complete();
successCB(aResult);
},
[failureCB = std::move(aFailureCB), holder](nsresult aRv) {
holder->Complete();
failureCB(CopyableErrorResult(aRv));
})
->Track(*holder);
RefPtr<StartUnregisterRunnable> r =

View File

@ -333,22 +333,23 @@ void U2FTokenManager::DoRegister(const WebAuthnMakeCredentialInfo& aInfo,
mozilla::TimeStamp startTime = mozilla::TimeStamp::Now();
mTokenManagerImpl->Register(aInfo, aForceNoneAttestation)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[tid, startTime](WebAuthnMakeCredentialResult&& aResult) {
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeConfirmRegister(tid, aResult);
Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED,
NS_LITERAL_STRING("U2FRegisterFinish"), 1);
Telemetry::AccumulateTimeDelta(
Telemetry::WEBAUTHN_CREATE_CREDENTIAL_MS, startTime);
},
[tid](nsresult rv) {
MOZ_ASSERT(NS_FAILED(rv));
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeAbortRegister(tid, rv);
Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED,
NS_LITERAL_STRING("U2FRegisterAbort"), 1);
})
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[tid, startTime](WebAuthnMakeCredentialResult&& aResult) {
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeConfirmRegister(tid, aResult);
Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED,
NS_LITERAL_STRING("U2FRegisterFinish"), 1);
Telemetry::AccumulateTimeDelta(
Telemetry::WEBAUTHN_CREATE_CREDENTIAL_MS, startTime);
},
[tid](nsresult rv) {
MOZ_ASSERT(NS_FAILED(rv));
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeAbortRegister(tid, rv);
Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED,
NS_LITERAL_STRING("U2FRegisterAbort"), 1);
})
->Track(mRegisterPromise);
}
@ -391,22 +392,23 @@ void U2FTokenManager::Sign(PWebAuthnTransactionParent* aTransactionParent,
mozilla::TimeStamp startTime = mozilla::TimeStamp::Now();
mTokenManagerImpl->Sign(aTransactionInfo)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[tid, startTime](WebAuthnGetAssertionResult&& aResult) {
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeConfirmSign(tid, aResult);
Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED,
NS_LITERAL_STRING("U2FSignFinish"), 1);
Telemetry::AccumulateTimeDelta(
Telemetry::WEBAUTHN_GET_ASSERTION_MS, startTime);
},
[tid](nsresult rv) {
MOZ_ASSERT(NS_FAILED(rv));
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeAbortSign(tid, rv);
Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED,
NS_LITERAL_STRING("U2FSignAbort"), 1);
})
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[tid, startTime](WebAuthnGetAssertionResult&& aResult) {
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeConfirmSign(tid, aResult);
Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED,
NS_LITERAL_STRING("U2FSignFinish"), 1);
Telemetry::AccumulateTimeDelta(Telemetry::WEBAUTHN_GET_ASSERTION_MS,
startTime);
},
[tid](nsresult rv) {
MOZ_ASSERT(NS_FAILED(rv));
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeAbortSign(tid, rv);
Telemetry::ScalarAdd(Telemetry::ScalarID::SECURITY_WEBAUTHN_USED,
NS_LITERAL_STRING("U2FSignAbort"), 1);
})
->Track(mSignPromise);
}

View File

@ -517,18 +517,19 @@ RefPtr<PerformanceInfoPromise> WorkerDebugger::ReportPerformanceInfo() {
SystemGroup::AbstractMainThreadFor(TaskCategory::Performance);
return CollectMemoryInfo(top, mainThread)
->Then(mainThread, __func__,
[workerRef, url, pid, perfId, windowID, duration, isTopLevel,
items](const PerformanceMemoryInfo& aMemoryInfo) {
return PerformanceInfoPromise::CreateAndResolve(
PerformanceInfo(url, pid, windowID, duration, perfId, true,
isTopLevel, aMemoryInfo, items),
__func__);
},
[workerRef]() {
return PerformanceInfoPromise::CreateAndReject(NS_ERROR_FAILURE,
__func__);
});
->Then(
mainThread, __func__,
[workerRef, url, pid, perfId, windowID, duration, isTopLevel,
items](const PerformanceMemoryInfo& aMemoryInfo) {
return PerformanceInfoPromise::CreateAndResolve(
PerformanceInfo(url, pid, windowID, duration, perfId, true,
isTopLevel, aMemoryInfo, items),
__func__);
},
[workerRef]() {
return PerformanceInfoPromise::CreateAndReject(NS_ERROR_FAILURE,
__func__);
});
}
} // namespace dom

View File

@ -1491,8 +1491,8 @@ nsresult XMLHttpRequestMainThread::StreamReaderFunc(
xmlHttpRequest->MaybeCreateBlobStorage();
rv = xmlHttpRequest->mBlobStorage->Append(fromRawSegment, count);
} else if (xmlHttpRequest->mResponseType ==
XMLHttpRequestResponseType::Arraybuffer &&
!xmlHttpRequest->mIsMappedArrayBuffer) {
XMLHttpRequestResponseType::Arraybuffer &&
!xmlHttpRequest->mIsMappedArrayBuffer) {
// get the initial capacity to something reasonable to avoid a bunch of
// reallocs right at the start
if (xmlHttpRequest->mArrayBufferBuilder.capacity() == 0)

View File

@ -130,7 +130,9 @@ void XMLUtils::normalizePIValue(nsAString& piValue) {
}
break;
}
default: { break; }
default: {
break;
}
}
piValue.Append(ch);
prevCh = ch;

View File

@ -165,7 +165,9 @@ nsresult XPathResult::SetExprResult(txAExprResult* aExprResult,
mResult->stringValue(mStringResult);
break;
}
default: { MOZ_ASSERT(isNode() || isIterator() || isSnapshot()); }
default: {
MOZ_ASSERT(isNode() || isIterator() || isSnapshot());
}
}
if (aExprResult->getResultType() == txAExprResult::NODESET) {

View File

@ -187,7 +187,9 @@ nsresult txCoreFunctionCall::evaluate(txIEvalContext* aContext,
return NS_OK;
}
default: { MOZ_CRASH("Unexpected mType?!"); }
default: {
MOZ_CRASH("Unexpected mType?!");
}
}
MOZ_CRASH("Inner mType switch should have returned!");
}

View File

@ -122,7 +122,9 @@ bool RelationalExpr::compareResults(txIEvalContext* aContext,
case GREATER_OR_EQUAL: {
return (leftDbl >= rightDbl);
}
default: { MOZ_ASSERT_UNREACHABLE("We should have caught all cases"); }
default: {
MOZ_ASSERT_UNREACHABLE("We should have caught all cases");
}
}
return false;

View File

@ -56,7 +56,9 @@ void txResultRecycler::recycle(txAExprResult* aResult) {
}
return;
}
default: { delete aResult; }
default: {
delete aResult;
}
}
}

View File

@ -354,7 +354,9 @@ static nsresult flushTransaction(txOutputTransaction* aTransaction,
return aHandler->startElement(
transaction->mPrefix, transaction->mLocalName, transaction->mNsID);
}
default: { MOZ_ASSERT_UNREACHABLE("Unexpected transaction type"); }
default: {
MOZ_ASSERT_UNREACHABLE("Unexpected transaction type");
}
}
return NS_ERROR_UNEXPECTED;

View File

@ -808,7 +808,9 @@ nsresult txMozillaXSLTProcessor::SetParameter(const nsAString& aNamespaceURI,
break;
}
default: { return NS_ERROR_FAILURE; }
default: {
return NS_ERROR_FAILURE;
}
}
int32_t nsId = kNameSpaceID_Unknown;

View File

@ -806,32 +806,33 @@ nsresult EditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher) {
RefPtr<EditorSpellCheck> self = this;
RefPtr<DictionaryFetcher> fetcher = aFetcher;
mSpellChecker->SetCurrentDictionaryFromList(tryDictList)
->Then(GetMainThreadSerialEventTarget(), __func__,
[self, fetcher]() {
->Then(
GetMainThreadSerialEventTarget(), __func__,
[self, fetcher]() {
#ifdef DEBUG_DICT
printf("***** Assigned from content preferences |%s|\n",
NS_ConvertUTF16toUTF8(dictName).get());
printf("***** Assigned from content preferences |%s|\n",
NS_ConvertUTF16toUTF8(dictName).get());
#endif
// We take an early exit here, so let's not forget to clear
// the word list.
self->DeleteSuggestedWordList();
// We take an early exit here, so let's not forget to clear
// the word list.
self->DeleteSuggestedWordList();
self->EndUpdateDictionary();
if (fetcher->mCallback) {
fetcher->mCallback->EditorSpellCheckDone();
}
},
[self, fetcher](nsresult aError) {
if (aError == NS_ERROR_ABORT) {
return;
}
// May be dictionary was uninstalled ?
// Clear the content preference and continue.
ClearCurrentDictionary(self->mEditor);
self->EndUpdateDictionary();
if (fetcher->mCallback) {
fetcher->mCallback->EditorSpellCheckDone();
}
},
[self, fetcher](nsresult aError) {
if (aError == NS_ERROR_ABORT) {
return;
}
// May be dictionary was uninstalled ?
// Clear the content preference and continue.
ClearCurrentDictionary(self->mEditor);
// Priority 2 or later will handled by the following
self->SetFallbackDictionary(fetcher);
});
// Priority 2 or later will handled by the following
self->SetFallbackDictionary(fetcher);
});
return NS_OK;
}
}

View File

@ -3430,12 +3430,13 @@ nsPermissionManager::WhenPermissionsAvailable(nsIPrincipal* aPrincipal,
RefPtr<nsIRunnable> runnable = aRunnable;
GenericPromise::All(thread, promises)
->Then(thread, __func__, [runnable]() { runnable->Run(); },
[]() {
NS_WARNING(
"nsPermissionManager permission promise rejected. We're "
"probably shutting down.");
});
->Then(
thread, __func__, [runnable]() { runnable->Run(); },
[]() {
NS_WARNING(
"nsPermissionManager permission promise rejected. We're "
"probably shutting down.");
});
return NS_OK;
}

View File

@ -32,8 +32,8 @@ __m128i loadUnaligned128(__m128i *p) {
"gsldlc1 %[vl], 0x7(%[p]) \n\t"
"gsldrc1 %[vl], 0x0(%[p]) \n\t"
".set pop \n\t"
: [vh] "=f"(v.h), [vl] "=f"(v.l)
: [p] "r"(p)
: [ vh ] "=f"(v.h), [ vl ] "=f"(v.l)
: [ p ] "r"(p)
: "memory");
return v;
@ -56,8 +56,8 @@ __m128i Divide(__m128i aValues, __m128i aDivisor) {
"mthc1 %[tmp], %[maskl] \n\t"
"mov.d %[maskh], %[maskl] \n\t"
".set pop \n\t"
: [rah] "=f"(ra.h), [ral] "=f"(ra.l), [maskh] "=f"(mask.h),
[maskl] "=f"(mask.l), [tmp] "=&r"(tmp));
: [ rah ] "=f"(ra.h), [ ral ] "=f"(ra.l), [ maskh ] "=f"(mask.h),
[ maskl ] "=f"(mask.l), [ tmp ] "=&r"(tmp));
asm volatile(
".set push \n\t"
@ -69,12 +69,12 @@ __m128i Divide(__m128i aValues, __m128i aDivisor) {
// the result is rounded.
_mm_paddd(t1, t1, ra) _mm_psrld(t1, t1, srl32) _mm_paddd(t2, t2, ra)
_mm_and(t2, t2, mask) _mm_or(p4321, t1, t2) ".set pop \n\t"
: [p4321h] "=&f"(p4321.h), [p4321l] "=&f"(p4321.l), [t1h] "=&f"(t1.h),
[t1l] "=&f"(t1.l), [t2h] "=&f"(t2.h), [t2l] "=&f"(t2.l),
[srl32] "=&f"(srl32), [tmp] "=&r"(tmp)
: [rah] "f"(ra.h), [ral] "f"(ra.l), [maskh] "f"(mask.h),
[maskl] "f"(mask.l), [avh] "f"(aValues.h), [avl] "f"(aValues.l),
[adh] "f"(aDivisor.h), [adl] "f"(aDivisor.l));
: [ p4321h ] "=&f"(p4321.h), [ p4321l ] "=&f"(p4321.l),
[ t1h ] "=&f"(t1.h), [ t1l ] "=&f"(t1.l), [ t2h ] "=&f"(t2.h),
[ t2l ] "=&f"(t2.l), [ srl32 ] "=&f"(srl32), [ tmp ] "=&r"(tmp)
: [ rah ] "f"(ra.h), [ ral ] "f"(ra.l), [ maskh ] "f"(mask.h),
[ maskl ] "f"(mask.l), [ avh ] "f"(aValues.h), [ avl ] "f"(aValues.l),
[ adh ] "f"(aDivisor.h), [ adl ] "f"(aDivisor.l));
return p4321;
}
@ -89,11 +89,11 @@ __m128i BlurFourPixels(const __m128i &aTopLeft, const __m128i &aTopRight,
".set push \n\t"
".set arch=loongson3a \n\t" _mm_psubw(val, abr, atr)
_mm_psubw(val, val, abl) _mm_paddw(val, val, atl) ".set pop \n\t"
: [valh] "=&f"(values.h), [vall] "=&f"(values.l)
: [abrh] "f"(aBottomRight.h), [abrl] "f"(aBottomRight.l),
[atrh] "f"(aTopRight.h), [atrl] "f"(aTopRight.l),
[ablh] "f"(aBottomLeft.h), [abll] "f"(aBottomLeft.l),
[atlh] "f"(aTopLeft.h), [atll] "f"(aTopLeft.l));
: [ valh ] "=&f"(values.h), [ vall ] "=&f"(values.l)
: [ abrh ] "f"(aBottomRight.h), [ abrl ] "f"(aBottomRight.l),
[ atrh ] "f"(aTopRight.h), [ atrl ] "f"(aTopRight.l),
[ ablh ] "f"(aBottomLeft.h), [ abll ] "f"(aBottomLeft.l),
[ atlh ] "f"(aTopLeft.h), [ atll ] "f"(aTopLeft.l));
return Divide(values, aDivisor);
}
@ -203,8 +203,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation,
"mtc1 %[tmp], %[see] \n\t"
"li %[tmp], 0x44 \n\t"
"mtc1 %[tmp], %[s44] \n\t" _mm_xor(zero, zero, zero) ".set pop \n\t"
: [tmp] "=&r"(tmp), [s44] "=f"(s44), [see] "=f"(see),
[zeroh] "=f"(zero.h), [zerol] "=f"(zero.l));
: [ tmp ] "=&r"(tmp), [ s44 ] "=f"(s44), [ see ] "=f"(see),
[ zeroh ] "=f"(zero.h), [ zerol ] "=f"(zero.l));
for (int y = aTopInflation + 1; y < (aSize.height + aTopInflation); y++) {
__m128i currentRowSum;
uint32_t *intRow = aIntegralImage + (y * stride32bit);
@ -215,7 +215,7 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation,
asm volatile(
".set push \n\t"
".set arch=loongson3a \n\t" _mm_xor(cr, cr, cr) ".set pop \n\t"
: [crh] "=f"(currentRowSum.h), [crl] "=f"(currentRowSum.l));
: [ crh ] "=f"(currentRowSum.h), [ crl ] "=f"(currentRowSum.l));
for (int x = 0; x < aLeftInflation; x += 4) {
__m128i sumPixels, t;
asm volatile(
@ -227,8 +227,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation,
"pshufh %[sph], %[spl], %[s44] \n\t"
"pshufh %[spl], %[spl], %[s44] \n\t"
".set pop \n\t"
: [sph] "=&f"(sumPixels.h), [spl] "=&f"(sumPixels.l)
: [pix] "r"(pixel), [s44] "f"(s44));
: [ sph ] "=&f"(sumPixels.h), [ spl ] "=&f"(sumPixels.l)
: [ pix ] "r"(pixel), [ s44 ] "f"(s44));
sumPixels = AccumulatePixelSums(sumPixels);
asm volatile (
".set push \n\t"
@ -264,10 +264,10 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation,
"punpcklwd %[spl], %[spl], %[spl] \n\t"
"mov.d %[sph], %[spl] \n\t" _mm_punpcklbh(sp, sp, zero)
_mm_punpcklhw(sp, sp, zero) ".set pop \n\t"
: [sph] "=&f"(sumPixels.h), [spl] "=&f"(sumPixels.l),
[crh] "+f"(currentRowSum.h), [crl] "+f"(currentRowSum.l)
: [pix] "r"(pixels), [see] "f"(see), [zeroh] "f"(zero.h),
[zerol] "f"(zero.l));
: [ sph ] "=&f"(sumPixels.h), [ spl ] "=&f"(sumPixels.l),
[ crh ] "+f"(currentRowSum.h), [ crl ] "+f"(currentRowSum.l)
: [ pix ] "r"(pixels), [ see ] "f"(see), [ zeroh ] "f"(zero.h),
[ zerol ] "f"(zero.l));
sumPixels = AccumulatePixelSums(sumPixels);
asm volatile (
".set push \n\t"
@ -305,8 +305,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation,
"punpcklwd %[crl], %[crl], %[crl] \n\t"
"mov.d %[crh], %[crl] \n\t"
".set pop \n\t"
: [crh] "=f"(currentRowSum.h), [crl] "=f"(currentRowSum.l)
: [cr] "r"(intCurrentRowSum));
: [ crh ] "=f"(currentRowSum.h), [ crl ] "=f"(currentRowSum.l)
: [ cr ] "r"(intCurrentRowSum));
break;
}
intCurrentRowSum += pixel;
@ -319,8 +319,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation,
"pshufh %[crl], %[crh], %[see] \n\t"
"pshufh %[crh], %[crh], %[see] \n\t"
".set pop \n\t"
: [crh] "+f"(currentRowSum.h), [crl] "+f"(currentRowSum.l)
: [see] "f"(see));
: [ crh ] "+f"(currentRowSum.h), [ crl ] "+f"(currentRowSum.l)
: [ see ] "f"(see));
}
for (; x < integralImageSize.width; x += 4) {
__m128i sumPixels, t;
@ -331,8 +331,8 @@ void GenerateIntegralImage_LS3(int32_t aLeftInflation, int32_t aRightInflation,
"punpcklwd %[spl], %[spl], %[spl] \n\t"
"mov.d %[sph], %[spl] \n\t"
".set pop \n\t"
: [sph] "=f"(sumPixels.h), [spl] "=f"(sumPixels.l)
: [pix] "r"(pixel));
: [ sph ] "=f"(sumPixels.h), [ spl ] "=f"(sumPixels.l)
: [ pix ] "r"(pixel));
sumPixels = AccumulatePixelSums(sumPixels);
asm volatile (
".set push \n\t"
@ -432,9 +432,9 @@ void AlphaBoxBlur::BoxBlur_LS3(uint8_t *aData, int32_t aLeftLobe,
"mtc1 %[rec], %[divl] \n\t"
"punpcklwd %[divl], %[divl], %[divl] \n\t"
"mov.d %[divh], %[divl] \n\t" _mm_xor(zero, zero, zero) ".set pop \n\t"
: [divh] "=f"(divisor.h), [divl] "=f"(divisor.l), [zeroh] "=f"(zero.h),
[zerol] "=f"(zero.l)
: [rec] "r"(reciprocal));
: [ divh ] "=f"(divisor.h), [ divl ] "=f"(divisor.l),
[ zeroh ] "=f"(zero.h), [ zerol ] "=f"(zero.l)
: [ rec ] "r"(reciprocal));
// This points to the start of the rectangle within the IntegralImage that
// overlaps the surface being blurred.

View File

@ -328,7 +328,9 @@ void ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest) {
readFormatGFX = SurfaceFormat::R5G6B5_UINT16;
break;
}
default: { MOZ_CRASH("GFX: Bad read format, read format."); }
default: {
MOZ_CRASH("GFX: Bad read format, read format.");
}
}
switch (readType) {
@ -347,7 +349,9 @@ void ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest) {
readAlignment = 2;
break;
}
default: { MOZ_CRASH("GFX: Bad read type, read type."); }
default: {
MOZ_CRASH("GFX: Bad read type, read type.");
}
}
int32_t stride = dest->GetSize().width * BytesPerPixel(readFormatGFX);

View File

@ -108,7 +108,9 @@ template <int LogLevel>
gfx::Log<LogLevel>& operator<<(gfx::Log<LogLevel>& log,
const ScrollableLayerGuid& aGuid) {
return log << nsPrintfCString("(0x%" PRIx64 ", %u, %" PRIu64 ")",
uint64_t(aGuid.mLayersId), aGuid.mPresShellId, aGuid.mScrollId).get();
uint64_t(aGuid.mLayersId), aGuid.mPresShellId,
aGuid.mScrollId)
.get();
}
} // namespace layers

View File

@ -185,7 +185,8 @@ template <typename Iterator, typename Node, typename PostAction>
auto ForEachNodePostOrder(Node aRoot, const PostAction& aPostAction) ->
typename EnableIf<IsSame<decltype(aPostAction(aRoot)), void>::value,
void>::Type {
ForEachNode<Iterator>(aRoot, [](Node aNode) {}, aPostAction);
ForEachNode<Iterator>(
aRoot, [](Node aNode) {}, aPostAction);
}
/*

View File

@ -740,7 +740,9 @@ static bool IsCompatibleTextureSource(TextureSource* aTexture,
return aTexture->GetFormat() == rgb.format() &&
aTexture->GetSize() == rgb.size();
}
default: { return false; }
default: {
return false;
}
}
}

View File

@ -728,7 +728,9 @@ already_AddRefed<TextureHost> CreateTextureHostD3D11(
aFlags, aDesc.get_SurfaceDescriptorDXGIYCbCr());
break;
}
default: { MOZ_ASSERT_UNREACHABLE("Unsupported SurfaceDescriptor type"); }
default: {
MOZ_ASSERT_UNREACHABLE("Unsupported SurfaceDescriptor type");
}
}
return result.forget();
}
@ -1044,7 +1046,9 @@ void DXGITextureHostD3D11::PushResourceUpdates(
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, bufferType, 1);
break;
}
default: { MOZ_ASSERT_UNREACHABLE("unexpected to be called"); }
default: {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
}
}
}
@ -1079,7 +1083,9 @@ void DXGITextureHostD3D11::PushDisplayItems(
aFilter);
break;
}
default: { MOZ_ASSERT_UNREACHABLE("unexpected to be called"); }
default: {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
}
}
}

View File

@ -230,7 +230,9 @@ bool CompositableParentManager::ReceiveCompositableUpdate(
}
break;
}
default: { MOZ_ASSERT(false, "bad type"); }
default: {
MOZ_ASSERT(false, "bad type");
}
}
return true;
@ -247,7 +249,9 @@ void CompositableParentManager::DestroyActor(const OpDestroy& aOp) {
ReleaseCompositable(aOp.get_CompositableHandle());
break;
}
default: { MOZ_ASSERT(false, "unsupported type"); }
default: {
MOZ_ASSERT(false, "unsupported type");
}
}
}

View File

@ -204,9 +204,7 @@ LayersBackend LayerManagerMLGPU::GetBackendType() {
void LayerManagerMLGPU::SetRoot(Layer* aLayer) { mRoot = aLayer; }
bool LayerManagerMLGPU::BeginTransaction(const nsCString& aURL) {
return true;
}
bool LayerManagerMLGPU::BeginTransaction(const nsCString& aURL) { return true; }
void LayerManagerMLGPU::BeginTransactionWithDrawTarget(
gfx::DrawTarget* aTarget, const gfx::IntRect& aRect) {

Some files were not shown because too many files have changed in this diff Show More