UPDATE: 1011268-swm-unregister
authorNikhil Marathe <nsm.nikhil@gmail.com>
Fri, 11 Jul 2014 17:58:38 -0700
changeset 1103 3e505e3ac2b279fcc039bb9080b42115e9e43c32
parent 1102 2ea513e98ab245d479e6b4a2bf6a6e3fbe85b8b8
child 1104 12196fb269783084ea0fdd85cb1dbd525c044354
push id32
push usernsm.nikhil@gmail.com
push dateThu, 24 Jul 2014 00:32:46 +0000
bugs1011268
UPDATE: 1011268-swm-unregister dom/workers/ServiceWorkerManager.cpp | 4 ++++ dom/workers/test/serviceworkers/mochitest.ini | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-) qparent: 6b8638719063 qtip: 810db2a5835d top: 1011268-swm-unregister
1011268-swm-unregister
series
--- a/1011268-swm-unregister
+++ b/1011268-swm-unregister
@@ -1,17 +1,17 @@
 # HG changeset patch
-# Parent ce528d6074ae9c7871157169415a2335fca7e75c
+# Parent 6b863871906376f504b6d6fa2829172d7891e8d9
 # User Nikhil Marathe <nsm.nikhil@gmail.com>
 Bug 1011268: Unregister algorithm. r=ehsan
 
 diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp
 --- a/dom/workers/ServiceWorkerManager.cpp
 +++ b/dom/workers/ServiceWorkerManager.cpp
-@@ -426,16 +426,94 @@ public:
+@@ -431,16 +431,94 @@ public:
      // for the same registration) are aborted. Update() sets a new
      // UpdatePromise on the registration.
      registration->mUpdatePromise->AddPromise(mPromise);
  
      return rv;
    }
  };
  
@@ -96,17 +96,17 @@ diff --git a/dom/workers/ServiceWorkerMa
  // If we return an error code here, the ServiceWorkerContainer will
  // automatically reject the Promise.
  NS_IMETHODIMP
  ServiceWorkerManager::Register(nsIDOMWindow* aWindow, const nsAString& aScope,
                                 const nsAString& aScriptURL,
                                 nsISupports** aPromise)
  {
    AssertIsOnMainThread();
-@@ -544,20 +622,17 @@ ServiceWorkerManager::RejectUpdatePromis
+@@ -549,20 +627,17 @@ ServiceWorkerManager::RejectUpdatePromis
   * may access the registration's (new) Promise after calling this method.
   */
  NS_IMETHODIMP
  ServiceWorkerManager::Update(ServiceWorkerRegistration* aRegistration,
                               nsPIDOMWindow* aWindow)
  {
    if (aRegistration->HasUpdatePromise()) {
      NS_WARNING("Already had a UpdatePromise. Aborting that one!");
@@ -118,17 +118,17 @@ diff --git a/dom/workers/ServiceWorkerMa
    }
  
    if (aRegistration->mInstallingWorker) {
      // FIXME(nsm): Terminate the worker. We still haven't figured out worker
      // instance ownership when not associated with a window, so let's wait on
      // this.
      // FIXME(nsm): We should be setting the state on the actual worker
      // instance.
-@@ -573,30 +648,79 @@ ServiceWorkerManager::Update(ServiceWork
+@@ -578,30 +653,79 @@ ServiceWorkerManager::Update(ServiceWork
  
    aRegistration->mUpdateInstance =
      new ServiceWorkerUpdateInstance(aRegistration, aWindow);
    aRegistration->mUpdateInstance->Update();
  
    return NS_OK;
  }
  
@@ -200,42 +200,41 @@ diff --git a/dom/workers/ServiceWorkerMa
  }
  
  /* static */
  already_AddRefed<ServiceWorkerManager>
  ServiceWorkerManager::GetInstance()
  {
    nsCOMPtr<nsIServiceWorkerManager> swm =
      do_GetService(SERVICEWORKERMANAGER_CONTRACTID);
-@@ -1050,17 +1174,21 @@ public:
-   {
+@@ -1055,16 +1179,20 @@ public:
      if (mRegistration->mCurrentWorker) {
        // FIXME(nsm). Steps 3.1-3.4 of the algorithm.
      }
  
      nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
  
      mRegistration->mCurrentWorker = mRegistration->mWaitingWorker.forget();
-+
      swm->InvalidateServiceWorkerContainerWorker(mRegistration, ACTIVE_WORKER | WAITING_WORKER);
 +    if (!mRegistration->mCurrentWorker) {
 +      // Just got unregistered!
++      MOZ_ASSERT(false);
 +    }
  
-     // FIXME(nsm): Steps 6-7 of the algorithm.
+     // FIXME(nsm): Steps 7 of the algorithm.
  
      swm->FireEventOnServiceWorkerContainers(mRegistration,
                                              NS_LITERAL_STRING("controllerchange"));
  
      nsRefPtr<ServiceWorker> serviceWorker;
- 
+     nsresult rv =
 diff --git a/dom/workers/ServiceWorkerManager.h b/dom/workers/ServiceWorkerManager.h
 --- a/dom/workers/ServiceWorkerManager.h
 +++ b/dom/workers/ServiceWorkerManager.h
-@@ -205,16 +205,17 @@ public:
+@@ -192,16 +192,17 @@ public:
   */
  class ServiceWorkerManager MOZ_FINAL : public nsIServiceWorkerManager
  {
    friend class ActivationRunnable;
    friend class RegisterRunnable;
    friend class CallInstallRunnable;
    friend class CancelServiceWorkerInstallationRunnable;
    friend class ServiceWorkerUpdateInstance;
@@ -243,17 +242,17 @@ diff --git a/dom/workers/ServiceWorkerMa
  
  public:
    NS_DECL_ISUPPORTS
    NS_DECL_NSISERVICEWORKERMANAGER
    NS_DECLARE_STATIC_IID_ACCESSOR(NS_SERVICEWORKERMANAGER_IMPL_IID)
  
    static ServiceWorkerManager* FactoryCreate()
    {
-@@ -267,16 +268,24 @@ public:
+@@ -254,16 +255,24 @@ public:
        ServiceWorkerRegistration* registration =
          new ServiceWorkerRegistration(aScope);
        // From now on ownership of registration is with
        // mServiceWorkerRegistrations.
        mServiceWorkerRegistrations.Put(aScope, registration);
        ServiceWorkerManager::AddScope(mOrderedScopes, aScope);
        return registration;
      }
@@ -268,17 +267,17 @@ diff --git a/dom/workers/ServiceWorkerMa
    };
  
    nsClassHashtable<nsCStringHashKey, ServiceWorkerDomainInfo> mDomainMap;
  
    void
    ResolveRegisterPromises(ServiceWorkerRegistration* aRegistration,
                            const nsACString& aWorkerScriptSpec);
  
-@@ -311,16 +320,19 @@ public:
+@@ -298,16 +307,19 @@ public:
  
    static already_AddRefed<ServiceWorkerManager>
    GetInstance();
  
  private:
    ServiceWorkerManager();
    ~ServiceWorkerManager();
  
@@ -291,24 +290,25 @@ diff --git a/dom/workers/ServiceWorkerMa
    void
    Install(ServiceWorkerRegistration* aRegistration,
            ServiceWorkerInfo* aServiceWorkerInfo);
  
    NS_IMETHOD
 diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini
 --- a/dom/workers/test/serviceworkers/mochitest.ini
 +++ b/dom/workers/test/serviceworkers/mochitest.ini
-@@ -1,12 +1,14 @@
+@@ -1,13 +1,15 @@
  [DEFAULT]
  support-files =
    worker.js
    worker2.js
    worker3.js
    parse_error_worker.js
    install_event_worker.js
+   simpleregister/index.html
 +  unregister/index.html
  
  [test_installation_simple.html]
  [test_install_event.html]
  [test_navigator.html]
  [test_scopes.html]
 +[test_unregister.html]
 diff --git a/dom/workers/test/serviceworkers/test_unregister.html b/dom/workers/test/serviceworkers/test_unregister.html
--- a/series
+++ b/series
@@ -1,10 +1,10 @@
+1011268-swm-unregister
 foojsapi
-1011268-swm-unregister
 sw-instance-events-and-state-2
 sw-instance-events-and-state
 903441-stuff
 898524-1-nowhite
 898524-2-nowhite
 857464-push-prefs
 857464-push-webpages
 885093-push-prompt