mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1109954 - Make resolve/reject values optional in callback signatures. r=cpearce
This commit is contained in:
parent
d60f59e183
commit
2963d4eccb
@ -2491,10 +2491,9 @@ MediaDecoderStateMachine::ShutdownReader()
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoderStateMachine::FinishShutdown(bool aSuccess)
|
||||
MediaDecoderStateMachine::FinishShutdown()
|
||||
{
|
||||
MOZ_ASSERT(OnStateMachineThread());
|
||||
MOZ_ASSERT(aSuccess);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
|
||||
// The reader's listeners hold references to the state machine,
|
||||
|
@ -163,7 +163,7 @@ public:
|
||||
void SetDormant(bool aDormant);
|
||||
void Shutdown();
|
||||
void ShutdownReader();
|
||||
void FinishShutdown(bool aSuccess);
|
||||
void FinishShutdown();
|
||||
|
||||
// Called from the main thread to get the duration. The decoder monitor
|
||||
// must be obtained before calling this. It is in units of microseconds.
|
||||
|
@ -155,6 +155,32 @@ protected:
|
||||
const char* mCallSite;
|
||||
};
|
||||
|
||||
/*
|
||||
* We create two overloads for invoking Resolve/Reject Methods so as to
|
||||
* make the resolve/reject value argument "optional".
|
||||
*/
|
||||
|
||||
// Avoid confusing the compiler when the callback accepts T* but the ValueType
|
||||
// is nsRefPtr<T>. See bug 1109954 comment 6.
|
||||
template <typename T>
|
||||
struct NonDeduced
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<typename ThisType, typename ValueType>
|
||||
static void InvokeCallbackMethod(ThisType* aThisVal, void(ThisType::*aMethod)(ValueType),
|
||||
typename NonDeduced<ValueType>::type aValue)
|
||||
{
|
||||
((*aThisVal).*aMethod)(aValue);
|
||||
}
|
||||
|
||||
template<typename ThisType, typename ValueType>
|
||||
static void InvokeCallbackMethod(ThisType* aThisVal, void(ThisType::*aMethod)(), ValueType aValue)
|
||||
{
|
||||
((*aThisVal).*aMethod)();
|
||||
}
|
||||
|
||||
template<typename TargetType, typename ThisType,
|
||||
typename ResolveMethodType, typename RejectMethodType>
|
||||
class ThenValue : public ThenValueBase
|
||||
@ -187,12 +213,12 @@ protected:
|
||||
protected:
|
||||
virtual void DoResolve(ResolveValueType aResolveValue)
|
||||
{
|
||||
((*mThisVal).*mResolveMethod)(aResolveValue);
|
||||
InvokeCallbackMethod(mThisVal.get(), mResolveMethod, aResolveValue);
|
||||
}
|
||||
|
||||
virtual void DoReject(RejectValueType aRejectValue)
|
||||
{
|
||||
((*mThisVal).*mRejectMethod)(aRejectValue);
|
||||
InvokeCallbackMethod(mThisVal.get(), mRejectMethod, aRejectValue);
|
||||
}
|
||||
|
||||
virtual ~ThenValue() {}
|
||||
|
@ -299,14 +299,13 @@ MediaSourceReader::Shutdown()
|
||||
MOZ_ASSERT(mMediaSourceShutdownPromise.IsEmpty());
|
||||
nsRefPtr<ShutdownPromise> p = mMediaSourceShutdownPromise.Ensure(__func__);
|
||||
|
||||
ContinueShutdown(true);
|
||||
ContinueShutdown();
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
MediaSourceReader::ContinueShutdown(bool aSuccess)
|
||||
MediaSourceReader::ContinueShutdown()
|
||||
{
|
||||
MOZ_ASSERT(aSuccess);
|
||||
if (mTrackBuffers.Length()) {
|
||||
mTrackBuffers[0]->Shutdown()->Then(GetTaskQueue(), __func__, this,
|
||||
&MediaSourceReader::ContinueShutdown,
|
||||
|
@ -180,7 +180,7 @@ private:
|
||||
|
||||
bool mHasEssentialTrackBuffers;
|
||||
|
||||
void ContinueShutdown(bool aSuccess);
|
||||
void ContinueShutdown();
|
||||
MediaPromiseHolder<ShutdownPromise> mMediaSourceShutdownPromise;
|
||||
#ifdef MOZ_FMP4
|
||||
nsRefPtr<SharedDecoderManager> mSharedDecoderManager;
|
||||
|
@ -112,9 +112,8 @@ TrackBuffer::Shutdown()
|
||||
}
|
||||
|
||||
void
|
||||
TrackBuffer::ContinueShutdown(bool aSuccess)
|
||||
TrackBuffer::ContinueShutdown()
|
||||
{
|
||||
MOZ_ASSERT(aSuccess);
|
||||
ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
|
||||
if (mDecoders.Length()) {
|
||||
mDecoders[0]->GetReader()->Shutdown()
|
||||
|
@ -160,7 +160,7 @@ private:
|
||||
// Protected by mParentDecoder's monitor.
|
||||
MediaInfo mInfo;
|
||||
|
||||
void ContinueShutdown(bool aSuccess);
|
||||
void ContinueShutdown();
|
||||
MediaPromiseHolder<ShutdownPromise> mShutdownPromise;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user