Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r=roc

MozReview-Commit-ID: DwDHDE7SLxY

--HG--
extra : rebase_source : 73f74260d8b62bb4838ab5a5c4b2153a251c5d95
This commit is contained in:
Andreas Pehrson 2016-01-14 11:38:08 +08:00
Родитель f2fb4ac630
Коммит ba233fd622
2 изменённых файлов: 43 добавлений и 1 удалений

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

@ -4191,6 +4191,21 @@ void HTMLMediaElement::NotifyDecoderPrincipalChanged()
ms->mStream->SetCORSMode(mCORSMode);
ms->mStream->CombineWithPrincipal(principal);
}
for (DecoderPrincipalChangeObserver* observer :
mDecoderPrincipalChangeObservers) {
observer->NotifyDecoderPrincipalChanged();
}
}
void HTMLMediaElement::AddDecoderPrincipalChangeObserver(DecoderPrincipalChangeObserver* aObserver)
{
mDecoderPrincipalChangeObservers.AppendElement(aObserver);
}
bool HTMLMediaElement::RemoveDecoderPrincipalChangeObserver(DecoderPrincipalChangeObserver* aObserver)
{
return mDecoderPrincipalChangeObservers.RemoveElement(aObserver);
}
void HTMLMediaElement::UpdateMediaSize(const nsIntSize& aSize)

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

@ -265,7 +265,30 @@ public:
already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
// called to notify that the principal of the decoder's media resource has changed.
virtual void NotifyDecoderPrincipalChanged() final override;
void NotifyDecoderPrincipalChanged() final override;
// An interface for observing principal changes on the media elements
// MediaDecoder.
class DecoderPrincipalChangeObserver
{
public:
virtual void NotifyDecoderPrincipalChanged() = 0;
};
/**
* Add a DecoderPrincipalChangeObserver to this media element.
*
* Ownership of the DecoderPrincipalChangeObserver remains with the caller,
* and it's the caller's responsibility to remove the observer before it dies.
*/
void AddDecoderPrincipalChangeObserver(DecoderPrincipalChangeObserver* aObserver);
/**
* Remove an added DecoderPrincipalChangeObserver from this media element.
*
* Returns true if it was successfully removed.
*/
bool RemoveDecoderPrincipalChangeObserver(DecoderPrincipalChangeObserver* aObserver);
// Update the visual size of the media. Called from the decoder on the
// main thread when/if the size changes.
@ -1111,6 +1134,10 @@ protected:
// At most one of mDecoder and mSrcStream can be non-null.
RefPtr<MediaDecoder> mDecoder;
// Observers listening to changes to the mDecoder principal.
// Used by streams captured from this element.
nsTArray<DecoderPrincipalChangeObserver*> mDecoderPrincipalChangeObservers;
// State-watching manager.
WatchManager<HTMLMediaElement> mWatchManager;