Bug 1224973 - Part 2: Set MediaDecoder visibility via NotifyOwnerActivityChanged. r=cpearce,jwwang

Make MediaDecoder::SetElementVisibility private.

MozReview-Commit-ID: GjCuSNPalkE
This commit is contained in:
Dan Glastonbury 2016-04-12 15:48:06 +10:00 коммит произвёл Dan Glastonbury
Родитель d4be2cf480
Коммит 9f98a19f8c
4 изменённых файлов: 18 добавлений и 10 удалений

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

@ -2774,7 +2774,7 @@ nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParen
if (mDecoder) { if (mDecoder) {
// When the MediaElement is binding to tree, the dormant status is // When the MediaElement is binding to tree, the dormant status is
// aligned to document's hidden status. // aligned to document's hidden status.
mDecoder->NotifyOwnerActivityChanged(); mDecoder->NotifyOwnerActivityChanged(!IsHidden());
} }
return rv; return rv;
@ -2872,7 +2872,7 @@ void HTMLMediaElement::UnbindFromTree(bool aDeep,
if (mDecoder) { if (mDecoder) {
MOZ_ASSERT(IsHidden()); MOZ_ASSERT(IsHidden());
mDecoder->NotifyOwnerActivityChanged(); mDecoder->NotifyOwnerActivityChanged(false);
} }
} }
@ -4532,10 +4532,8 @@ void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
bool bool
HTMLMediaElement::NotifyOwnerDocumentActivityChangedInternal() HTMLMediaElement::NotifyOwnerDocumentActivityChangedInternal()
{ {
nsIDocument* ownerDoc = OwnerDoc();
if (mDecoder && !IsBeingDestroyed()) { if (mDecoder && !IsBeingDestroyed()) {
mDecoder->SetElementVisibility(!ownerDoc->Hidden()); mDecoder->NotifyOwnerActivityChanged(!IsHidden());
mDecoder->NotifyOwnerActivityChanged();
} }
bool pauseElement = !IsActive(); bool pauseElement = !IsActive();

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

@ -287,7 +287,7 @@ MediaDecoder::ResourceCallback::NotifyBytesConsumed(int64_t aBytes,
} }
void void
MediaDecoder::NotifyOwnerActivityChanged() MediaDecoder::NotifyOwnerActivityChanged(bool aIsVisible)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -295,6 +295,8 @@ MediaDecoder::NotifyOwnerActivityChanged()
return; return;
} }
SetElementVisibility(aIsVisible);
UpdateDormantState(false /* aDormantTimeout */, false /* aActivity */); UpdateDormantState(false /* aDormantTimeout */, false /* aActivity */);
// Start dormant timer if necessary // Start dormant timer if necessary
StartDormantTimer(); StartDormantTimer();
@ -1365,6 +1367,13 @@ MediaDecoder::DurationChanged()
} }
} }
void
MediaDecoder::SetElementVisibility(bool aIsVisible)
{
MOZ_ASSERT(NS_IsMainThread());
mIsVisible = aIsVisible;
}
void void
MediaDecoder::UpdateEstimatedMediaDuration(int64_t aDuration) MediaDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
{ {

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

@ -180,7 +180,7 @@ public:
// Dormant state is a state to free all scarce media resources // Dormant state is a state to free all scarce media resources
// (like hw video codec), did not decoding and stay dormant. // (like hw video codec), did not decoding and stay dormant.
// It is used to share scarece media resources in system. // It is used to share scarece media resources in system.
virtual void NotifyOwnerActivityChanged(); virtual void NotifyOwnerActivityChanged(bool aIsVisible);
void UpdateDormantState(bool aDormantTimeout, bool aActivity); void UpdateDormantState(bool aDormantTimeout, bool aActivity);
@ -250,9 +250,6 @@ protected:
void UpdateEstimatedMediaDuration(int64_t aDuration) override; void UpdateEstimatedMediaDuration(int64_t aDuration) override;
public: public:
// Called from HTMLMediaElement when owner document activity changes
virtual void SetElementVisibility(bool aIsVisible) {}
// Set a flag indicating whether random seeking is supported // Set a flag indicating whether random seeking is supported
void SetMediaSeekable(bool aMediaSeekable); void SetMediaSeekable(bool aMediaSeekable);
// Set a flag indicating whether seeking is supported only in buffered ranges // Set a flag indicating whether seeking is supported only in buffered ranges
@ -368,6 +365,9 @@ private:
void SetAudioChannel(dom::AudioChannel aChannel) { mAudioChannel = aChannel; } void SetAudioChannel(dom::AudioChannel aChannel) { mAudioChannel = aChannel; }
dom::AudioChannel GetAudioChannel() { return mAudioChannel; } dom::AudioChannel GetAudioChannel() { return mAudioChannel; }
// Called from HTMLMediaElement when owner document activity changes
virtual void SetElementVisibility(bool aIsVisible);
/****** /******
* The following methods must only be called on the main * The following methods must only be called on the main
* thread. * thread.

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

@ -252,6 +252,7 @@ void
MediaOmxCommonDecoder::SetElementVisibility(bool aIsVisible) MediaOmxCommonDecoder::SetElementVisibility(bool aIsVisible)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MediaDecoder::SetElementVisibility(aIsVisible);
if (mAudioOffloadPlayer) { if (mAudioOffloadPlayer) {
mAudioOffloadPlayer->SetElementVisibility(aIsVisible); mAudioOffloadPlayer->SetElementVisibility(aIsVisible);
} }