diff --git a/dom/workers/ServiceWorkerRegistrationInfo.cpp b/dom/workers/ServiceWorkerRegistrationInfo.cpp index 06541257774e..a9b0cb184e0a 100644 --- a/dom/workers/ServiceWorkerRegistrationInfo.cpp +++ b/dom/workers/ServiceWorkerRegistrationInfo.cpp @@ -223,7 +223,7 @@ ServiceWorkerRegistrationInfo::TryToActivate() AssertIsOnMainThread(); bool controlling = IsControllingDocuments(); bool skipWaiting = mWaitingWorker && mWaitingWorker->SkipWaitingFlag(); - bool idle = !mActiveWorker || mActiveWorker->WorkerPrivate()->IsIdle(); + bool idle = IsIdle(); if (idle && (!controlling || skipWaiting)) { Activate(); } @@ -519,4 +519,10 @@ ServiceWorkerRegistrationInfo::TransitionWaitingToActive() WhichServiceWorker::ACTIVE_WORKER); } +bool +ServiceWorkerRegistrationInfo::IsIdle() const +{ + return !mActiveWorker || mActiveWorker->WorkerPrivate()->IsIdle(); +} + END_WORKERS_NAMESPACE diff --git a/dom/workers/ServiceWorkerRegistrationInfo.h b/dom/workers/ServiceWorkerRegistrationInfo.h index 65d9f90a65d1..d2d217be0f68 100644 --- a/dom/workers/ServiceWorkerRegistrationInfo.h +++ b/dom/workers/ServiceWorkerRegistrationInfo.h @@ -171,6 +171,10 @@ public: // worker is updated to the Activating state. void TransitionWaitingToActive(); + + // Determine if the registration is actively performing work. + bool + IsIdle() const; }; } // namespace workers