mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Backed out changeset be04f96bf78b (bug 1347791)
This commit is contained in:
parent
771b1095ef
commit
b5eb8a2a1b
@ -184,6 +184,9 @@ AudioChannelAgent::InitInternal(nsPIDOMWindowInner* aWindow,
|
|||||||
mCallback = aCallback;
|
mCallback = aCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
||||||
|
service->NotifyCreatedNewAgent(this);
|
||||||
|
|
||||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||||
("AudioChannelAgent, InitInternal, this = %p, type = %d, "
|
("AudioChannelAgent, InitInternal, this = %p, type = %d, "
|
||||||
"owner = %p, hasCallback = %d\n", this, mAudioChannelType,
|
"owner = %p, hasCallback = %d\n", this, mAudioChannelType,
|
||||||
|
@ -365,6 +365,19 @@ AudioChannelService::~AudioChannelService()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioChannelService::NotifyCreatedNewAgent(AudioChannelAgent* aAgent)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aAgent);
|
||||||
|
|
||||||
|
nsCOMPtr<nsPIDOMWindowOuter> window = aAgent->Window();
|
||||||
|
if (!window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window->NotifyCreatedNewMediaComponent();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
||||||
AudibleState aAudible)
|
AudibleState aAudible)
|
||||||
|
@ -206,6 +206,8 @@ public:
|
|||||||
void ChildStatusReceived(uint64_t aChildID, bool aTelephonyChannel,
|
void ChildStatusReceived(uint64_t aChildID, bool aTelephonyChannel,
|
||||||
bool aContentOrNormalChannel, bool aAnyChannel);
|
bool aContentOrNormalChannel, bool aAnyChannel);
|
||||||
|
|
||||||
|
void NotifyCreatedNewAgent(AudioChannelAgent* aAgent);
|
||||||
|
|
||||||
void NotifyMediaResumedFromBlock(nsPIDOMWindowOuter* aWindow);
|
void NotifyMediaResumedFromBlock(nsPIDOMWindowOuter* aWindow);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1007,7 +1007,8 @@ nsPIDOMWindow<T>::nsPIDOMWindow(nsPIDOMWindowOuter *aOuterWindow)
|
|||||||
// Make sure no actual window ends up with mWindowID == 0
|
// Make sure no actual window ends up with mWindowID == 0
|
||||||
mWindowID(NextWindowID()), mHasNotifiedGlobalCreated(false),
|
mWindowID(NextWindowID()), mHasNotifiedGlobalCreated(false),
|
||||||
mMarkedCCGeneration(0), mServiceWorkersTestingEnabled(false),
|
mMarkedCCGeneration(0), mServiceWorkersTestingEnabled(false),
|
||||||
mLargeAllocStatus(LargeAllocStatus::NONE)
|
mLargeAllocStatus(LargeAllocStatus::NONE),
|
||||||
|
mShouldResumeOnFirstActiveMediaComponent(false)
|
||||||
{
|
{
|
||||||
if (aOuterWindow) {
|
if (aOuterWindow) {
|
||||||
mTimeoutManager =
|
mTimeoutManager =
|
||||||
@ -4416,6 +4417,20 @@ nsPIDOMWindowInner::IsRunningTimeout()
|
|||||||
return TimeoutManager().IsRunningTimeout();
|
return TimeoutManager().IsRunningTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsPIDOMWindowOuter::NotifyCreatedNewMediaComponent()
|
||||||
|
{
|
||||||
|
// We would only active media component when there is any alive one.
|
||||||
|
mShouldResumeOnFirstActiveMediaComponent = true;
|
||||||
|
|
||||||
|
// If the document is already on the foreground but the suspend state is still
|
||||||
|
// suspend-block, that means the media component was created after calling
|
||||||
|
// MaybeActiveMediaComponents, so the window's suspend state doesn't be
|
||||||
|
// changed yet. Therefore, we need to call it again, because the state is only
|
||||||
|
// changed after there exists alive media within the window.
|
||||||
|
MaybeActiveMediaComponents();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsPIDOMWindowOuter::MaybeActiveMediaComponents()
|
nsPIDOMWindowOuter::MaybeActiveMediaComponents()
|
||||||
{
|
{
|
||||||
@ -4423,7 +4438,21 @@ nsPIDOMWindowOuter::MaybeActiveMediaComponents()
|
|||||||
return mOuterWindow->MaybeActiveMediaComponents();
|
return mOuterWindow->MaybeActiveMediaComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mMediaSuspend != nsISuspendedTypes::SUSPENDED_BLOCK) {
|
// Resume the media when the tab was blocked and the tab already has
|
||||||
|
// alive media components.
|
||||||
|
if (!mShouldResumeOnFirstActiveMediaComponent ||
|
||||||
|
mMediaSuspend != nsISuspendedTypes::SUSPENDED_BLOCK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsPIDOMWindowInner> inner = GetCurrentInnerWindow();
|
||||||
|
if (!inner) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the document is not visible, don't need to resume it.
|
||||||
|
nsCOMPtr<nsIDocument> doc = inner->GetExtantDoc();
|
||||||
|
if (!doc || doc->Hidden()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,6 +746,10 @@ protected:
|
|||||||
bool mServiceWorkersTestingEnabled;
|
bool mServiceWorkersTestingEnabled;
|
||||||
|
|
||||||
mozilla::dom::LargeAllocStatus mLargeAllocStatus; // Outer window only
|
mozilla::dom::LargeAllocStatus mLargeAllocStatus; // Outer window only
|
||||||
|
|
||||||
|
// When there is any created alive media component, we can consider to resume
|
||||||
|
// the media content in the window.
|
||||||
|
bool mShouldResumeOnFirstActiveMediaComponent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NS_PIDOMWINDOWINNER_IID \
|
#define NS_PIDOMWINDOWINNER_IID \
|
||||||
@ -994,6 +998,7 @@ public:
|
|||||||
float GetAudioVolume() const;
|
float GetAudioVolume() const;
|
||||||
nsresult SetAudioVolume(float aVolume);
|
nsresult SetAudioVolume(float aVolume);
|
||||||
|
|
||||||
|
void NotifyCreatedNewMediaComponent();
|
||||||
void MaybeActiveMediaComponents();
|
void MaybeActiveMediaComponents();
|
||||||
|
|
||||||
void SetServiceWorkersTestingEnabled(bool aEnabled);
|
void SetServiceWorkersTestingEnabled(bool aEnabled);
|
||||||
|
Loading…
Reference in New Issue
Block a user