Bug 1311523 Allow multiple windows to be paused for SharedWorkers. r=baku

This commit is contained in:
Ben Kelly 2016-10-25 06:26:04 -07:00
Родитель b46ba94f25
Коммит 2cebe4f62c
2 изменённых файлов: 14 добавлений и 11 удалений

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

@ -2180,8 +2180,8 @@ WorkerPrivateParent<Derived>::WorkerPrivateParent(
mMemoryReportCondVar(mMutex, "WorkerPrivateParent Memory Report CondVar"),
mParent(aParent), mScriptURL(aScriptURL),
mWorkerName(aWorkerName), mLoadingWorkerScript(false),
mBusyCount(0), mParentStatus(Pending), mParentFrozen(false),
mParentWindowPaused(false), mIsChromeWorker(aIsChromeWorker),
mBusyCount(0), mParentWindowPausedDepth(0), mParentStatus(Pending),
mParentFrozen(false), mIsChromeWorker(aIsChromeWorker),
mMainThreadObjectsForgotten(false), mIsSecureContext(false),
mWorkerType(aWorkerType),
mCreationTimeStamp(TimeStamp::Now()),
@ -2691,10 +2691,8 @@ void
WorkerPrivateParent<Derived>::ParentWindowPaused()
{
AssertIsOnMainThread();
MOZ_ASSERT(!mParentWindowPaused, "Suspended more than once!");
mParentWindowPaused = true;
MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 0);
mParentWindowPausedDepth += 1;
}
template <class Derived>
@ -2703,9 +2701,12 @@ WorkerPrivateParent<Derived>::ParentWindowResumed()
{
AssertIsOnMainThread();
MOZ_ASSERT(mParentWindowPaused, "Resumed more than once!");
mParentWindowPaused = false;
MOZ_ASSERT(mParentWindowPausedDepth > 0);
MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 1);
mParentWindowPausedDepth -= 1;
if (mParentWindowPausedDepth > 0) {
return;
}
{
MutexAutoLock lock(mMutex);

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

@ -198,9 +198,11 @@ private:
nsTArray<RefPtr<SharedWorker>> mSharedWorkers;
uint64_t mBusyCount;
// SharedWorkers may have multiple windows paused, so this must be
// a count instead of just a boolean.
uint32_t mParentWindowPausedDepth;
Status mParentStatus;
bool mParentFrozen;
bool mParentWindowPaused;
bool mIsChromeWorker;
bool mMainThreadObjectsForgotten;
// mIsSecureContext is set once in our constructor; after that it can be read
@ -441,7 +443,7 @@ public:
IsParentWindowPaused() const
{
AssertIsOnParentThread();
return mParentWindowPaused;
return mParentWindowPausedDepth > 0;
}
bool