Bug 1290116 P1 Expose a ServiceWorkerRegistrationInfo::IsIdle() method. r=asuth
☠☠ backed out by 35b2715748a3 ☠ ☠
authorBen Kelly <ben@wanderview.com>
Fri, 05 Aug 2016 02:08:20 -0700
changeset 397506 90006dffbe5bde43ced588089cace5218251ef9d
parent 397351 32b74662a9e38a53e7f054992e9739c08881833f
child 397507 74ceee4dc2f4872e16b6de01e46575008094fc5a
push id25332
push usermaglione.k@gmail.com
push dateSat, 06 Aug 2016 21:21:51 +0000
reviewersasuth
bugs1290116
milestone51.0a1
Bug 1290116 P1 Expose a ServiceWorkerRegistrationInfo::IsIdle() method. r=asuth
dom/workers/ServiceWorkerRegistrationInfo.cpp
dom/workers/ServiceWorkerRegistrationInfo.h
--- a/dom/workers/ServiceWorkerRegistrationInfo.cpp
+++ b/dom/workers/ServiceWorkerRegistrationInfo.cpp
@@ -218,17 +218,17 @@ ServiceWorkerRegistrationInfo::TryToActi
  * TryToActivate should not be called directly, use TryToActivateAsync instead.
  */
 void
 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();
   }
 }
 
 void
 ServiceWorkerRegistrationInfo::Activate()
 {
@@ -514,9 +514,15 @@ ServiceWorkerRegistrationInfo::Transitio
   // We are transitioning from waiting to active normally, so go to
   // the activating state.
   mActiveWorker = mWaitingWorker.forget();
   mActiveWorker->UpdateState(ServiceWorkerState::Activating);
   NotifyListenersOnChange(WhichServiceWorker::WAITING_WORKER |
                           WhichServiceWorker::ACTIVE_WORKER);
 }
 
+bool
+ServiceWorkerRegistrationInfo::IsIdle() const
+{
+  return !mActiveWorker || mActiveWorker->WorkerPrivate()->IsIdle();
+}
+
 END_WORKERS_NAMESPACE
--- a/dom/workers/ServiceWorkerRegistrationInfo.h
+++ b/dom/workers/ServiceWorkerRegistrationInfo.h
@@ -166,15 +166,19 @@ public:
   // The worker is transitioned to the Activated state.
   void
   SetActive(ServiceWorkerInfo* aServiceWorker);
 
   // Transition the current waiting worker to be the new active worker.  The
   // worker is updated to the Activating state.
   void
   TransitionWaitingToActive();
+
+  // Determine if the registration is actively performing work.
+  bool
+  IsIdle() const;
 };
 
 } // namespace workers
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_workers_serviceworkerregistrationinfo_h