Bug 813209 - Refactor MediaResource into BaseMediaResource so that we can base the implementation of BufferMediaSource on top of MediaSource; r=cpearce

This refactoring is needed for the introduction of the BufferMediaResource class.

--HG--
extra : rebase_source : e4b5016e9b947948799f1b8975b23a3dd685a366
This commit is contained in:
Ehsan Akhgari 2012-11-16 20:31:53 -08:00
Родитель 3803556ae5
Коммит 09c0f1a536
2 изменённых файлов: 21 добавлений и 14 удалений

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

@ -49,7 +49,7 @@ namespace mozilla {
ChannelMediaResource::ChannelMediaResource(MediaDecoder* aDecoder,
nsIChannel* aChannel, nsIURI* aURI)
: MediaResource(aDecoder, aChannel, aURI),
: BaseMediaResource(aDecoder, aChannel, aURI),
mOffset(0), mSuspendCount(0),
mReopenOnError(false), mIgnoreClose(false),
mCacheStream(this),
@ -1153,11 +1153,11 @@ ChannelMediaResource::PossiblyResume()
}
}
class FileMediaResource : public MediaResource
class FileMediaResource : public BaseMediaResource
{
public:
FileMediaResource(MediaDecoder* aDecoder, nsIChannel* aChannel, nsIURI* aURI) :
MediaResource(aDecoder, aChannel, aURI),
BaseMediaResource(aDecoder, aChannel, aURI),
mSize(-1),
mLock("FileMediaResource.mLock"),
mSizeInitialized(false)
@ -1514,7 +1514,7 @@ MediaResource::Create(MediaDecoder* aDecoder, nsIChannel* aChannel)
return new ChannelMediaResource(aDecoder, aChannel, uri);
}
void MediaResource::MoveLoadsToBackground() {
void BaseMediaResource::MoveLoadsToBackground() {
NS_ASSERTION(!mLoadInBackground, "Why are you calling this more than once?");
mLoadInBackground = true;
if (!mChannel) {
@ -1545,7 +1545,7 @@ void MediaResource::MoveLoadsToBackground() {
}
}
void MediaResource::ModifyLoadFlags(nsLoadFlags aFlags)
void BaseMediaResource::ModifyLoadFlags(nsLoadFlags aFlags)
{
nsCOMPtr<nsILoadGroup> loadGroup;
DebugOnly<nsresult> rv = mChannel->GetLoadGroup(getter_AddRefs(loadGroup));

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

@ -146,14 +146,11 @@ public:
class MediaResource
{
public:
virtual ~MediaResource()
{
MOZ_COUNT_DTOR(MediaResource);
}
virtual ~MediaResource() {}
// The following can be called on the main thread only:
// Get the URI
nsIURI* URI() const { return mURI; }
virtual nsIURI* URI() const { return nullptr; }
// Close the resource, stop any listeners, channels, etc.
// Cancels any currently blocking Read request and forces that request to
// return an error.
@ -227,7 +224,7 @@ public:
// Moves any existing channel loads into the background, so that they don't
// block the load event. Any new loads initiated (for example to seek)
// will also be in the background.
void MoveLoadsToBackground();
virtual void MoveLoadsToBackground() {}
// Ensures that the value returned by IsSuspendedByCache below is up to date
// (i.e. the cache has examined this stream at least once).
virtual void EnsureCacheUpToDate() {}
@ -307,15 +304,25 @@ public:
* aRanges is being used.
*/
virtual nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges) = 0;
};
class BaseMediaResource : public MediaResource {
public:
virtual nsIURI* URI() const { return mURI; }
virtual void MoveLoadsToBackground();
protected:
MediaResource(MediaDecoder* aDecoder, nsIChannel* aChannel, nsIURI* aURI) :
BaseMediaResource(MediaDecoder* aDecoder, nsIChannel* aChannel, nsIURI* aURI) :
mDecoder(aDecoder),
mChannel(aChannel),
mURI(aURI),
mLoadInBackground(false)
{
MOZ_COUNT_CTOR(MediaResource);
MOZ_COUNT_CTOR(BaseMediaResource);
}
virtual ~BaseMediaResource()
{
MOZ_COUNT_DTOR(BaseMediaResource);
}
// Set the request's load flags to aFlags. If the request is part of a
@ -349,7 +356,7 @@ protected:
* All synchronization is performed by MediaCacheStream; all off-main-
* thread operations are delegated directly to that object.
*/
class ChannelMediaResource : public MediaResource
class ChannelMediaResource : public BaseMediaResource
{
public:
ChannelMediaResource(MediaDecoder* aDecoder, nsIChannel* aChannel, nsIURI* aURI);