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
This commit is contained in:
JW Wang
2017-08-04 15:29:55 +08:00
parent ba4e1416b8
commit 5df0f2fb77
4 changed files with 21 additions and 9 deletions

View File

@@ -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;
}
}