Bug 1661668 - Capture `this` in HTMLMediaElement::SetSinkId captures, for readability. r=padenot

Depends on D88820

Differential Revision: https://phabricator.services.mozilla.com/D88821
This commit is contained in:
Andreas Pehrson 2020-08-31 15:34:09 +00:00
Родитель 408f7e4600
Коммит 222394b14b
1 изменённых файлов: 11 добавлений и 11 удалений

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

@ -7740,13 +7740,13 @@ already_AddRefed<Promise> HTMLMediaElement::SetSinkId(const nsAString& aSinkId,
->GetSinkDevice(win, sinkId) ->GetSinkDevice(win, sinkId)
->Then( ->Then(
mAbstractMainThread, __func__, mAbstractMainThread, __func__,
[self = RefPtr<HTMLMediaElement>(this)]( [self = RefPtr<HTMLMediaElement>(this),
RefPtr<AudioDeviceInfo>&& aInfo) { this](RefPtr<AudioDeviceInfo>&& aInfo) {
// Sink found switch output device. // Sink found switch output device.
MOZ_ASSERT(aInfo); MOZ_ASSERT(aInfo);
if (self->mDecoder) { if (mDecoder) {
RefPtr<SinkInfoPromise> p = self->mDecoder->SetSink(aInfo)->Then( RefPtr<SinkInfoPromise> p = mDecoder->SetSink(aInfo)->Then(
self->mAbstractMainThread, __func__, mAbstractMainThread, __func__,
[aInfo](const GenericPromise::ResolveOrRejectValue& aValue) { [aInfo](const GenericPromise::ResolveOrRejectValue& aValue) {
if (aValue.IsResolve()) { if (aValue.IsResolve()) {
return SinkInfoPromise::CreateAndResolve(aInfo, __func__); return SinkInfoPromise::CreateAndResolve(aInfo, __func__);
@ -7756,11 +7756,11 @@ already_AddRefed<Promise> HTMLMediaElement::SetSinkId(const nsAString& aSinkId,
}); });
return p; return p;
} }
if (self->mSrcStream) { if (mSrcStream) {
MOZ_ASSERT(self->mMediaStreamRenderer); MOZ_ASSERT(mMediaStreamRenderer);
RefPtr<SinkInfoPromise> p = RefPtr<SinkInfoPromise> p =
self->mMediaStreamRenderer->SetAudioOutputDevice(aInfo)->Then( mMediaStreamRenderer->SetAudioOutputDevice(aInfo)->Then(
self->mAbstractMainThread, __func__, mAbstractMainThread, __func__,
[aInfo](const GenericPromise::AllPromiseType:: [aInfo](const GenericPromise::AllPromiseType::
ResolveOrRejectValue& aValue) { ResolveOrRejectValue& aValue) {
if (aValue.IsResolve()) { if (aValue.IsResolve()) {
@ -7780,10 +7780,10 @@ already_AddRefed<Promise> HTMLMediaElement::SetSinkId(const nsAString& aSinkId,
return SinkInfoPromise::CreateAndReject(res, __func__); return SinkInfoPromise::CreateAndReject(res, __func__);
}) })
->Then(mAbstractMainThread, __func__, ->Then(mAbstractMainThread, __func__,
[promise, self = RefPtr<HTMLMediaElement>(this), [promise, self = RefPtr<HTMLMediaElement>(this), this,
sinkId](const SinkInfoPromise::ResolveOrRejectValue& aValue) { sinkId](const SinkInfoPromise::ResolveOrRejectValue& aValue) {
if (aValue.IsResolve()) { if (aValue.IsResolve()) {
self->mSink = std::pair(sinkId, aValue.ResolveValue()); mSink = std::pair(sinkId, aValue.ResolveValue());
promise->MaybeResolveWithUndefined(); promise->MaybeResolveWithUndefined();
} else { } else {
switch (aValue.RejectValue()) { switch (aValue.RejectValue()) {