Bug 1686696 - part5 : remove nsSyncSection. r=bryce

`nsSyncSection` is not related with media event, so that's not proper ot put it in `MediaElementEventRunners.h`.

In addition, that can simply be implemented by `NS_NewRunnableFunction` so we don't need `nsSyncSection` anymore.

Differential Revision: https://phabricator.services.mozilla.com/D104115
This commit is contained in:
alwu
2021-02-11 03:45:30 +00:00
parent ab645e5e61
commit ed129ef725
3 changed files with 13 additions and 29 deletions

View File

@@ -2295,15 +2295,24 @@ void HTMLMediaElement::NoSupportedMediaSourceError(
NS_ERROR_DOM_MEDIA_NOT_SUPPORTED_ERR);
}
typedef void (HTMLMediaElement::*SyncSectionFn)();
// Runs a "synchronous section", a function that must run once the event loop
// has reached a "stable state"
// http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#synchronous-section
void HTMLMediaElement::RunInStableState(nsIRunnable* aRunnable) {
if (mShuttingDown) {
return;
}
nsCOMPtr<nsIRunnable> event = new nsSyncSection(this, aRunnable);
nsContentUtils::RunInStableState(event.forget());
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction(
"HTMLMediaElement::RunInStableState",
[self = RefPtr<HTMLMediaElement>(this), loadId = GetCurrentLoadID(),
runnable = RefPtr<nsIRunnable>(aRunnable)]() {
if (self->GetCurrentLoadID() != loadId) {
return;
}
runnable->Run();
});
nsContentUtils::RunInStableState(task.forget());
}
void HTMLMediaElement::QueueLoadFromSourceTask() {