Bug 1184634 - Rename MediaPromise to MozPromise. r=gerald

This commit is contained in:
Bobby Holley 2015-07-16 11:06:49 -07:00
Родитель 74f03750da
Коммит 407d2c5f90
29 изменённых файлов: 184 добавлений и 184 удалений

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

@ -9,7 +9,7 @@
#include "MediaData.h" #include "MediaData.h"
#include "MediaInfo.h" #include "MediaInfo.h"
#include "MediaPromise.h" #include "MozPromise.h"
#include "TimeUnits.h" #include "TimeUnits.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
@ -40,7 +40,7 @@ class MediaDataDemuxer
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDataDemuxer) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDataDemuxer)
typedef MediaPromise<nsresult, DemuxerFailureReason, /* IsExclusive = */ true> InitPromise; typedef MozPromise<nsresult, DemuxerFailureReason, /* IsExclusive = */ true> InitPromise;
// Initializes the demuxer. Other methods cannot be called unless // Initializes the demuxer. Other methods cannot be called unless
// initialization has completed and succeeded. // initialization has completed and succeeded.
@ -133,9 +133,9 @@ public:
uint32_t mSkipped; uint32_t mSkipped;
}; };
typedef MediaPromise<media::TimeUnit, DemuxerFailureReason, /* IsExclusive = */ true> SeekPromise; typedef MozPromise<media::TimeUnit, DemuxerFailureReason, /* IsExclusive = */ true> SeekPromise;
typedef MediaPromise<nsRefPtr<SamplesHolder>, DemuxerFailureReason, /* IsExclusive = */ true> SamplesPromise; typedef MozPromise<nsRefPtr<SamplesHolder>, DemuxerFailureReason, /* IsExclusive = */ true> SamplesPromise;
typedef MediaPromise<uint32_t, SkipFailureHolder, /* IsExclusive = */ true> SkipAccessPointPromise; typedef MozPromise<uint32_t, SkipFailureHolder, /* IsExclusive = */ true> SkipAccessPointPromise;
// Returns the TrackInfo (a.k.a Track Description) for this track. // Returns the TrackInfo (a.k.a Track Description) for this track.
// The TrackInfo returned will be: // The TrackInfo returned will be:

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

@ -121,7 +121,7 @@ public:
StaticRefPtr<MediaMemoryTracker> MediaMemoryTracker::sUniqueInstance; StaticRefPtr<MediaMemoryTracker> MediaMemoryTracker::sUniqueInstance;
PRLogModuleInfo* gStateWatchingLog; PRLogModuleInfo* gStateWatchingLog;
PRLogModuleInfo* gMediaPromiseLog; PRLogModuleInfo* gMozPromiseLog;
PRLogModuleInfo* gMediaTimerLog; PRLogModuleInfo* gMediaTimerLog;
PRLogModuleInfo* gMediaSampleLog; PRLogModuleInfo* gMediaSampleLog;
@ -134,7 +134,7 @@ MediaDecoder::InitStatics()
// Log modules. // Log modules.
gMediaDecoderLog = PR_NewLogModule("MediaDecoder"); gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
gMediaPromiseLog = PR_NewLogModule("MediaPromise"); gMozPromiseLog = PR_NewLogModule("MozPromise");
gStateWatchingLog = PR_NewLogModule("StateWatching"); gStateWatchingLog = PR_NewLogModule("StateWatching");
gMediaTimerLog = PR_NewLogModule("MediaTimer"); gMediaTimerLog = PR_NewLogModule("MediaTimer");
gMediaSampleLog = PR_NewLogModule("MediaSample"); gMediaSampleLog = PR_NewLogModule("MediaSample");

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

@ -189,7 +189,7 @@ destroying the MediaDecoder object.
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsITimer.h" #include "nsITimer.h"
#include "MediaPromise.h" #include "MozPromise.h"
#include "MediaResource.h" #include "MediaResource.h"
#include "mozilla/dom/AudioChannelBinding.h" #include "mozilla/dom/AudioChannelBinding.h"
#include "mozilla/ReentrantMonitor.h" #include "mozilla/ReentrantMonitor.h"
@ -274,7 +274,7 @@ public:
MediaDecoderEventVisibility mEventVisibility; MediaDecoderEventVisibility mEventVisibility;
}; };
typedef MediaPromise<SeekResolveValue, bool /* aIgnored */, /* IsExclusive = */ true> SeekPromise; typedef MozPromise<SeekResolveValue, bool /* aIgnored */, /* IsExclusive = */ true> SeekPromise;
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
@ -986,7 +986,7 @@ protected:
// Returns true if heuristic dormant is supported. // Returns true if heuristic dormant is supported.
bool IsHeuristicDormantSupported() const; bool IsHeuristicDormantSupported() const;
MediaPromiseRequestHolder<SeekPromise> mSeekRequest; MozPromiseRequestHolder<SeekPromise> mSeekRequest;
// True when seeking or otherwise moving the play position around in // True when seeking or otherwise moving the play position around in
// such a manner that progress event data is inaccurate. This is set // such a manner that progress event data is inaccurate. This is set

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

@ -9,7 +9,7 @@
#include "AbstractMediaDecoder.h" #include "AbstractMediaDecoder.h"
#include "MediaInfo.h" #include "MediaInfo.h"
#include "MediaData.h" #include "MediaData.h"
#include "MediaPromise.h" #include "MozPromise.h"
#include "MediaQueue.h" #include "MediaQueue.h"
#include "MediaTimer.h" #include "MediaTimer.h"
#include "AudioCompactor.h" #include "AudioCompactor.h"
@ -66,16 +66,16 @@ public:
CANCELED CANCELED
}; };
typedef MediaPromise<nsRefPtr<MetadataHolder>, ReadMetadataFailureReason, /* IsExclusive = */ true> MetadataPromise; typedef MozPromise<nsRefPtr<MetadataHolder>, ReadMetadataFailureReason, /* IsExclusive = */ true> MetadataPromise;
typedef MediaPromise<nsRefPtr<AudioData>, NotDecodedReason, /* IsExclusive = */ true> AudioDataPromise; typedef MozPromise<nsRefPtr<AudioData>, NotDecodedReason, /* IsExclusive = */ true> AudioDataPromise;
typedef MediaPromise<nsRefPtr<VideoData>, NotDecodedReason, /* IsExclusive = */ true> VideoDataPromise; typedef MozPromise<nsRefPtr<VideoData>, NotDecodedReason, /* IsExclusive = */ true> VideoDataPromise;
typedef MediaPromise<int64_t, nsresult, /* IsExclusive = */ true> SeekPromise; typedef MozPromise<int64_t, nsresult, /* IsExclusive = */ true> SeekPromise;
// Note that, conceptually, WaitForData makes sense in a non-exclusive sense. // Note that, conceptually, WaitForData makes sense in a non-exclusive sense.
// But in the current architecture it's only ever used exclusively (by MDSM), // But in the current architecture it's only ever used exclusively (by MDSM),
// so we mark it that way to verify our assumptions. If you have a use-case // so we mark it that way to verify our assumptions. If you have a use-case
// for multiple WaitForData consumers, feel free to flip the exclusivity here. // for multiple WaitForData consumers, feel free to flip the exclusivity here.
typedef MediaPromise<MediaData::Type, WaitForDataRejectValue, /* IsExclusive = */ true> WaitForDataPromise; typedef MozPromise<MediaData::Type, WaitForDataRejectValue, /* IsExclusive = */ true> WaitForDataPromise;
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader)
@ -386,7 +386,7 @@ protected:
Mirror<media::NullableTimeUnit> mDuration; Mirror<media::NullableTimeUnit> mDuration;
// State for ThrottledNotifyDataArrived. // State for ThrottledNotifyDataArrived.
MediaPromiseRequestHolder<MediaTimerPromise> mThrottledNotify; MozPromiseRequestHolder<MediaTimerPromise> mThrottledNotify;
const TimeDuration mThrottleDuration; const TimeDuration mThrottleDuration;
TimeStamp mLastThrottledNotify; TimeStamp mLastThrottledNotify;
Maybe<media::Interval<int64_t>> mThrottledInterval; Maybe<media::Interval<int64_t>> mThrottledInterval;
@ -420,8 +420,8 @@ protected:
private: private:
// Promises used only for the base-class (sync->async adapter) implementation // Promises used only for the base-class (sync->async adapter) implementation
// of Request{Audio,Video}Data. // of Request{Audio,Video}Data.
MediaPromiseHolder<AudioDataPromise> mBaseAudioPromise; MozPromiseHolder<AudioDataPromise> mBaseAudioPromise;
MediaPromiseHolder<VideoDataPromise> mBaseVideoPromise; MozPromiseHolder<VideoDataPromise> mBaseVideoPromise;
bool mTaskQueueIsBorrowed; bool mTaskQueueIsBorrowed;

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

@ -766,7 +766,7 @@ private:
private: private:
MediaDecoderStateMachine* mSelf; MediaDecoderStateMachine* mSelf;
nsRefPtr<MediaTimer> mMediaTimer; nsRefPtr<MediaTimer> mMediaTimer;
MediaPromiseRequestHolder<mozilla::MediaTimerPromise> mRequest; MozPromiseRequestHolder<mozilla::MediaTimerPromise> mRequest;
TimeStamp mTarget; TimeStamp mTarget;
} mDelayedScheduler; } mDelayedScheduler;
@ -778,7 +778,7 @@ private:
public: public:
typedef MediaDecoderReader::AudioDataPromise AudioDataPromise; typedef MediaDecoderReader::AudioDataPromise AudioDataPromise;
typedef MediaDecoderReader::VideoDataPromise VideoDataPromise; typedef MediaDecoderReader::VideoDataPromise VideoDataPromise;
typedef MediaPromise<bool, bool, /* isExclusive = */ false> HaveStartTimePromise; typedef MozPromise<bool, bool, /* isExclusive = */ false> HaveStartTimePromise;
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(StartTimeRendezvous); NS_INLINE_DECL_THREADSAFE_REFCOUNTING(StartTimeRendezvous);
StartTimeRendezvous(AbstractThread* aOwnerThread, bool aHasAudio, bool aHasVideo, StartTimeRendezvous(AbstractThread* aOwnerThread, bool aHasAudio, bool aHasVideo,
@ -888,7 +888,7 @@ private:
return aType == MediaData::AUDIO_DATA ? mAudioStartTime : mVideoStartTime; return aType == MediaData::AUDIO_DATA ? mAudioStartTime : mVideoStartTime;
} }
MediaPromiseHolder<HaveStartTimePromise> mHaveStartTimePromise; MozPromiseHolder<HaveStartTimePromise> mHaveStartTimePromise;
nsRefPtr<AbstractThread> mOwnerThread; nsRefPtr<AbstractThread> mOwnerThread;
Maybe<int64_t> mAudioStartTime; Maybe<int64_t> mAudioStartTime;
Maybe<int64_t> mVideoStartTime; Maybe<int64_t> mVideoStartTime;
@ -999,7 +999,7 @@ private:
} }
SeekTarget mTarget; SeekTarget mTarget;
MediaPromiseHolder<MediaDecoder::SeekPromise> mPromise; MozPromiseHolder<MediaDecoder::SeekPromise> mPromise;
}; };
// Queued seek - moves to mPendingSeek when DecodeFirstFrame completes. // Queued seek - moves to mPendingSeek when DecodeFirstFrame completes.
@ -1157,8 +1157,8 @@ private:
// Only one of a given pair of ({Audio,Video}DataPromise, WaitForDataPromise) // Only one of a given pair of ({Audio,Video}DataPromise, WaitForDataPromise)
// should exist at any given moment. // should exist at any given moment.
MediaPromiseRequestHolder<MediaDecoderReader::AudioDataPromise> mAudioDataRequest; MozPromiseRequestHolder<MediaDecoderReader::AudioDataPromise> mAudioDataRequest;
MediaPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise> mAudioWaitRequest; MozPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise> mAudioWaitRequest;
const char* AudioRequestStatus() const char* AudioRequestStatus()
{ {
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
@ -1171,8 +1171,8 @@ private:
return "idle"; return "idle";
} }
MediaPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise> mVideoWaitRequest; MozPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise> mVideoWaitRequest;
MediaPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mVideoDataRequest; MozPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mVideoDataRequest;
const char* VideoRequestStatus() const char* VideoRequestStatus()
{ {
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
@ -1185,7 +1185,7 @@ private:
return "idle"; return "idle";
} }
MediaPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise>& WaitRequestRef(MediaData::Type aType) MozPromiseRequestHolder<MediaDecoderReader::WaitForDataPromise>& WaitRequestRef(MediaData::Type aType)
{ {
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
return aType == MediaData::AUDIO_DATA ? mAudioWaitRequest : mVideoWaitRequest; return aType == MediaData::AUDIO_DATA ? mAudioWaitRequest : mVideoWaitRequest;
@ -1261,7 +1261,7 @@ private:
bool mDecodeToSeekTarget; bool mDecodeToSeekTarget;
// Track the current seek promise made by the reader. // Track the current seek promise made by the reader.
MediaPromiseRequestHolder<MediaDecoderReader::SeekPromise> mSeekRequest; MozPromiseRequestHolder<MediaDecoderReader::SeekPromise> mSeekRequest;
// We record the playback position before we seek in order to // We record the playback position before we seek in order to
// determine where the seek terminated relative to the playback position // determine where the seek terminated relative to the playback position
@ -1269,7 +1269,7 @@ private:
int64_t mCurrentTimeBeforeSeek; int64_t mCurrentTimeBeforeSeek;
// Track our request for metadata from the reader. // Track our request for metadata from the reader.
MediaPromiseRequestHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest; MozPromiseRequestHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest;
// Stores presentation info required for playback. The decoder monitor // Stores presentation info required for playback. The decoder monitor
// must be held when accessing this. // must be held when accessing this.

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

@ -227,12 +227,12 @@ private:
bool mDiscontinuity; bool mDiscontinuity;
// Pending seek. // Pending seek.
MediaPromiseRequestHolder<MediaTrackDemuxer::SeekPromise> mSeekRequest; MozPromiseRequestHolder<MediaTrackDemuxer::SeekPromise> mSeekRequest;
// Queued demux samples waiting to be decoded. // Queued demux samples waiting to be decoded.
nsTArray<nsRefPtr<MediaRawData>> mQueuedSamples; nsTArray<nsRefPtr<MediaRawData>> mQueuedSamples;
MediaPromiseRequestHolder<MediaTrackDemuxer::SamplesPromise> mDemuxRequest; MozPromiseRequestHolder<MediaTrackDemuxer::SamplesPromise> mDemuxRequest;
MediaPromiseHolder<WaitForDataPromise> mWaitingPromise; MozPromiseHolder<WaitForDataPromise> mWaitingPromise;
bool HasWaitingPromise() bool HasWaitingPromise()
{ {
MOZ_ASSERT(mOwner->OnTaskQueue()); MOZ_ASSERT(mOwner->OnTaskQueue());
@ -308,7 +308,7 @@ private:
DecoderData(aOwner, aType, aDecodeAhead) DecoderData(aOwner, aType, aDecodeAhead)
{} {}
MediaPromiseHolder<PromiseType> mPromise; MozPromiseHolder<PromiseType> mPromise;
bool HasPromise() override bool HasPromise() override
{ {
@ -335,7 +335,7 @@ private:
// Demuxer objects. // Demuxer objects.
void OnDemuxerInitDone(nsresult); void OnDemuxerInitDone(nsresult);
void OnDemuxerInitFailed(DemuxerFailureReason aFailure); void OnDemuxerInitFailed(DemuxerFailureReason aFailure);
MediaPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest; MozPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest;
void OnDemuxFailed(TrackType aTrack, DemuxerFailureReason aFailure); void OnDemuxFailed(TrackType aTrack, DemuxerFailureReason aFailure);
void DoDemuxVideo(); void DoDemuxVideo();
@ -353,7 +353,7 @@ private:
} }
void SkipVideoDemuxToNextKeyFrame(media::TimeUnit aTimeThreshold); void SkipVideoDemuxToNextKeyFrame(media::TimeUnit aTimeThreshold);
MediaPromiseRequestHolder<MediaTrackDemuxer::SkipAccessPointPromise> mSkipRequest; MozPromiseRequestHolder<MediaTrackDemuxer::SkipAccessPointPromise> mSkipRequest;
void OnVideoSkipCompleted(uint32_t aSkipped); void OnVideoSkipCompleted(uint32_t aSkipped);
void OnVideoSkipFailed(MediaTrackDemuxer::SkipFailureHolder aFailure); void OnVideoSkipFailed(MediaTrackDemuxer::SkipFailureHolder aFailure);
@ -368,7 +368,7 @@ private:
// Metadata objects // Metadata objects
// True if we've read the streams' metadata. // True if we've read the streams' metadata.
bool mInitDone; bool mInitDone;
MediaPromiseHolder<MetadataPromise> mMetadataPromise; MozPromiseHolder<MetadataPromise> mMetadataPromise;
// Accessed from multiple thread, in particular the MediaDecoderStateMachine, // Accessed from multiple thread, in particular the MediaDecoderStateMachine,
// however the value doesn't change after reading the metadata. // however the value doesn't change after reading the metadata.
bool mSeekable; bool mSeekable;
@ -404,7 +404,7 @@ private:
} }
// Temporary seek information while we wait for the data // Temporary seek information while we wait for the data
Maybe<media::TimeUnit> mPendingSeekTime; Maybe<media::TimeUnit> mPendingSeekTime;
MediaPromiseHolder<SeekPromise> mSeekPromise; MozPromiseHolder<SeekPromise> mSeekPromise;
#ifdef MOZ_EME #ifdef MOZ_EME
nsRefPtr<CDMProxy> mCDMProxy; nsRefPtr<CDMProxy> mCDMProxy;

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

@ -13,7 +13,7 @@
#include "mozilla/unused.h" #include "mozilla/unused.h"
#include "SharedThreadPool.h" #include "SharedThreadPool.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "MediaPromise.h" #include "MozPromise.h"
#include "TaskDispatcher.h" #include "TaskDispatcher.h"
class nsIRunnable; class nsIRunnable;
@ -22,7 +22,7 @@ namespace mozilla {
class SharedThreadPool; class SharedThreadPool;
typedef MediaPromise<bool, bool, false> ShutdownPromise; typedef MozPromise<bool, bool, false> ShutdownPromise;
// Abstracts executing runnables in order in a thread pool. The runnables // Abstracts executing runnables in order in a thread pool. The runnables
// dispatched to the MediaTaskQueue will be executed in the order in which // dispatched to the MediaTaskQueue will be executed in the order in which
@ -156,7 +156,7 @@ protected:
// True if we've started our shutdown process. // True if we've started our shutdown process.
bool mIsShutdown; bool mIsShutdown;
MediaPromiseHolder<ShutdownPromise> mShutdownPromise; MozPromiseHolder<ShutdownPromise> mShutdownPromise;
// True if we're flushing; we reject new tasks if we're flushing. // True if we're flushing; we reject new tasks if we're flushing.
bool mIsFlushing; bool mIsFlushing;

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

@ -7,7 +7,7 @@
#if !defined(MediaTimer_h_) #if !defined(MediaTimer_h_)
#define MediaTimer_h_ #define MediaTimer_h_
#include "MediaPromise.h" #include "MozPromise.h"
#include <queue> #include <queue>
@ -28,11 +28,11 @@ extern PRLogModuleInfo* gMediaTimerLog;
// This promise type is only exclusive because so far there isn't a reason for // This promise type is only exclusive because so far there isn't a reason for
// it not to be. Feel free to change that. // it not to be. Feel free to change that.
typedef MediaPromise<bool, bool, /* IsExclusive = */ true> MediaTimerPromise; typedef MozPromise<bool, bool, /* IsExclusive = */ true> MediaTimerPromise;
// Timers only know how to fire at a given thread, which creates an impedence // Timers only know how to fire at a given thread, which creates an impedence
// mismatch with code that operates with MediaTaskQueues. This class solves // mismatch with code that operates with MediaTaskQueues. This class solves
// that mismatch with a dedicated (but shared) thread and a nice MediaPromise-y // that mismatch with a dedicated (but shared) thread and a nice MozPromise-y
// interface. // interface.
class MediaTimer class MediaTimer
{ {

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

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined(MediaPromise_h_) #if !defined(MozPromise_h_)
#define MediaPromise_h_ #define MozPromise_h_
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
@ -20,18 +20,18 @@
#include "mozilla/Monitor.h" #include "mozilla/Monitor.h"
#include "mozilla/unused.h" #include "mozilla/unused.h"
/* Polyfill __func__ on MSVC for consumers to pass to the MediaPromise API. */ /* Polyfill __func__ on MSVC for consumers to pass to the MozPromise API. */
#ifdef _MSC_VER #ifdef _MSC_VER
#define __func__ __FUNCTION__ #define __func__ __FUNCTION__
#endif #endif
namespace mozilla { namespace mozilla {
extern PRLogModuleInfo* gMediaPromiseLog; extern PRLogModuleInfo* gMozPromiseLog;
#define PROMISE_LOG(x, ...) \ #define PROMISE_LOG(x, ...) \
MOZ_ASSERT(gMediaPromiseLog); \ MOZ_ASSERT(gMozPromiseLog); \
MOZ_LOG(gMediaPromiseLog, mozilla::LogLevel::Debug, (x, ##__VA_ARGS__)) MOZ_LOG(gMozPromiseLog, mozilla::LogLevel::Debug, (x, ##__VA_ARGS__))
namespace detail { namespace detail {
template<typename ThisType, typename Ret, typename ArgType> template<typename ThisType, typename Ret, typename ArgType>
@ -75,14 +75,14 @@ struct ReturnTypeIs {
* callbacks to be invoked (asynchronously, on a specified thread) when the * callbacks to be invoked (asynchronously, on a specified thread) when the
* request is either completed (resolved) or cannot be completed (rejected). * request is either completed (resolved) or cannot be completed (rejected).
* *
* MediaPromises attempt to mirror the spirit of JS Promises to the extent that * MozPromises attempt to mirror the spirit of JS Promises to the extent that
* is possible (and desirable) in C++. While the intent is that MediaPromises * is possible (and desirable) in C++. While the intent is that MozPromises
* feel familiar to programmers who are accustomed to their JS-implemented cousin, * feel familiar to programmers who are accustomed to their JS-implemented cousin,
* we don't shy away from imposing restrictions and adding features that make * we don't shy away from imposing restrictions and adding features that make
* sense for the use cases we encounter. * sense for the use cases we encounter.
* *
* A MediaPromise is ThreadSafe, and may be ->Then()ed on any thread. The Then() * A MozPromise is ThreadSafe, and may be ->Then()ed on any thread. The Then()
* call accepts resolve and reject callbacks, and returns a MediaPromise::Request. * call accepts resolve and reject callbacks, and returns a MozPromise::Request.
* The Request object serves several purposes for the consumer. * The Request object serves several purposes for the consumer.
* *
* (1) It allows the caller to cancel the delivery of the resolve/reject value * (1) It allows the caller to cancel the delivery of the resolve/reject value
@ -91,33 +91,33 @@ struct ReturnTypeIs {
* *
* (2) It provides access to a "Completion Promise", which is roughly analagous * (2) It provides access to a "Completion Promise", which is roughly analagous
* to the Promise returned directly by ->then() calls on JS promises. If * to the Promise returned directly by ->then() calls on JS promises. If
* the resolve/reject callback returns a new MediaPromise, that promise is * the resolve/reject callback returns a new MozPromise, that promise is
* chained to the completion promise, such that its resolve/reject value * chained to the completion promise, such that its resolve/reject value
* will be forwarded along when it arrives. If the resolve/reject callback * will be forwarded along when it arrives. If the resolve/reject callback
* returns void, the completion promise is resolved/rejected with the same * returns void, the completion promise is resolved/rejected with the same
* value that was passed to the callback. * value that was passed to the callback.
* *
* The MediaPromise APIs skirt traditional XPCOM convention by returning nsRefPtrs * The MozPromise APIs skirt traditional XPCOM convention by returning nsRefPtrs
* (rather than already_AddRefed) from various methods. This is done to allow elegant * (rather than already_AddRefed) from various methods. This is done to allow elegant
* chaining of calls without cluttering up the code with intermediate variables, and * chaining of calls without cluttering up the code with intermediate variables, and
* without introducing separate API variants for callers that want a return value * without introducing separate API variants for callers that want a return value
* (from, say, ->Then()) from those that don't. * (from, say, ->Then()) from those that don't.
* *
* When IsExclusive is true, the MediaPromise does a release-mode assertion that * When IsExclusive is true, the MozPromise does a release-mode assertion that
* there is at most one call to either Then(...) or ChainTo(...). * there is at most one call to either Then(...) or ChainTo(...).
*/ */
class MediaPromiseRefcountable class MozPromiseRefcountable
{ {
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaPromiseRefcountable) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MozPromiseRefcountable)
protected: protected:
virtual ~MediaPromiseRefcountable() {} virtual ~MozPromiseRefcountable() {}
}; };
template<typename T> class MediaPromiseHolder; template<typename T> class MozPromiseHolder;
template<typename ResolveValueT, typename RejectValueT, bool IsExclusive> template<typename ResolveValueT, typename RejectValueT, bool IsExclusive>
class MediaPromise : public MediaPromiseRefcountable class MozPromise : public MozPromiseRefcountable
{ {
public: public:
typedef ResolveValueT ResolveValueType; typedef ResolveValueT ResolveValueType;
@ -168,47 +168,47 @@ public:
}; };
protected: protected:
// MediaPromise is the public type, and never constructed directly. Construct // MozPromise is the public type, and never constructed directly. Construct
// a MediaPromise::Private, defined below. // a MozPromise::Private, defined below.
explicit MediaPromise(const char* aCreationSite) explicit MozPromise(const char* aCreationSite)
: mCreationSite(aCreationSite) : mCreationSite(aCreationSite)
, mMutex("MediaPromise Mutex") , mMutex("MozPromise Mutex")
, mHaveRequest(false) , mHaveRequest(false)
{ {
PROMISE_LOG("%s creating MediaPromise (%p)", mCreationSite, this); PROMISE_LOG("%s creating MozPromise (%p)", mCreationSite, this);
} }
public: public:
// MediaPromise::Private allows us to separate the public interface (upon which // MozPromise::Private allows us to separate the public interface (upon which
// consumers of the promise may invoke methods like Then()) from the private // consumers of the promise may invoke methods like Then()) from the private
// interface (upon which the creator of the promise may invoke Resolve() or // interface (upon which the creator of the promise may invoke Resolve() or
// Reject()). APIs should create and store a MediaPromise::Private (usually // Reject()). APIs should create and store a MozPromise::Private (usually
// via a MediaPromiseHolder), and return a MediaPromise to consumers. // via a MozPromiseHolder), and return a MozPromise to consumers.
// //
// NB: We can include the definition of this class inline once B2G ICS is gone. // NB: We can include the definition of this class inline once B2G ICS is gone.
class Private; class Private;
template<typename ResolveValueType_> template<typename ResolveValueType_>
static nsRefPtr<MediaPromise> static nsRefPtr<MozPromise>
CreateAndResolve(ResolveValueType_&& aResolveValue, const char* aResolveSite) CreateAndResolve(ResolveValueType_&& aResolveValue, const char* aResolveSite)
{ {
nsRefPtr<typename MediaPromise::Private> p = new MediaPromise::Private(aResolveSite); nsRefPtr<typename MozPromise::Private> p = new MozPromise::Private(aResolveSite);
p->Resolve(Forward<ResolveValueType_>(aResolveValue), aResolveSite); p->Resolve(Forward<ResolveValueType_>(aResolveValue), aResolveSite);
return p.forget(); return p.forget();
} }
template<typename RejectValueType_> template<typename RejectValueType_>
static nsRefPtr<MediaPromise> static nsRefPtr<MozPromise>
CreateAndReject(RejectValueType_&& aRejectValue, const char* aRejectSite) CreateAndReject(RejectValueType_&& aRejectValue, const char* aRejectSite)
{ {
nsRefPtr<typename MediaPromise::Private> p = new MediaPromise::Private(aRejectSite); nsRefPtr<typename MozPromise::Private> p = new MozPromise::Private(aRejectSite);
p->Reject(Forward<RejectValueType_>(aRejectValue), aRejectSite); p->Reject(Forward<RejectValueType_>(aRejectValue), aRejectSite);
return p.forget(); return p.forget();
} }
typedef MediaPromise<nsTArray<ResolveValueType>, RejectValueType, IsExclusive> AllPromiseType; typedef MozPromise<nsTArray<ResolveValueType>, RejectValueType, IsExclusive> AllPromiseType;
private: private:
class AllPromiseHolder : public MediaPromiseRefcountable class AllPromiseHolder : public MozPromiseRefcountable
{ {
public: public:
explicit AllPromiseHolder(size_t aDependentPromises) explicit AllPromiseHolder(size_t aDependentPromises)
@ -255,7 +255,7 @@ private:
}; };
public: public:
static nsRefPtr<AllPromiseType> All(AbstractThread* aProcessingThread, nsTArray<nsRefPtr<MediaPromise>>& aPromises) static nsRefPtr<AllPromiseType> All(AbstractThread* aProcessingThread, nsTArray<nsRefPtr<MozPromise>>& aPromises)
{ {
nsRefPtr<AllPromiseHolder> holder = new AllPromiseHolder(aPromises.Length()); nsRefPtr<AllPromiseHolder> holder = new AllPromiseHolder(aPromises.Length());
for (size_t i = 0; i < aPromises.Length(); ++i) { for (size_t i = 0; i < aPromises.Length(); ++i) {
@ -267,7 +267,7 @@ public:
return holder->Promise(); return holder->Promise();
} }
class Request : public MediaPromiseRefcountable class Request : public MozPromiseRefcountable
{ {
public: public:
virtual void Disconnect() = 0; virtual void Disconnect() = 0;
@ -276,7 +276,7 @@ public:
// tries to access an inherited protected member. // tries to access an inherited protected member.
bool IsDisconnected() const { return mDisconnected; } bool IsDisconnected() const { return mDisconnected; }
virtual MediaPromise* CompletionPromise() = 0; virtual MozPromise* CompletionPromise() = 0;
protected: protected:
Request() : mComplete(false), mDisconnected(false) {} Request() : mComplete(false), mDisconnected(false) {}
@ -300,7 +300,7 @@ protected:
class ResolveOrRejectRunnable : public nsRunnable class ResolveOrRejectRunnable : public nsRunnable
{ {
public: public:
ResolveOrRejectRunnable(ThenValueBase* aThenValue, MediaPromise* aPromise) ResolveOrRejectRunnable(ThenValueBase* aThenValue, MozPromise* aPromise)
: mThenValue(aThenValue) : mThenValue(aThenValue)
, mPromise(aPromise) , mPromise(aPromise)
{ {
@ -323,23 +323,23 @@ protected:
private: private:
nsRefPtr<ThenValueBase> mThenValue; nsRefPtr<ThenValueBase> mThenValue;
nsRefPtr<MediaPromise> mPromise; nsRefPtr<MozPromise> mPromise;
}; };
explicit ThenValueBase(AbstractThread* aResponseTarget, const char* aCallSite) explicit ThenValueBase(AbstractThread* aResponseTarget, const char* aCallSite)
: mResponseTarget(aResponseTarget), mCallSite(aCallSite) {} : mResponseTarget(aResponseTarget), mCallSite(aCallSite) {}
MediaPromise* CompletionPromise() override MozPromise* CompletionPromise() override
{ {
MOZ_DIAGNOSTIC_ASSERT(mResponseTarget->IsCurrentThreadIn()); MOZ_DIAGNOSTIC_ASSERT(mResponseTarget->IsCurrentThreadIn());
MOZ_DIAGNOSTIC_ASSERT(!Request::mComplete); MOZ_DIAGNOSTIC_ASSERT(!Request::mComplete);
if (!mCompletionPromise) { if (!mCompletionPromise) {
mCompletionPromise = new MediaPromise::Private("<completion promise>"); mCompletionPromise = new MozPromise::Private("<completion promise>");
} }
return mCompletionPromise; return mCompletionPromise;
} }
void Dispatch(MediaPromise *aPromise) void Dispatch(MozPromise *aPromise)
{ {
aPromise->mMutex.AssertCurrentThreadOwns(); aPromise->mMutex.AssertCurrentThreadOwns();
MOZ_ASSERT(!aPromise->IsPending()); MOZ_ASSERT(!aPromise->IsPending());
@ -371,7 +371,7 @@ protected:
} }
protected: protected:
virtual already_AddRefed<MediaPromise> DoResolveOrRejectInternal(const ResolveOrRejectValue& aValue) = 0; virtual already_AddRefed<MozPromise> DoResolveOrRejectInternal(const ResolveOrRejectValue& aValue) = 0;
void DoResolveOrReject(const ResolveOrRejectValue& aValue) void DoResolveOrReject(const ResolveOrRejectValue& aValue)
{ {
@ -382,16 +382,16 @@ protected:
} }
// Invoke the resolve or reject method. // Invoke the resolve or reject method.
nsRefPtr<MediaPromise> p = DoResolveOrRejectInternal(aValue); nsRefPtr<MozPromise> p = DoResolveOrRejectInternal(aValue);
// If there's a completion promise, resolve it appropriately with the // If there's a completion promise, resolve it appropriately with the
// result of the method. // result of the method.
// //
// We jump through some hoops to cast to MediaPromise::Private here. This // We jump through some hoops to cast to MozPromise::Private here. This
// can go away when we can just declare mCompletionPromise as // can go away when we can just declare mCompletionPromise as
// MediaPromise::Private. See the declaration below. // MozPromise::Private. See the declaration below.
nsRefPtr<MediaPromise::Private> completionPromise = nsRefPtr<MozPromise::Private> completionPromise =
dont_AddRef(static_cast<MediaPromise::Private*>(mCompletionPromise.forget().take())); dont_AddRef(static_cast<MozPromise::Private*>(mCompletionPromise.forget().take()));
if (completionPromise) { if (completionPromise) {
if (p) { if (p) {
p->ChainTo(completionPromise.forget(), "<chained completion promise>"); p->ChainTo(completionPromise.forget(), "<chained completion promise>");
@ -403,11 +403,11 @@ protected:
nsRefPtr<AbstractThread> mResponseTarget; // May be released on any thread. nsRefPtr<AbstractThread> mResponseTarget; // May be released on any thread.
// Declaring nsRefPtr<MediaPromise::Private> here causes build failures // Declaring nsRefPtr<MozPromise::Private> here causes build failures
// on MSVC because MediaPromise::Private is only forward-declared at this // on MSVC because MozPromise::Private is only forward-declared at this
// point. This hack can go away when we inline-declare MediaPromise::Private, // point. This hack can go away when we inline-declare MozPromise::Private,
// which is blocked on the B2G ICS compiler being too old. // which is blocked on the B2G ICS compiler being too old.
nsRefPtr<MediaPromise> mCompletionPromise; nsRefPtr<MozPromise> mCompletionPromise;
const char* mCallSite; const char* mCallSite;
}; };
@ -418,9 +418,9 @@ protected:
*/ */
template<typename ThisType, typename MethodType, typename ValueType> template<typename ThisType, typename MethodType, typename ValueType>
static typename EnableIf<ReturnTypeIs<MethodType, nsRefPtr<MediaPromise>>::value && static typename EnableIf<ReturnTypeIs<MethodType, nsRefPtr<MozPromise>>::value &&
TakesArgument<MethodType>::value, TakesArgument<MethodType>::value,
already_AddRefed<MediaPromise>>::Type already_AddRefed<MozPromise>>::Type
InvokeCallbackMethod(ThisType* aThisVal, MethodType aMethod, ValueType&& aValue) InvokeCallbackMethod(ThisType* aThisVal, MethodType aMethod, ValueType&& aValue)
{ {
return ((*aThisVal).*aMethod)(Forward<ValueType>(aValue)).forget(); return ((*aThisVal).*aMethod)(Forward<ValueType>(aValue)).forget();
@ -429,7 +429,7 @@ protected:
template<typename ThisType, typename MethodType, typename ValueType> template<typename ThisType, typename MethodType, typename ValueType>
static typename EnableIf<ReturnTypeIs<MethodType, void>::value && static typename EnableIf<ReturnTypeIs<MethodType, void>::value &&
TakesArgument<MethodType>::value, TakesArgument<MethodType>::value,
already_AddRefed<MediaPromise>>::Type already_AddRefed<MozPromise>>::Type
InvokeCallbackMethod(ThisType* aThisVal, MethodType aMethod, ValueType&& aValue) InvokeCallbackMethod(ThisType* aThisVal, MethodType aMethod, ValueType&& aValue)
{ {
((*aThisVal).*aMethod)(Forward<ValueType>(aValue)); ((*aThisVal).*aMethod)(Forward<ValueType>(aValue));
@ -437,9 +437,9 @@ protected:
} }
template<typename ThisType, typename MethodType, typename ValueType> template<typename ThisType, typename MethodType, typename ValueType>
static typename EnableIf<ReturnTypeIs<MethodType, nsRefPtr<MediaPromise>>::value && static typename EnableIf<ReturnTypeIs<MethodType, nsRefPtr<MozPromise>>::value &&
!TakesArgument<MethodType>::value, !TakesArgument<MethodType>::value,
already_AddRefed<MediaPromise>>::Type already_AddRefed<MozPromise>>::Type
InvokeCallbackMethod(ThisType* aThisVal, MethodType aMethod, ValueType&& aValue) InvokeCallbackMethod(ThisType* aThisVal, MethodType aMethod, ValueType&& aValue)
{ {
return ((*aThisVal).*aMethod)().forget(); return ((*aThisVal).*aMethod)().forget();
@ -448,7 +448,7 @@ protected:
template<typename ThisType, typename MethodType, typename ValueType> template<typename ThisType, typename MethodType, typename ValueType>
static typename EnableIf<ReturnTypeIs<MethodType, void>::value && static typename EnableIf<ReturnTypeIs<MethodType, void>::value &&
!TakesArgument<MethodType>::value, !TakesArgument<MethodType>::value,
already_AddRefed<MediaPromise>>::Type already_AddRefed<MozPromise>>::Type
InvokeCallbackMethod(ThisType* aThisVal, MethodType aMethod, ValueType&& aValue) InvokeCallbackMethod(ThisType* aThisVal, MethodType aMethod, ValueType&& aValue)
{ {
((*aThisVal).*aMethod)(); ((*aThisVal).*aMethod)();
@ -478,9 +478,9 @@ protected:
} }
protected: protected:
virtual already_AddRefed<MediaPromise> DoResolveOrRejectInternal(const ResolveOrRejectValue& aValue) override virtual already_AddRefed<MozPromise> DoResolveOrRejectInternal(const ResolveOrRejectValue& aValue) override
{ {
nsRefPtr<MediaPromise> completion; nsRefPtr<MozPromise> completion;
if (aValue.IsResolve()) { if (aValue.IsResolve()) {
completion = InvokeCallbackMethod(mThisVal.get(), mResolveMethod, aValue.ResolveValue()); completion = InvokeCallbackMethod(mThisVal.get(), mResolveMethod, aValue.ResolveValue());
} else { } else {
@ -530,14 +530,14 @@ protected:
} }
protected: protected:
virtual already_AddRefed<MediaPromise> DoResolveOrRejectInternal(const ResolveOrRejectValue& aValue) override virtual already_AddRefed<MozPromise> DoResolveOrRejectInternal(const ResolveOrRejectValue& aValue) override
{ {
// Note: The usage of InvokeCallbackMethod here requires that // Note: The usage of InvokeCallbackMethod here requires that
// ResolveFunction/RejectFunction are capture-lambdas (i.e. anonymous // ResolveFunction/RejectFunction are capture-lambdas (i.e. anonymous
// classes with ::operator()), since it allows us to share code more easily. // classes with ::operator()), since it allows us to share code more easily.
// We could fix this if need be, though it's quite easy to work around by // We could fix this if need be, though it's quite easy to work around by
// just capturing something. // just capturing something.
nsRefPtr<MediaPromise> completion; nsRefPtr<MozPromise> completion;
if (aValue.IsResolve()) { if (aValue.IsResolve()) {
completion = InvokeCallbackMethod(mResolveFunction.ptr(), &ResolveFunction::operator(), aValue.ResolveValue()); completion = InvokeCallbackMethod(mResolveFunction.ptr(), &ResolveFunction::operator(), aValue.ResolveValue());
} else { } else {
@ -647,9 +647,9 @@ protected:
} }
} }
virtual ~MediaPromise() virtual ~MozPromise()
{ {
PROMISE_LOG("MediaPromise::~MediaPromise [this=%p]", this); PROMISE_LOG("MozPromise::~MozPromise [this=%p]", this);
MOZ_ASSERT(!IsPending()); MOZ_ASSERT(!IsPending());
MOZ_ASSERT(mThenValues.IsEmpty()); MOZ_ASSERT(mThenValues.IsEmpty());
MOZ_ASSERT(mChainedPromises.IsEmpty()); MOZ_ASSERT(mChainedPromises.IsEmpty());
@ -664,18 +664,18 @@ protected:
}; };
template<typename ResolveValueT, typename RejectValueT, bool IsExclusive> template<typename ResolveValueT, typename RejectValueT, bool IsExclusive>
class MediaPromise<ResolveValueT, RejectValueT, IsExclusive>::Private class MozPromise<ResolveValueT, RejectValueT, IsExclusive>::Private
: public MediaPromise<ResolveValueT, RejectValueT, IsExclusive> : public MozPromise<ResolveValueT, RejectValueT, IsExclusive>
{ {
public: public:
explicit Private(const char* aCreationSite) : MediaPromise(aCreationSite) {} explicit Private(const char* aCreationSite) : MozPromise(aCreationSite) {}
template<typename ResolveValueT_> template<typename ResolveValueT_>
void Resolve(ResolveValueT_&& aResolveValue, const char* aResolveSite) void Resolve(ResolveValueT_&& aResolveValue, const char* aResolveSite)
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
MOZ_ASSERT(IsPending()); MOZ_ASSERT(IsPending());
PROMISE_LOG("%s resolving MediaPromise (%p created at %s)", aResolveSite, this, mCreationSite); PROMISE_LOG("%s resolving MozPromise (%p created at %s)", aResolveSite, this, mCreationSite);
mValue.SetResolve(Forward<ResolveValueT_>(aResolveValue)); mValue.SetResolve(Forward<ResolveValueT_>(aResolveValue));
DispatchAll(); DispatchAll();
} }
@ -685,7 +685,7 @@ public:
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
MOZ_ASSERT(IsPending()); MOZ_ASSERT(IsPending());
PROMISE_LOG("%s rejecting MediaPromise (%p created at %s)", aRejectSite, this, mCreationSite); PROMISE_LOG("%s rejecting MozPromise (%p created at %s)", aRejectSite, this, mCreationSite);
mValue.SetReject(Forward<RejectValueT_>(aRejectValue)); mValue.SetReject(Forward<RejectValueT_>(aRejectValue));
DispatchAll(); DispatchAll();
} }
@ -695,28 +695,28 @@ public:
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
MOZ_ASSERT(IsPending()); MOZ_ASSERT(IsPending());
PROMISE_LOG("%s resolveOrRejecting MediaPromise (%p created at %s)", aSite, this, mCreationSite); PROMISE_LOG("%s resolveOrRejecting MozPromise (%p created at %s)", aSite, this, mCreationSite);
mValue = Forward<ResolveOrRejectValue_>(aValue); mValue = Forward<ResolveOrRejectValue_>(aValue);
DispatchAll(); DispatchAll();
} }
}; };
// A generic promise type that does the trick for simple use cases. // A generic promise type that does the trick for simple use cases.
typedef MediaPromise<bool, nsresult, /* IsExclusive = */ false> GenericPromise; typedef MozPromise<bool, nsresult, /* IsExclusive = */ false> GenericPromise;
/* /*
* Class to encapsulate a promise for a particular role. Use this as the member * Class to encapsulate a promise for a particular role. Use this as the member
* variable for a class whose method returns a promise. * variable for a class whose method returns a promise.
*/ */
template<typename PromiseType> template<typename PromiseType>
class MediaPromiseHolder class MozPromiseHolder
{ {
public: public:
MediaPromiseHolder() MozPromiseHolder()
: mMonitor(nullptr) {} : mMonitor(nullptr) {}
// Move semantics. // Move semantics.
MediaPromiseHolder& operator=(MediaPromiseHolder&& aOther) MozPromiseHolder& operator=(MozPromiseHolder&& aOther)
{ {
MOZ_ASSERT(!mMonitor && !aOther.mMonitor); MOZ_ASSERT(!mMonitor && !aOther.mMonitor);
MOZ_DIAGNOSTIC_ASSERT(!mPromise); MOZ_DIAGNOSTIC_ASSERT(!mPromise);
@ -725,7 +725,7 @@ public:
return *this; return *this;
} }
~MediaPromiseHolder() { MOZ_ASSERT(!mPromise); } ~MozPromiseHolder() { MOZ_ASSERT(!mPromise); }
already_AddRefed<PromiseType> Ensure(const char* aMethodName) { already_AddRefed<PromiseType> Ensure(const char* aMethodName) {
if (mMonitor) { if (mMonitor) {
@ -806,15 +806,15 @@ private:
}; };
/* /*
* Class to encapsulate a MediaPromise::Request reference. Use this as the member * Class to encapsulate a MozPromise::Request reference. Use this as the member
* variable for a class waiting on a media promise. * variable for a class waiting on a MozPromise.
*/ */
template<typename PromiseType> template<typename PromiseType>
class MediaPromiseRequestHolder class MozPromiseRequestHolder
{ {
public: public:
MediaPromiseRequestHolder() {} MozPromiseRequestHolder() {}
~MediaPromiseRequestHolder() { MOZ_ASSERT(!mRequest); } ~MozPromiseRequestHolder() { MOZ_ASSERT(!mRequest); }
void Begin(typename PromiseType::Request* aRequest) void Begin(typename PromiseType::Request* aRequest)
{ {

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

@ -7,7 +7,7 @@
#if !defined(StateMirroring_h_) #if !defined(StateMirroring_h_)
#define StateMirroring_h_ #define StateMirroring_h_
#include "MediaPromise.h" #include "MozPromise.h"
#include "StateWatching.h" #include "StateWatching.h"
#include "TaskDispatcher.h" #include "TaskDispatcher.h"

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

@ -13,7 +13,7 @@
#include "nsIThread.h" #include "nsIThread.h"
#include "nsSize.h" #include "nsSize.h"
#include "nsRect.h" #include "nsRect.h"
#include "MediaPromise.h" #include "MozPromise.h"
#if !(defined(XP_WIN) || defined(XP_MACOSX) || defined(LINUX)) || \ #if !(defined(XP_WIN) || defined(XP_MACOSX) || defined(LINUX)) || \
defined(MOZ_ASAN) defined(MOZ_ASAN)
@ -215,7 +215,7 @@ class SharedThreadPool;
// wait on tasks in the PLAYBACK thread pool. // wait on tasks in the PLAYBACK thread pool.
// //
// No new dependencies on this mechanism should be added, as methods are being // No new dependencies on this mechanism should be added, as methods are being
// made async supported by MediaPromise, making this unnecessary and // made async supported by MozPromise, making this unnecessary and
// permitting unifying the pool. // permitting unifying the pool.
enum class MediaThreadType { enum class MediaThreadType {
PLAYBACK, // MediaDecoderStateMachine and MediaDecoderReader PLAYBACK, // MediaDecoderStateMachine and MediaDecoderReader

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

@ -36,8 +36,8 @@ class AndroidMediaReader : public MediaDecoderReader
int64_t mVideoSeekTimeUs; int64_t mVideoSeekTimeUs;
int64_t mAudioSeekTimeUs; int64_t mAudioSeekTimeUs;
nsRefPtr<VideoData> mLastVideoFrame; nsRefPtr<VideoData> mLastVideoFrame;
MediaPromiseHolder<MediaDecoderReader::SeekPromise> mSeekPromise; MozPromiseHolder<MediaDecoderReader::SeekPromise> mSeekPromise;
MediaPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mSeekRequest; MozPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mSeekRequest;
public: public:
AndroidMediaReader(AbstractMediaDecoder* aDecoder, AndroidMediaReader(AbstractMediaDecoder* aDecoder,
const nsACString& aContentType); const nsACString& aContentType);

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

@ -14,7 +14,7 @@
#include "nsIThread.h" #include "nsIThread.h"
#include "GMPDecryptorProxy.h" #include "GMPDecryptorProxy.h"
#include "mozilla/CDMCaps.h" #include "mozilla/CDMCaps.h"
#include "MediaPromise.h" #include "MozPromise.h"
namespace mozilla { namespace mozilla {
class MediaRawData; class MediaRawData;
@ -44,7 +44,7 @@ public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CDMProxy) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CDMProxy)
typedef MediaPromise<DecryptResult, DecryptResult, /* IsExclusive = */ true> DecryptPromise; typedef MozPromise<DecryptResult, DecryptResult, /* IsExclusive = */ true> DecryptPromise;
// Main thread only. // Main thread only.
CDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem); CDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem);
@ -259,7 +259,7 @@ private:
nsRefPtr<MediaRawData> mSample; nsRefPtr<MediaRawData> mSample;
private: private:
~DecryptJob() {} ~DecryptJob() {}
MediaPromiseHolder<DecryptPromise> mPromise; MozPromiseHolder<DecryptPromise> mPromise;
}; };
// GMP thread only. // GMP thread only.
void gmp_Decrypt(nsRefPtr<DecryptJob> aJob); void gmp_Decrypt(nsRefPtr<DecryptJob> aJob);

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

@ -224,7 +224,7 @@ private:
mPromise.SetMonitor(&mMonitor); mPromise.SetMonitor(&mMonitor);
} }
MediaPromiseHolder<PromiseType> mPromise; MozPromiseHolder<PromiseType> mPromise;
bool HasPromise() override { return !mPromise.IsEmpty(); } bool HasPromise() override { return !mPromise.IsEmpty(); }
void RejectPromise(MediaDecoderReader::NotDecodedReason aReason, void RejectPromise(MediaDecoderReader::NotDecodedReason aReason,

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

@ -6,13 +6,13 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
#include "MediaTaskQueue.h" #include "MediaTaskQueue.h"
#include "MediaPromise.h" #include "MozPromise.h"
#include "SharedThreadPool.h" #include "SharedThreadPool.h"
#include "VideoUtils.h" #include "VideoUtils.h"
using namespace mozilla; using namespace mozilla;
typedef MediaPromise<int, double, false> TestPromise; typedef MozPromise<int, double, false> TestPromise;
typedef TestPromise::ResolveOrRejectValue RRValue; typedef TestPromise::ResolveOrRejectValue RRValue;
class MOZ_STACK_CLASS AutoTaskQueue class MOZ_STACK_CLASS AutoTaskQueue
@ -88,7 +88,7 @@ RunOnTaskQueue(MediaTaskQueue* aQueue, FunctionType aFun)
// std::function can't come soon enough. :-( // std::function can't come soon enough. :-(
#define DO_FAIL []()->void { EXPECT_TRUE(false); } #define DO_FAIL []()->void { EXPECT_TRUE(false); }
TEST(MediaPromise, BasicResolve) TEST(MozPromise, BasicResolve)
{ {
AutoTaskQueue atq; AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue(); nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
@ -99,7 +99,7 @@ TEST(MediaPromise, BasicResolve)
}); });
} }
TEST(MediaPromise, BasicReject) TEST(MozPromise, BasicReject)
{ {
AutoTaskQueue atq; AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue(); nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
@ -110,7 +110,7 @@ TEST(MediaPromise, BasicReject)
}); });
} }
TEST(MediaPromise, AsyncResolve) TEST(MozPromise, AsyncResolve)
{ {
AutoTaskQueue atq; AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue(); nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
@ -139,7 +139,7 @@ TEST(MediaPromise, AsyncResolve)
}); });
} }
TEST(MediaPromise, CompletionPromises) TEST(MozPromise, CompletionPromises)
{ {
bool invokedPass = false; bool invokedPass = false;
AutoTaskQueue atq; AutoTaskQueue atq;
@ -171,7 +171,7 @@ TEST(MediaPromise, CompletionPromises)
}); });
} }
TEST(MediaPromise, PromiseAllResolve) TEST(MozPromise, PromiseAllResolve)
{ {
AutoTaskQueue atq; AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue(); nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();
@ -195,7 +195,7 @@ TEST(MediaPromise, PromiseAllResolve)
}); });
} }
TEST(MediaPromise, PromiseAllReject) TEST(MozPromise, PromiseAllReject)
{ {
AutoTaskQueue atq; AutoTaskQueue atq;
nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue(); nsRefPtr<MediaTaskQueue> queue = atq.TaskQueue();

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

@ -10,7 +10,7 @@ UNIFIED_SOURCES += [
'TestGMPCrossOrigin.cpp', 'TestGMPCrossOrigin.cpp',
'TestGMPRemoveAndDelete.cpp', 'TestGMPRemoveAndDelete.cpp',
'TestIntervalSet.cpp', 'TestIntervalSet.cpp',
'TestMediaPromise.cpp', 'TestMozPromise.cpp',
'TestMP3Demuxer.cpp', 'TestMP3Demuxer.cpp',
'TestMP4Demuxer.cpp', 'TestMP4Demuxer.cpp',
# 'TestMP4Reader.cpp', disabled so we can turn check tests back on (bug 1175752) # 'TestMP4Reader.cpp', disabled so we can turn check tests back on (bug 1175752)

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

@ -206,7 +206,7 @@ private:
int64_t GetReaderAudioTime(int64_t aTime) const; int64_t GetReaderAudioTime(int64_t aTime) const;
int64_t GetReaderVideoTime(int64_t aTime) const; int64_t GetReaderVideoTime(int64_t aTime) const;
// Will reject the MediaPromise with END_OF_STREAM if mediasource has ended // Will reject the MozPromise with END_OF_STREAM if mediasource has ended
// or with WAIT_FOR_DATA otherwise. // or with WAIT_FOR_DATA otherwise.
void CheckForWaitOrEndOfStream(MediaData::Type aType, int64_t aTime /* microseconds */); void CheckForWaitOrEndOfStream(MediaData::Type aType, int64_t aTime /* microseconds */);
@ -234,15 +234,15 @@ private:
nsRefPtr<TrackBuffer> mAudioTrack; nsRefPtr<TrackBuffer> mAudioTrack;
nsRefPtr<TrackBuffer> mVideoTrack; nsRefPtr<TrackBuffer> mVideoTrack;
MediaPromiseRequestHolder<AudioDataPromise> mAudioRequest; MozPromiseRequestHolder<AudioDataPromise> mAudioRequest;
MediaPromiseRequestHolder<VideoDataPromise> mVideoRequest; MozPromiseRequestHolder<VideoDataPromise> mVideoRequest;
MediaPromiseHolder<AudioDataPromise> mAudioPromise; MozPromiseHolder<AudioDataPromise> mAudioPromise;
MediaPromiseHolder<VideoDataPromise> mVideoPromise; MozPromiseHolder<VideoDataPromise> mVideoPromise;
MediaPromiseHolder<WaitForDataPromise> mAudioWaitPromise; MozPromiseHolder<WaitForDataPromise> mAudioWaitPromise;
MediaPromiseHolder<WaitForDataPromise> mVideoWaitPromise; MozPromiseHolder<WaitForDataPromise> mVideoWaitPromise;
MediaPromiseHolder<WaitForDataPromise>& WaitPromise(MediaData::Type aType) MozPromiseHolder<WaitForDataPromise>& WaitPromise(MediaData::Type aType)
{ {
return aType == MediaData::AUDIO_DATA ? mAudioWaitPromise : mVideoWaitPromise; return aType == MediaData::AUDIO_DATA ? mAudioWaitPromise : mVideoWaitPromise;
} }
@ -257,9 +257,9 @@ private:
bool mForceVideoDecodeAhead; bool mForceVideoDecodeAhead;
MediaPromiseRequestHolder<SeekPromise> mAudioSeekRequest; MozPromiseRequestHolder<SeekPromise> mAudioSeekRequest;
MediaPromiseRequestHolder<SeekPromise> mVideoSeekRequest; MozPromiseRequestHolder<SeekPromise> mVideoSeekRequest;
MediaPromiseHolder<SeekPromise> mSeekPromise; MozPromiseHolder<SeekPromise> mSeekPromise;
// Temporary seek information while we wait for the data // Temporary seek information while we wait for the data
// to be added to the track buffer. // to be added to the track buffer.
@ -281,7 +281,7 @@ private:
bool mHasEssentialTrackBuffers; bool mHasEssentialTrackBuffers;
void ContinueShutdown(); void ContinueShutdown();
MediaPromiseHolder<ShutdownPromise> mMediaSourceShutdownPromise; MozPromiseHolder<ShutdownPromise> mMediaSourceShutdownPromise;
#ifdef MOZ_FMP4 #ifdef MOZ_FMP4
nsRefPtr<SharedDecoderManager> mSharedDecoderManager; nsRefPtr<SharedDecoderManager> mSharedDecoderManager;
#endif #endif

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

@ -7,7 +7,7 @@
#ifndef mozilla_dom_SourceBuffer_h_ #ifndef mozilla_dom_SourceBuffer_h_
#define mozilla_dom_SourceBuffer_h_ #define mozilla_dom_SourceBuffer_h_
#include "MediaPromise.h" #include "MozPromise.h"
#include "MediaSource.h" #include "MediaSource.h"
#include "js/RootingAPI.h" #include "js/RootingAPI.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
@ -195,7 +195,7 @@ private:
uint32_t mUpdateID; uint32_t mUpdateID;
int64_t mReportedOffset; int64_t mReportedOffset;
MediaPromiseRequestHolder<SourceBufferContentManager::AppendPromise> mPendingAppend; MozPromiseRequestHolder<SourceBufferContentManager::AppendPromise> mPendingAppend;
const nsCString mType; const nsCString mType;
}; };

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

@ -8,7 +8,7 @@
#define MOZILLA_SOURCEBUFFERCONTENTMANAGER_H_ #define MOZILLA_SOURCEBUFFERCONTENTMANAGER_H_
#include "MediaData.h" #include "MediaData.h"
#include "MediaPromise.h" #include "MozPromise.h"
#include "MediaSourceDecoder.h" #include "MediaSourceDecoder.h"
#include "SourceBuffer.h" #include "SourceBuffer.h"
#include "TimeUnits.h" #include "TimeUnits.h"
@ -23,7 +23,7 @@ class SourceBufferContentManager {
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SourceBufferContentManager); NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SourceBufferContentManager);
typedef MediaPromise<bool, nsresult, /* IsExclusive = */ true> AppendPromise; typedef MozPromise<bool, nsresult, /* IsExclusive = */ true> AppendPromise;
typedef AppendPromise RangeRemovalPromise; typedef AppendPromise RangeRemovalPromise;
static already_AddRefed<SourceBufferContentManager> static already_AddRefed<SourceBufferContentManager>

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

@ -1093,7 +1093,7 @@ TrackBuffer::AbortAppendData()
RemoveDecoder(current); RemoveDecoder(current);
} }
// The SourceBuffer would have disconnected its promise. // The SourceBuffer would have disconnected its promise.
// However we must ensure that the MediaPromiseHolder handle all pending // However we must ensure that the MozPromiseHolder handle all pending
// promises. // promises.
mInitializationPromise.RejectIfExists(NS_ERROR_ABORT, __func__); mInitializationPromise.RejectIfExists(NS_ERROR_ABORT, __func__);
} }

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

@ -138,7 +138,7 @@ private:
// Queue on the parent's decoder task queue a call to NotifyDataRemoved. // Queue on the parent's decoder task queue a call to NotifyDataRemoved.
void NotifyReaderDataRemoved(MediaDecoderReader* aReader); void NotifyReaderDataRemoved(MediaDecoderReader* aReader);
typedef MediaPromise<bool, nsresult, /* IsExclusive = */ true> BufferedRangesUpdatedPromise; typedef MozPromise<bool, nsresult, /* IsExclusive = */ true> BufferedRangesUpdatedPromise;
nsRefPtr<BufferedRangesUpdatedPromise> UpdateBufferedRanges(Interval<int64_t> aByteRange, bool aNotifyParent); nsRefPtr<BufferedRangesUpdatedPromise> UpdateBufferedRanges(Interval<int64_t> aByteRange, bool aNotifyParent);
// Queue execution of InitializeDecoder on mTaskQueue. // Queue execution of InitializeDecoder on mTaskQueue.
@ -226,15 +226,15 @@ private:
MediaInfo mInfo; MediaInfo mInfo;
void ContinueShutdown(); void ContinueShutdown();
MediaPromiseHolder<ShutdownPromise> mShutdownPromise; MozPromiseHolder<ShutdownPromise> mShutdownPromise;
bool mDecoderPerSegment; bool mDecoderPerSegment;
bool mShutdown; bool mShutdown;
MediaPromiseHolder<AppendPromise> mInitializationPromise; MozPromiseHolder<AppendPromise> mInitializationPromise;
// Track our request for metadata from the reader. // Track our request for metadata from the reader.
MediaPromiseRequestHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest; MozPromiseRequestHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest;
MediaPromiseHolder<RangeRemovalPromise> mRangeRemovalPromise; MozPromiseHolder<RangeRemovalPromise> mRangeRemovalPromise;
Interval<int64_t> mLastAppendRange; Interval<int64_t> mLastAppendRange;

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

@ -34,7 +34,7 @@ using dom::SourceBufferAppendMode;
class TrackBuffersManager : public SourceBufferContentManager { class TrackBuffersManager : public SourceBufferContentManager {
public: public:
typedef MediaPromise<bool, nsresult, /* IsExclusive = */ true> CodedFrameProcessingPromise; typedef MozPromise<bool, nsresult, /* IsExclusive = */ true> CodedFrameProcessingPromise;
typedef TrackInfo::TrackType TrackType; typedef TrackInfo::TrackType TrackType;
typedef MediaData::Type MediaType; typedef MediaData::Type MediaType;
typedef nsTArray<nsRefPtr<MediaRawData>> TrackBuffer; typedef nsTArray<nsRefPtr<MediaRawData>> TrackBuffer;
@ -166,7 +166,7 @@ private:
void OnDemuxerInitDone(nsresult); void OnDemuxerInitDone(nsresult);
void OnDemuxerInitFailed(DemuxerFailureReason aFailure); void OnDemuxerInitFailed(DemuxerFailureReason aFailure);
MediaPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest; MozPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest;
bool mEncrypted; bool mEncrypted;
void OnDemuxFailed(TrackType aTrack, DemuxerFailureReason aFailure); void OnDemuxFailed(TrackType aTrack, DemuxerFailureReason aFailure);
@ -221,7 +221,7 @@ private:
// buffer. // buffer.
bool mNeedRandomAccessPoint; bool mNeedRandomAccessPoint;
nsRefPtr<MediaTrackDemuxer> mDemuxer; nsRefPtr<MediaTrackDemuxer> mDemuxer;
MediaPromiseRequestHolder<MediaTrackDemuxer::SamplesPromise> mDemuxRequest; MozPromiseRequestHolder<MediaTrackDemuxer::SamplesPromise> mDemuxRequest;
// If set, position where the next contiguous frame will be inserted. // If set, position where the next contiguous frame will be inserted.
// If a discontinuity is detected, it will be unset and recalculated upon // If a discontinuity is detected, it will be unset and recalculated upon
// the next insertion. // the next insertion.
@ -272,10 +272,10 @@ private:
void UpdateBufferedRanges(); void UpdateBufferedRanges();
void RejectProcessing(nsresult aRejectValue, const char* aName); void RejectProcessing(nsresult aRejectValue, const char* aName);
void ResolveProcessing(bool aResolveValue, const char* aName); void ResolveProcessing(bool aResolveValue, const char* aName);
MediaPromiseRequestHolder<CodedFrameProcessingPromise> mProcessingRequest; MozPromiseRequestHolder<CodedFrameProcessingPromise> mProcessingRequest;
MediaPromiseHolder<CodedFrameProcessingPromise> mProcessingPromise; MozPromiseHolder<CodedFrameProcessingPromise> mProcessingPromise;
MediaPromiseHolder<AppendPromise> mAppendPromise; MozPromiseHolder<AppendPromise> mAppendPromise;
// Set to true while SegmentParserLoop is running. This is used for diagnostic // Set to true while SegmentParserLoop is running. This is used for diagnostic
// purposes only. We can't rely on mAppendPromise to be empty as it is only // purposes only. We can't rely on mAppendPromise to be empty as it is only
// cleared in a follow up task. // cleared in a follow up task.

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

@ -124,7 +124,6 @@ EXPORTS += [
'MediaFormatReader.h', 'MediaFormatReader.h',
'MediaInfo.h', 'MediaInfo.h',
'MediaMetadataManager.h', 'MediaMetadataManager.h',
'MediaPromise.h',
'MediaQueue.h', 'MediaQueue.h',
'MediaRecorder.h', 'MediaRecorder.h',
'MediaResource.h', 'MediaResource.h',
@ -134,6 +133,7 @@ EXPORTS += [
'MediaTimer.h', 'MediaTimer.h',
'MediaTrack.h', 'MediaTrack.h',
'MediaTrackList.h', 'MediaTrackList.h',
'MozPromise.h',
'MP3Decoder.h', 'MP3Decoder.h',
'MP3Demuxer.h', 'MP3Demuxer.h',
'MP3FrameParser.h', 'MP3FrameParser.h',

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

@ -146,10 +146,10 @@ private:
// mLock // mLock
SeekTarget mSeekTarget; SeekTarget mSeekTarget;
// MediaPromise of current seek. // MozPromise of current seek.
// Used in main thread and offload callback thread, protected by Mutex // Used in main thread and offload callback thread, protected by Mutex
// mLock // mLock
MediaPromiseHolder<MediaDecoder::SeekPromise> mSeekPromise; MozPromiseHolder<MediaDecoder::SeekPromise> mSeekPromise;
// Positions obtained from offlaoded tracks (DSP) // Positions obtained from offlaoded tracks (DSP)
// Used in main thread and offload callback thread, protected by Mutex // Used in main thread and offload callback thread, protected by Mutex

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

@ -178,10 +178,10 @@ protected:
android::sp<android::MediaExtractor> mExtractor; android::sp<android::MediaExtractor> mExtractor;
MediaPromiseHolder<MediaDecoderReader::MetadataPromise> mMetadataPromise; MozPromiseHolder<MediaDecoderReader::MetadataPromise> mMetadataPromise;
// XXX Remove after bug 1168008 land. // XXX Remove after bug 1168008 land.
MediaPromiseRequestHolder<MediaResourcePromise> mMediaResourceRequest; MozPromiseRequestHolder<MediaResourcePromise> mMediaResourceRequest;
MediaPromiseHolder<MediaResourcePromise> mMediaResourcePromise; MozPromiseHolder<MediaResourcePromise> mMediaResourcePromise;
private: private:
@ -216,7 +216,7 @@ private:
{ {
AudioTrack(); AudioTrack();
// Protected by mTrackMonitor. // Protected by mTrackMonitor.
MediaPromiseHolder<AudioDataPromise> mAudioPromise; MozPromiseHolder<AudioDataPromise> mAudioPromise;
private: private:
// Forbidden // Forbidden
@ -238,7 +238,7 @@ private:
nsIntRect mPictureRect; nsIntRect mPictureRect;
gfx::IntRect mRelativePictureRect; gfx::IntRect mRelativePictureRect;
// Protected by mTrackMonitor. // Protected by mTrackMonitor.
MediaPromiseHolder<VideoDataPromise> mVideoPromise; MozPromiseHolder<VideoDataPromise> mVideoPromise;
nsRefPtr<MediaTaskQueue> mReleaseBufferTaskQueue; nsRefPtr<MediaTaskQueue> mReleaseBufferTaskQueue;
private: private:

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

@ -24,7 +24,7 @@ class AbstractMediaDecoder;
class MediaOmxCommonReader : public MediaDecoderReader class MediaOmxCommonReader : public MediaDecoderReader
{ {
public: public:
typedef MediaPromise<bool /* aIgnored */, bool /* aIgnored */, /* IsExclusive = */ true> MediaResourcePromise; typedef MozPromise<bool /* aIgnored */, bool /* aIgnored */, /* IsExclusive = */ true> MediaResourcePromise;
MediaOmxCommonReader(AbstractMediaDecoder* aDecoder); MediaOmxCommonReader(AbstractMediaDecoder* aDecoder);

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

@ -44,11 +44,11 @@ class MediaOmxReader : public MediaOmxCommonReader
// If mIsShutdown is false, and mShutdownMutex is held, then // If mIsShutdown is false, and mShutdownMutex is held, then
// AbstractMediaDecoder::mDecoder will be non-null. // AbstractMediaDecoder::mDecoder will be non-null.
bool mIsShutdown; bool mIsShutdown;
MediaPromiseHolder<MediaDecoderReader::MetadataPromise> mMetadataPromise; MozPromiseHolder<MediaDecoderReader::MetadataPromise> mMetadataPromise;
MediaPromiseRequestHolder<MediaResourcePromise> mMediaResourceRequest; MozPromiseRequestHolder<MediaResourcePromise> mMediaResourceRequest;
MediaPromiseHolder<MediaDecoderReader::SeekPromise> mSeekPromise; MozPromiseHolder<MediaDecoderReader::SeekPromise> mSeekPromise;
MediaPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mSeekRequest; MozPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mSeekRequest;
protected: protected:
android::sp<android::OmxDecoder> mOmxDecoder; android::sp<android::OmxDecoder> mOmxDecoder;
android::sp<android::MediaExtractor> mExtractor; android::sp<android::MediaExtractor> mExtractor;
@ -113,7 +113,7 @@ public:
android::sp<android::MediaSource> GetAudioOffloadTrack(); android::sp<android::MediaSource> GetAudioOffloadTrack();
// This method is intended only for private use but public only for // This method is intended only for private use but public only for
// MediaPromise::InvokeCallbackMethod(). // MozPromise::InvokeCallbackMethod().
void ReleaseDecoder(); void ReleaseDecoder();
private: private:

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

@ -121,7 +121,7 @@ class OmxDecoder : public OMXCodecProxy::CodecResourceListener {
// 'true' if a read from the audio stream was done while reading the metadata // 'true' if a read from the audio stream was done while reading the metadata
bool mAudioMetadataRead; bool mAudioMetadataRead;
mozilla::MediaPromiseHolder<MediaResourcePromise> mMediaResourcePromise; mozilla::MozPromiseHolder<MediaResourcePromise> mMediaResourcePromise;
void ReleaseVideoBuffer(); void ReleaseVideoBuffer();
void ReleaseAudioBuffer(); void ReleaseAudioBuffer();

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

@ -17,7 +17,7 @@
namespace mozilla { namespace mozilla {
typedef MediaPromiseRequestHolder<CDMProxy::DecryptPromise> DecryptPromiseRequestHolder; typedef MozPromiseRequestHolder<CDMProxy::DecryptPromise> DecryptPromiseRequestHolder;
static PLDHashOperator static PLDHashOperator
DropDecryptPromises(MediaRawData* aKey, DropDecryptPromises(MediaRawData* aKey,