Bug 1347791 - part2 : the tab would always be resumed when it goes to foreground first time. r=baku

Since now we move the block/resume logic to front-end side, we can remove
the changing from bug1319771 and other related bugs which are used to ensure the
pinned tab should be blocked successfully after session restore.

MozReview-Commit-ID: Ixe7tOvCEhv

--HG--
extra : rebase_source : 4214c68b4c95df5c33bf1a68c9ffb84ee4c4d5aa
This commit is contained in:
Alastor Wu 2017-06-29 04:52:02 -07:00
parent ade6cb9314
commit 5ea418e1fe
5 changed files with 1 additions and 53 deletions

View File

@ -184,9 +184,6 @@ AudioChannelAgent::InitInternal(nsPIDOMWindowInner* aWindow,
mCallback = aCallback;
}
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
service->NotifyCreatedNewAgent(this);
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, InitInternal, this = %p, type = %d, "
"owner = %p, hasCallback = %d\n", this, mAudioChannelType,

View File

@ -322,19 +322,6 @@ AudioChannelService::~AudioChannelService()
{
}
void
AudioChannelService::NotifyCreatedNewAgent(AudioChannelAgent* aAgent)
{
MOZ_ASSERT(aAgent);
nsCOMPtr<nsPIDOMWindowOuter> window = aAgent->Window();
if (!window) {
return;
}
window->NotifyCreatedNewMediaComponent();
}
void
AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
AudibleState aAudible)

View File

@ -146,8 +146,6 @@ public:
static AudioChannel GetAudioChannel(const nsAString& aString);
static AudioChannel GetDefaultAudioChannel();
void NotifyCreatedNewAgent(AudioChannelAgent* aAgent);
void NotifyMediaResumedFromBlock(nsPIDOMWindowOuter* aWindow);
private:

View File

@ -1013,7 +1013,6 @@ nsPIDOMWindow<T>::nsPIDOMWindow(nsPIDOMWindowOuter *aOuterWindow)
mWindowID(NextWindowID()), mHasNotifiedGlobalCreated(false),
mMarkedCCGeneration(0), mServiceWorkersTestingEnabled(false),
mLargeAllocStatus(LargeAllocStatus::NONE),
mShouldResumeOnFirstActiveMediaComponent(false),
mHasTriedToCacheTopInnerWindow(false),
mNumOfIndexedDBDatabases(0)
{
@ -4491,20 +4490,6 @@ nsPIDOMWindowInner::HasActiveIndexedDBDatabases()
mNumOfIndexedDBDatabases > 0;
}
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
nsPIDOMWindowOuter::MaybeActiveMediaComponents()
{
@ -4512,21 +4497,7 @@ nsPIDOMWindowOuter::MaybeActiveMediaComponents()
return mOuterWindow->MaybeActiveMediaComponents();
}
// 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()) {
if (mMediaSuspend != nsISuspendedTypes::SUSPENDED_BLOCK) {
return;
}

View File

@ -761,10 +761,6 @@ protected:
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;
// mTopInnerWindow is only used on inner windows for tab-wise check by timeout
// throttling. It could be null.
nsCOMPtr<nsPIDOMWindowInner> mTopInnerWindow;
@ -1019,7 +1015,6 @@ public:
float GetAudioVolume() const;
nsresult SetAudioVolume(float aVolume);
void NotifyCreatedNewMediaComponent();
void MaybeActiveMediaComponents();
void SetServiceWorkersTestingEnabled(bool aEnabled);