Bug 1153370 - Do MediaPromise TailDispatch checking outside the scope of the MediaPromise lock. r=jww

This reduces the potential for deadlocks.
This commit is contained in:
Bobby Holley 2015-04-10 11:58:18 -07:00
parent 3d89d1e8b9
commit 177765d6a7

View File

@ -311,8 +311,6 @@ public:
ResolveMethodType aResolveMethod, RejectMethodType aRejectMethod,
TaskDispatcher& aDispatcher = PassByRef<AutoTaskDispatcher>())
{
MutexAutoLock lock(mMutex);
// {Refable,}Then() rarely dispatch directly - they do so only in the case
// where the promise has already been resolved by the time {Refable,}Then()
// is invoked. This case is rare, but it _can_ happen, which makes it a ripe
@ -322,6 +320,7 @@ public:
// infrequently.
aDispatcher.AssertIsTailDispatcherIfRequired();
MutexAutoLock lock(mMutex);
MOZ_DIAGNOSTIC_ASSERT(!IsExclusive || !mHaveConsumer);
mHaveConsumer = true;
nsRefPtr<ThenValueBase> thenValue = new ThenValue<ThisType, ResolveMethodType, RejectMethodType>(