Bug 1336510 - Part 4: Capture a strong reference to this in dom/media, r=jwwang

MozReview-Commit-ID: 4lVGrGzhVXh
This commit is contained in:
Michael Layzell 2017-02-03 16:57:49 -05:00
Родитель f225a42d33
Коммит 1d0870e2e1
8 изменённых файлов: 87 добавлений и 67 удалений

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

@ -1813,13 +1813,14 @@ MediaDecoder::DumpDebugInfo()
return; return;
} }
RefPtr<MediaDecoder> self = this;
GetStateMachine()->RequestDebugInfo()->Then( GetStateMachine()->RequestDebugInfo()->Then(
AbstractThread::MainThread(), __func__, AbstractThread::MainThread(), __func__,
[this, str] (const nsACString& aString) { [this, self, str] (const nsACString& aString) {
DUMP_LOG("%s", str.get()); DUMP_LOG("%s", str.get());
DUMP_LOG("%s", aString.Data()); DUMP_LOG("%s", aString.Data());
}, },
[this, str] () { [this, self, str] () {
DUMP_LOG("%s", str.get()); DUMP_LOG("%s", str.get());
}); });
} }

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

@ -2821,9 +2821,10 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder)
mMetadataManager.Connect(mReader->TimedMetadataEvent(), OwnerThread()); mMetadataManager.Connect(mReader->TimedMetadataEvent(), OwnerThread());
RefPtr<MediaDecoderStateMachine> self = this;
mOnMediaNotSeekable = mReader->OnMediaNotSeekable().Connect( mOnMediaNotSeekable = mReader->OnMediaNotSeekable().Connect(
OwnerThread(), [this] () { OwnerThread(), [self] () {
mMediaSeekable = false; self->mMediaSeekable = false;
}); });
mMediaSink = CreateMediaSink(mAudioCaptured); mMediaSink = CreateMediaSink(mAudioCaptured);
@ -2837,7 +2838,6 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder)
nsresult rv = mReader->Init(); nsresult rv = mReader->Init();
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
RefPtr<MediaDecoderStateMachine> self = this;
OwnerThread()->Dispatch(NS_NewRunnableFunction([self] () { OwnerThread()->Dispatch(NS_NewRunnableFunction([self] () {
MOZ_ASSERT(!self->mStateObj); MOZ_ASSERT(!self->mStateObj);
auto s = new DecodeMetadataState(self); auto s = new DecodeMetadataState(self);
@ -3112,9 +3112,10 @@ MediaDecoderStateMachine::RequestAudioData()
SAMPLE_LOG("Queueing audio task - queued=%" PRIuSIZE ", decoder-queued=%" PRIuSIZE, SAMPLE_LOG("Queueing audio task - queued=%" PRIuSIZE ", decoder-queued=%" PRIuSIZE,
AudioQueue().GetSize(), mReader->SizeOfAudioQueueInFrames()); AudioQueue().GetSize(), mReader->SizeOfAudioQueueInFrames());
RefPtr<MediaDecoderStateMachine> self = this;
mReader->RequestAudioData()->Then( mReader->RequestAudioData()->Then(
OwnerThread(), __func__, OwnerThread(), __func__,
[this] (MediaData* aAudio) { [this, self] (MediaData* aAudio) {
MOZ_ASSERT(aAudio); MOZ_ASSERT(aAudio);
mAudioDataRequest.Complete(); mAudioDataRequest.Complete();
// audio->GetEndTime() is not always mono-increasing in chained ogg. // audio->GetEndTime() is not always mono-increasing in chained ogg.
@ -3124,7 +3125,7 @@ MediaDecoderStateMachine::RequestAudioData()
aAudio->GetEndTime()); aAudio->GetEndTime());
mStateObj->HandleAudioDecoded(aAudio); mStateObj->HandleAudioDecoded(aAudio);
}, },
[this] (const MediaResult& aError) { [this, self] (const MediaResult& aError) {
SAMPLE_LOG("OnAudioNotDecoded aError=%" PRIu32, static_cast<uint32_t>(aError.Code())); SAMPLE_LOG("OnAudioNotDecoded aError=%" PRIu32, static_cast<uint32_t>(aError.Code()));
mAudioDataRequest.Complete(); mAudioDataRequest.Complete();
switch (aError.Code()) { switch (aError.Code()) {
@ -3158,9 +3159,10 @@ MediaDecoderStateMachine::RequestVideoData(bool aSkipToNextKeyframe,
aSkipToNextKeyframe, aCurrentTime.ToMicroseconds()); aSkipToNextKeyframe, aCurrentTime.ToMicroseconds());
TimeStamp videoDecodeStartTime = TimeStamp::Now(); TimeStamp videoDecodeStartTime = TimeStamp::Now();
RefPtr<MediaDecoderStateMachine> self = this;
mReader->RequestVideoData(aSkipToNextKeyframe, aCurrentTime)->Then( mReader->RequestVideoData(aSkipToNextKeyframe, aCurrentTime)->Then(
OwnerThread(), __func__, OwnerThread(), __func__,
[this, videoDecodeStartTime] (MediaData* aVideo) { [this, self, videoDecodeStartTime] (MediaData* aVideo) {
MOZ_ASSERT(aVideo); MOZ_ASSERT(aVideo);
mVideoDataRequest.Complete(); mVideoDataRequest.Complete();
// Handle abnormal or negative timestamps. // Handle abnormal or negative timestamps.
@ -3170,7 +3172,7 @@ MediaDecoderStateMachine::RequestVideoData(bool aSkipToNextKeyframe,
aVideo->GetEndTime()); aVideo->GetEndTime());
mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime); mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime);
}, },
[this] (const MediaResult& aError) { [this, self] (const MediaResult& aError) {
SAMPLE_LOG("OnVideoNotDecoded aError=%" PRIu32 , static_cast<uint32_t>(aError.Code())); SAMPLE_LOG("OnVideoNotDecoded aError=%" PRIu32 , static_cast<uint32_t>(aError.Code()));
mVideoDataRequest.Complete(); mVideoDataRequest.Complete();
switch (aError.Code()) { switch (aError.Code()) {
@ -3194,29 +3196,30 @@ MediaDecoderStateMachine::WaitForData(MediaData::Type aType)
{ {
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(aType == MediaData::AUDIO_DATA || aType == MediaData::VIDEO_DATA); MOZ_ASSERT(aType == MediaData::AUDIO_DATA || aType == MediaData::VIDEO_DATA);
RefPtr<MediaDecoderStateMachine> self = this;
if (aType == MediaData::AUDIO_DATA) { if (aType == MediaData::AUDIO_DATA) {
mReader->WaitForData(MediaData::AUDIO_DATA)->Then( mReader->WaitForData(MediaData::AUDIO_DATA)->Then(
OwnerThread(), __func__, OwnerThread(), __func__,
[this] (MediaData::Type aType) { [self] (MediaData::Type aType) {
mAudioWaitRequest.Complete(); self->mAudioWaitRequest.Complete();
MOZ_ASSERT(aType == MediaData::AUDIO_DATA); MOZ_ASSERT(aType == MediaData::AUDIO_DATA);
mStateObj->HandleAudioWaited(aType); self->mStateObj->HandleAudioWaited(aType);
}, },
[this] (const WaitForDataRejectValue& aRejection) { [self] (const WaitForDataRejectValue& aRejection) {
mAudioWaitRequest.Complete(); self->mAudioWaitRequest.Complete();
DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA); self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
})->Track(mAudioWaitRequest); })->Track(mAudioWaitRequest);
} else { } else {
mReader->WaitForData(MediaData::VIDEO_DATA)->Then( mReader->WaitForData(MediaData::VIDEO_DATA)->Then(
OwnerThread(), __func__, OwnerThread(), __func__,
[this] (MediaData::Type aType) { [self] (MediaData::Type aType) {
mVideoWaitRequest.Complete(); self->mVideoWaitRequest.Complete();
MOZ_ASSERT(aType == MediaData::VIDEO_DATA); MOZ_ASSERT(aType == MediaData::VIDEO_DATA);
mStateObj->HandleVideoWaited(aType); self->mStateObj->HandleVideoWaited(aType);
}, },
[this] (const WaitForDataRejectValue& aRejection) { [self] (const WaitForDataRejectValue& aRejection) {
mVideoWaitRequest.Complete(); self->mVideoWaitRequest.Complete();
DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA); self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
})->Track(mVideoWaitRequest); })->Track(mVideoWaitRequest);
} }
} }
@ -3577,9 +3580,10 @@ MediaDecoderStateMachine::ScheduleStateMachineIn(int64_t aMicroseconds)
// It is OK to capture 'this' without causing UAF because the callback // It is OK to capture 'this' without causing UAF because the callback
// always happens before shutdown. // always happens before shutdown.
mDelayedScheduler.Ensure(target, [this] () { RefPtr<MediaDecoderStateMachine> self = this;
mDelayedScheduler.CompleteRequest(); mDelayedScheduler.Ensure(target, [self] () {
RunStateMachine(); self->mDelayedScheduler.CompleteRequest();
self->RunStateMachine();
}, [] () { }, [] () {
MOZ_DIAGNOSTIC_ASSERT(false); MOZ_DIAGNOSTIC_ASSERT(false);
}); });
@ -3796,8 +3800,9 @@ MediaDecoderStateMachine::RequestDebugInfo()
{ {
using PromiseType = MediaDecoder::DebugInfoPromise; using PromiseType = MediaDecoder::DebugInfoPromise;
RefPtr<PromiseType::Private> p = new PromiseType::Private(__func__); RefPtr<PromiseType::Private> p = new PromiseType::Private(__func__);
OwnerThread()->Dispatch(NS_NewRunnableFunction([this, p] () { RefPtr<MediaDecoderStateMachine> self = this;
p->Resolve(GetDebugInfo(), __func__); OwnerThread()->Dispatch(NS_NewRunnableFunction([self, p] () {
p->Resolve(self->GetDebugInfo(), __func__);
}), AbstractThread::AssertDispatchSuccess, AbstractThread::TailDispatch); }), AbstractThread::AssertDispatchSuccess, AbstractThread::TailDispatch);
return p.forget(); return p.forget();
} }

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

@ -2295,23 +2295,23 @@ if (privileged) {
RefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowID, videoType, RefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowID, videoType,
audioType, fake); audioType, fake);
p->Then([this, onSuccess, onFailure, windowID, c, listener, askPermission, RefPtr<MediaManager> self = this;
p->Then([self, onSuccess, onFailure, windowID, c, listener, askPermission,
prefs, isHTTPS, callID, principalInfo, prefs, isHTTPS, callID, principalInfo,
isChrome](SourceSet*& aDevices) mutable { isChrome](SourceSet*& aDevices) mutable {
RefPtr<Refcountable<UniquePtr<SourceSet>>> devices( RefPtr<Refcountable<UniquePtr<SourceSet>>> devices(
new Refcountable<UniquePtr<SourceSet>>(aDevices)); // grab result new Refcountable<UniquePtr<SourceSet>>(aDevices)); // grab result
// Ensure that the captured 'this' pointer and our windowID are still good. // Ensure that our windowID is still good.
if (!MediaManager::Exists() || if (!nsGlobalWindow::GetInnerWindowWithId(windowID)) {
!nsGlobalWindow::GetInnerWindowWithId(windowID)) {
return; return;
} }
// Apply any constraints. This modifies the passed-in list. // Apply any constraints. This modifies the passed-in list.
RefPtr<PledgeChar> p2 = SelectSettings(c, isChrome, devices); RefPtr<PledgeChar> p2 = self->SelectSettings(c, isChrome, devices);
p2->Then([this, onSuccess, onFailure, windowID, c, p2->Then([self, onSuccess, onFailure, windowID, c,
listener, askPermission, prefs, isHTTPS, callID, principalInfo, listener, askPermission, prefs, isHTTPS, callID, principalInfo,
isChrome, devices](const char*& badConstraint) mutable { isChrome, devices](const char*& badConstraint) mutable {
@ -2359,13 +2359,13 @@ if (privileged) {
isChrome, isChrome,
devices->release())); devices->release()));
// Store the task w/callbacks. // Store the task w/callbacks.
mActiveCallbacks.Put(callID, task.forget()); self->mActiveCallbacks.Put(callID, task.forget());
// Add a WindowID cross-reference so OnNavigation can tear things down // Add a WindowID cross-reference so OnNavigation can tear things down
nsTArray<nsString>* array; nsTArray<nsString>* array;
if (!mCallIds.Get(windowID, &array)) { if (!self->mCallIds.Get(windowID, &array)) {
array = new nsTArray<nsString>(); array = new nsTArray<nsString>();
mCallIds.Put(windowID, array); self->mCallIds.Put(windowID, array);
} }
array->AppendElement(callID); array->AppendElement(callID);
@ -3002,7 +3002,9 @@ MediaManager::Shutdown()
// cleared until the lambda function clears it. // cleared until the lambda function clears it.
// note that this == sSingleton // note that this == sSingleton
RefPtr<MediaManager> that(sSingleton); MOZ_ASSERT(this == sSingleton);
RefPtr<MediaManager> that = this;
// Release the backend (and call Shutdown()) from within the MediaManager thread // Release the backend (and call Shutdown()) from within the MediaManager thread
// Don't use MediaManager::PostTask() because we're sInShutdown=true here! // Don't use MediaManager::PostTask() because we're sInShutdown=true here!
RefPtr<ShutdownTask> shutdown = new ShutdownTask(this, RefPtr<ShutdownTask> shutdown = new ShutdownTask(this,

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

@ -70,9 +70,10 @@ public:
void Forget() void Forget()
{ {
mAbstractMainThread->Dispatch(NS_NewRunnableFunction([this] () { RefPtr<DecodedStreamGraphListener> self = this;
mAbstractMainThread->Dispatch(NS_NewRunnableFunction([self] () {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
mFinishPromise.ResolveIfExists(true, __func__); self->mFinishPromise.ResolveIfExists(true, __func__);
})); }));
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
mStream = nullptr; mStream = nullptr;

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

@ -128,7 +128,8 @@ OggDemuxer::~OggDemuxer()
// If we were able to initialize our decoders, report whether we encountered // If we were able to initialize our decoders, report whether we encountered
// a chained stream or not. // a chained stream or not.
bool isChained = mIsChained; bool isChained = mIsChained;
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([=]() -> void { RefPtr<OggDemuxer> self = this;
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([this, self, isChained]() -> void {
OGG_DEBUG("Reporting telemetry MEDIA_OGG_LOADED_IS_CHAINED=%d", isChained); OGG_DEBUG("Reporting telemetry MEDIA_OGG_LOADED_IS_CHAINED=%d", isChained);
Telemetry::Accumulate(Telemetry::HistogramID::MEDIA_OGG_LOADED_IS_CHAINED, isChained); Telemetry::Accumulate(Telemetry::HistogramID::MEDIA_OGG_LOADED_IS_CHAINED, isChained);
}); });

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

@ -284,9 +284,10 @@ CamerasChild::NumberOfCapabilities(CaptureEngine aCapEngine,
LOG((__PRETTY_FUNCTION__)); LOG((__PRETTY_FUNCTION__));
LOG(("NumberOfCapabilities for %s", deviceUniqueIdUTF8)); LOG(("NumberOfCapabilities for %s", deviceUniqueIdUTF8));
nsCString unique_id(deviceUniqueIdUTF8); nsCString unique_id(deviceUniqueIdUTF8);
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine, unique_id]() -> nsresult { media::NewRunnableFrom([self, aCapEngine, unique_id]() -> nsresult {
if (this->SendNumberOfCapabilities(aCapEngine, unique_id)) { if (self->SendNumberOfCapabilities(aCapEngine, unique_id)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -300,9 +301,10 @@ int
CamerasChild::NumberOfCaptureDevices(CaptureEngine aCapEngine) CamerasChild::NumberOfCaptureDevices(CaptureEngine aCapEngine)
{ {
LOG((__PRETTY_FUNCTION__)); LOG((__PRETTY_FUNCTION__));
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine]() -> nsresult { media::NewRunnableFrom([self, aCapEngine]() -> nsresult {
if (this->SendNumberOfCaptureDevices(aCapEngine)) { if (self->SendNumberOfCaptureDevices(aCapEngine)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -328,9 +330,10 @@ int
CamerasChild::EnsureInitialized(CaptureEngine aCapEngine) CamerasChild::EnsureInitialized(CaptureEngine aCapEngine)
{ {
LOG((__PRETTY_FUNCTION__)); LOG((__PRETTY_FUNCTION__));
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine]() -> nsresult { media::NewRunnableFrom([self, aCapEngine]() -> nsresult {
if (this->SendEnsureInitialized(aCapEngine)) { if (self->SendEnsureInitialized(aCapEngine)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -348,9 +351,10 @@ CamerasChild::GetCaptureCapability(CaptureEngine aCapEngine,
{ {
LOG(("GetCaptureCapability: %s %d", unique_idUTF8, capability_number)); LOG(("GetCaptureCapability: %s %d", unique_idUTF8, capability_number));
nsCString unique_id(unique_idUTF8); nsCString unique_id(unique_idUTF8);
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine, unique_id, capability_number]() -> nsresult { media::NewRunnableFrom([self, aCapEngine, unique_id, capability_number]() -> nsresult {
if (this->SendGetCaptureCapability(aCapEngine, unique_id, capability_number)) { if (self->SendGetCaptureCapability(aCapEngine, unique_id, capability_number)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -389,9 +393,10 @@ CamerasChild::GetCaptureDevice(CaptureEngine aCapEngine,
bool* scary) bool* scary)
{ {
LOG((__PRETTY_FUNCTION__)); LOG((__PRETTY_FUNCTION__));
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine, list_number]() -> nsresult { media::NewRunnableFrom([self, aCapEngine, list_number]() -> nsresult {
if (this->SendGetCaptureDevice(aCapEngine, list_number)) { if (self->SendGetCaptureDevice(aCapEngine, list_number)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -433,9 +438,10 @@ CamerasChild::AllocateCaptureDevice(CaptureEngine aCapEngine,
{ {
LOG((__PRETTY_FUNCTION__)); LOG((__PRETTY_FUNCTION__));
nsCString unique_id(unique_idUTF8); nsCString unique_id(unique_idUTF8);
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine, unique_id, aPrincipalInfo]() -> nsresult { media::NewRunnableFrom([self, aCapEngine, unique_id, aPrincipalInfo]() -> nsresult {
if (this->SendAllocateCaptureDevice(aCapEngine, unique_id, aPrincipalInfo)) { if (self->SendAllocateCaptureDevice(aCapEngine, unique_id, aPrincipalInfo)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -466,9 +472,10 @@ CamerasChild::ReleaseCaptureDevice(CaptureEngine aCapEngine,
const int capture_id) const int capture_id)
{ {
LOG((__PRETTY_FUNCTION__)); LOG((__PRETTY_FUNCTION__));
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine, capture_id]() -> nsresult { media::NewRunnableFrom([self, aCapEngine, capture_id]() -> nsresult {
if (this->SendReleaseCaptureDevice(aCapEngine, capture_id)) { if (self->SendReleaseCaptureDevice(aCapEngine, capture_id)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -517,9 +524,10 @@ CamerasChild::StartCapture(CaptureEngine aCapEngine,
webrtcCaps.rawType, webrtcCaps.rawType,
webrtcCaps.codecType, webrtcCaps.codecType,
webrtcCaps.interlaced); webrtcCaps.interlaced);
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine, capture_id, capCap]() -> nsresult { media::NewRunnableFrom([self, aCapEngine, capture_id, capCap]() -> nsresult {
if (this->SendStartCapture(aCapEngine, capture_id, capCap)) { if (self->SendStartCapture(aCapEngine, capture_id, capCap)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -532,9 +540,10 @@ int
CamerasChild::StopCapture(CaptureEngine aCapEngine, const int capture_id) CamerasChild::StopCapture(CaptureEngine aCapEngine, const int capture_id)
{ {
LOG((__PRETTY_FUNCTION__)); LOG((__PRETTY_FUNCTION__));
RefPtr<CamerasChild> self = this;
nsCOMPtr<nsIRunnable> runnable = nsCOMPtr<nsIRunnable> runnable =
media::NewRunnableFrom([this, aCapEngine, capture_id]() -> nsresult { media::NewRunnableFrom([self, aCapEngine, capture_id]() -> nsresult {
if (this->SendStopCapture(aCapEngine, capture_id)) { if (self->SendStopCapture(aCapEngine, capture_id)) {
return NS_OK; return NS_OK;
} }
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -599,11 +608,12 @@ CamerasChild::ShutdownParent()
if (CamerasSingleton::Thread()) { if (CamerasSingleton::Thread()) {
LOG(("Dispatching actor deletion")); LOG(("Dispatching actor deletion"));
// Delete the parent actor. // Delete the parent actor.
RefPtr<CamerasChild> self = this;
RefPtr<Runnable> deleteRunnable = RefPtr<Runnable> deleteRunnable =
// CamerasChild (this) will remain alive and is only deleted by the // CamerasChild (this) will remain alive and is only deleted by the
// IPC layer when SendAllDone returns. // IPC layer when SendAllDone returns.
media::NewRunnableFrom([this]() -> nsresult { media::NewRunnableFrom([self]() -> nsresult {
Unused << this->SendAllDone(); Unused << self->SendAllDone();
return NS_OK; return NS_OK;
}); });
CamerasSingleton::Thread()->Dispatch(deleteRunnable, NS_DISPATCH_NORMAL); CamerasSingleton::Thread()->Dispatch(deleteRunnable, NS_DISPATCH_NORMAL);

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

@ -316,10 +316,10 @@ MediaEngineRemoteVideoSource::SetLastCapability(
webrtc::CaptureCapability cap = aCapability; webrtc::CaptureCapability cap = aCapability;
RefPtr<MediaEngineRemoteVideoSource> that = this; RefPtr<MediaEngineRemoteVideoSource> that = this;
NS_DispatchToMainThread(media::NewRunnableFrom([this, that, cap]() mutable { NS_DispatchToMainThread(media::NewRunnableFrom([that, cap]() mutable {
mSettings.mWidth.Value() = cap.width; that->mSettings.mWidth.Value() = cap.width;
mSettings.mHeight.Value() = cap.height; that->mSettings.mHeight.Value() = cap.height;
mSettings.mFrameRate.Value() = cap.maxFPS; that->mSettings.mFrameRate.Value() = cap.maxFPS;
return NS_OK; return NS_OK;
})); }));
} }

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

@ -373,10 +373,10 @@ MediaEngineWebRTCMicrophoneSource::SetLastPrefs(
RefPtr<MediaEngineWebRTCMicrophoneSource> that = this; RefPtr<MediaEngineWebRTCMicrophoneSource> that = this;
NS_DispatchToMainThread(media::NewRunnableFrom([this, that, aPrefs]() mutable { NS_DispatchToMainThread(media::NewRunnableFrom([that, aPrefs]() mutable {
mSettings.mEchoCancellation.Value() = aPrefs.mAecOn; that->mSettings.mEchoCancellation.Value() = aPrefs.mAecOn;
mSettings.mMozAutoGainControl.Value() = aPrefs.mAgcOn; that->mSettings.mMozAutoGainControl.Value() = aPrefs.mAgcOn;
mSettings.mMozNoiseSuppression.Value() = aPrefs.mNoiseOn; that->mSettings.mMozNoiseSuppression.Value() = aPrefs.mNoiseOn;
return NS_OK; return NS_OK;
})); }));
} }