mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-01 12:03:08 +00:00
Bug 1561715 - Part 3: Remove SchedulerGroup::IsBackground. r=smaug
Depends on D56745 Differential Revision: https://phabricator.services.mozilla.com/D56879 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
bdf7912139
commit
794b0068c3
@ -27,10 +27,7 @@ LinkedList<TabGroup>* TabGroup::sTabGroups = nullptr;
|
||||
TabGroup::TabGroup(bool aIsChrome)
|
||||
: mLastWindowLeft(false),
|
||||
mThrottledQueuesInitialized(false),
|
||||
mNumOfIndexedDBTransactions(0),
|
||||
mNumOfIndexedDBDatabases(0),
|
||||
mIsChrome(aIsChrome),
|
||||
mForegroundCount(0) {
|
||||
mIsChrome(aIsChrome) {
|
||||
if (!sTabGroups) {
|
||||
sTabGroups = new LinkedList<TabGroup>();
|
||||
}
|
||||
@ -174,10 +171,6 @@ already_AddRefed<TabGroup> TabGroup::Join(nsPIDOMWindowOuter* aWindow,
|
||||
MOZ_ASSERT(!tabGroup->mWindows.Contains(aWindow));
|
||||
tabGroup->mWindows.AppendElement(aWindow);
|
||||
|
||||
if (!aWindow->IsBackground()) {
|
||||
tabGroup->mForegroundCount++;
|
||||
}
|
||||
|
||||
return tabGroup.forget();
|
||||
}
|
||||
|
||||
@ -186,11 +179,6 @@ void TabGroup::Leave(nsPIDOMWindowOuter* aWindow) {
|
||||
MOZ_ASSERT(mWindows.Contains(aWindow));
|
||||
mWindows.RemoveElement(aWindow);
|
||||
|
||||
if (!aWindow->IsBackground()) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mForegroundCount > 0);
|
||||
mForegroundCount--;
|
||||
}
|
||||
|
||||
MaybeDestroy();
|
||||
}
|
||||
|
||||
@ -226,32 +214,5 @@ AbstractThread* TabGroup::AbstractMainThreadForImpl(TaskCategory aCategory) {
|
||||
return SchedulerGroup::AbstractMainThreadForImpl(aCategory);
|
||||
}
|
||||
|
||||
void TabGroup::WindowChangedBackgroundStatus(bool aIsNowBackground) {
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aIsNowBackground) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mForegroundCount > 0);
|
||||
mForegroundCount -= 1;
|
||||
} else {
|
||||
mForegroundCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool TabGroup::IsBackground() const {
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
#ifdef DEBUG
|
||||
uint32_t foregrounded = 0;
|
||||
for (auto& window : mWindows) {
|
||||
if (!window->IsBackground()) {
|
||||
foregrounded++;
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(foregrounded == mForegroundCount);
|
||||
#endif
|
||||
|
||||
return mForegroundCount == 0;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -101,22 +101,6 @@ class TabGroup final : public SchedulerGroup,
|
||||
// can always be used off the main thread.
|
||||
nsISerialEventTarget* EventTargetFor(TaskCategory aCategory) const override;
|
||||
|
||||
void WindowChangedBackgroundStatus(bool aIsNowBackground);
|
||||
|
||||
// Returns true if all of the TabGroup's top-level windows are in
|
||||
// the background.
|
||||
bool IsBackground() const override;
|
||||
|
||||
// Increase/Decrease the number of IndexedDB transactions/databases for the
|
||||
// decision making of the preemption in the scheduler.
|
||||
Atomic<uint32_t>& IndexedDBTransactionCounter() {
|
||||
return mNumOfIndexedDBTransactions;
|
||||
}
|
||||
|
||||
Atomic<uint32_t>& IndexedDBDatabaseCounter() {
|
||||
return mNumOfIndexedDBDatabases;
|
||||
}
|
||||
|
||||
static LinkedList<TabGroup>* GetTabGroupList() { return sTabGroups; }
|
||||
|
||||
private:
|
||||
@ -132,14 +116,11 @@ class TabGroup final : public SchedulerGroup,
|
||||
// Thread-safe members
|
||||
Atomic<bool> mLastWindowLeft;
|
||||
Atomic<bool> mThrottledQueuesInitialized;
|
||||
Atomic<uint32_t> mNumOfIndexedDBTransactions;
|
||||
Atomic<uint32_t> mNumOfIndexedDBDatabases;
|
||||
const bool mIsChrome;
|
||||
|
||||
// Main thread only
|
||||
DocGroupMap mDocGroups;
|
||||
nsTArray<nsPIDOMWindowOuter*> mWindows;
|
||||
uint32_t mForegroundCount;
|
||||
|
||||
static LinkedList<TabGroup>* sTabGroups;
|
||||
};
|
||||
|
@ -2465,15 +2465,6 @@ void nsPIDOMWindowInner::TryToCacheTopInnerWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
void nsPIDOMWindowInner::UpdateActiveIndexedDBTransactionCount(int32_t aDelta) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aDelta == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
TabGroup()->IndexedDBTransactionCounter() += aDelta;
|
||||
}
|
||||
|
||||
void nsPIDOMWindowInner::UpdateActiveIndexedDBDatabaseCount(int32_t aDelta) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -2489,8 +2480,6 @@ void nsPIDOMWindowInner::UpdateActiveIndexedDBDatabaseCount(int32_t aDelta) {
|
||||
: mNumOfIndexedDBDatabases;
|
||||
|
||||
counter += aDelta;
|
||||
|
||||
TabGroup()->IndexedDBDatabaseCounter() += aDelta;
|
||||
}
|
||||
|
||||
bool nsPIDOMWindowInner::HasActiveIndexedDBDatabases() {
|
||||
|
@ -6806,9 +6806,6 @@ void nsGlobalWindowOuter::SetIsBackground(bool aIsBackground) {
|
||||
}
|
||||
|
||||
void nsGlobalWindowOuter::SetIsBackgroundInternal(bool aIsBackground) {
|
||||
if (mIsBackground != aIsBackground) {
|
||||
TabGroup()->WindowChangedBackgroundStatus(aIsBackground);
|
||||
}
|
||||
mIsBackground = aIsBackground;
|
||||
}
|
||||
|
||||
|
@ -309,9 +309,8 @@ class nsPIDOMWindowInner : public mozIDOMWindow {
|
||||
// indexedDB counters.
|
||||
void TryToCacheTopInnerWindow();
|
||||
|
||||
// Increase/Decrease the number of active IndexedDB transactions/databases for
|
||||
// the decision making of TabGroup scheduling and timeout-throttling.
|
||||
void UpdateActiveIndexedDBTransactionCount(int32_t aDelta);
|
||||
// Increase/Decrease the number of active IndexedDB databases for the
|
||||
// decision making of TabGroup scheduling and timeout-throttling.
|
||||
void UpdateActiveIndexedDBDatabaseCount(int32_t aDelta);
|
||||
|
||||
// Return true if there is any active IndexedDB databases which could block
|
||||
|
@ -395,10 +395,6 @@ void IDBFactory::UpdateActiveTransactionCount(int32_t aDelta) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aDelta > 0 || (mActiveTransactionCount + aDelta) <
|
||||
mActiveTransactionCount);
|
||||
mActiveTransactionCount += aDelta;
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mGlobal);
|
||||
if (window) {
|
||||
window->UpdateActiveIndexedDBTransactionCount(aDelta);
|
||||
}
|
||||
}
|
||||
|
||||
void IDBFactory::UpdateActiveDatabaseCount(int32_t aDelta) {
|
||||
|
@ -52,10 +52,6 @@ class SchedulerGroup : public LinkedListElement<SchedulerGroup> {
|
||||
|
||||
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
||||
|
||||
// This method returns true if all members of the "group" are in a
|
||||
// "background" state.
|
||||
virtual bool IsBackground() const { return false; }
|
||||
|
||||
class Runnable final : public mozilla::Runnable, public nsIRunnablePriority {
|
||||
public:
|
||||
Runnable(already_AddRefed<nsIRunnable>&& aRunnable,
|
||||
|
Loading…
x
Reference in New Issue
Block a user