зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1383628. P5 - move CanClone() from MediaResource to BaseMediaResource. r=gerald
1. we move clone related methods to BaseMediaResource which is the only cloneable sub-class of MediaResource. 2. add CanClone() to ChannelMediaDecoder to reduce the dependency on MediaResource for HTMLMediaElement. MediaResource should be internal details to MediaDecoder. MozReview-Commit-ID: Hl2nAiuyTO0 --HG-- extra : rebase_source : 43dd9ee33ef2ef2e9093eb6b264dc174379d61d2 extra : source : 978ded48a90f2c407c4545486243acabf492736a
This commit is contained in:
Родитель
163c6a8c8b
Коммит
b2d75fa057
|
@ -3744,9 +3744,11 @@ HTMLMediaElement::LookupMediaElementURITable(nsIURI* aURI)
|
|||
// Ditto for anything else that could cause us to send different headers.
|
||||
if (NS_SUCCEEDED(elem->NodePrincipal()->Equals(NodePrincipal(), &equal)) && equal &&
|
||||
elem->mCORSMode == mCORSMode) {
|
||||
NS_ASSERTION(elem->mDecoder && elem->mDecoder->GetResource(), "Decoder gone");
|
||||
MediaResource* resource = elem->mDecoder->GetResource();
|
||||
if (resource->CanClone()) {
|
||||
// See SetupDecoder() below. We only add a element to the table when
|
||||
// mDecoder is a ChannelMediaDecoder.
|
||||
auto decoder = static_cast<ChannelMediaDecoder*>(elem->mDecoder.get());
|
||||
NS_ASSERTION(decoder, "Decoder gone");
|
||||
if (decoder->CanClone()) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,6 +155,13 @@ ChannelMediaDecoder::ChannelMediaDecoder(MediaDecoderInit& aInit)
|
|||
mResourceCallback->Connect(this);
|
||||
}
|
||||
|
||||
bool
|
||||
ChannelMediaDecoder::CanClone()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
return mResource && mResource->CanClone();
|
||||
}
|
||||
|
||||
already_AddRefed<ChannelMediaDecoder>
|
||||
ChannelMediaDecoder::Clone(MediaDecoderInit& aInit)
|
||||
{
|
||||
|
|
|
@ -66,6 +66,8 @@ public:
|
|||
|
||||
void Shutdown() override;
|
||||
|
||||
bool CanClone();
|
||||
|
||||
// Create a new decoder of the same type as this one.
|
||||
already_AddRefed<ChannelMediaDecoder> Clone(MediaDecoderInit& aInit);
|
||||
|
||||
|
|
|
@ -174,12 +174,6 @@ public:
|
|||
virtual void Resume() = 0;
|
||||
// Get the current principal for the channel
|
||||
virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() = 0;
|
||||
// If this returns false, then we shouldn't try to clone this MediaResource
|
||||
// because its underlying resources are not suitable for reuse (e.g.
|
||||
// because the underlying connection has been lost, or this resource
|
||||
// just can't be safely cloned). If this returns true, CloneData could
|
||||
// still fail. If this returns false, CloneData should not be called.
|
||||
virtual bool CanClone() { return false; }
|
||||
|
||||
// These methods are called off the main thread.
|
||||
// The mode is initially MODE_PLAYBACK.
|
||||
|
@ -331,6 +325,13 @@ public:
|
|||
nsIChannel* aChannel,
|
||||
bool aIsPrivateBrowsing);
|
||||
|
||||
// If this returns false, then we shouldn't try to clone this MediaResource
|
||||
// because its underlying resources are not suitable for reuse (e.g.
|
||||
// because the underlying connection has been lost, or this resource
|
||||
// just can't be safely cloned). If this returns true, CloneData could
|
||||
// still fail. If this returns false, CloneData should not be called.
|
||||
virtual bool CanClone() { return false; }
|
||||
|
||||
// Create a new stream of the same type that refers to the same URI
|
||||
// with a new channel. Any cached data associated with the original
|
||||
// stream should be accessible in the new stream too.
|
||||
|
|
Загрузка…
Ссылка в новой задаче