Bug 1438211 P9 Remove nsPIDOMWindowInner::GetServiceWorkerRegistration() and InvalidateServiceWorkerRegistration(). r=asuth
authorBen Kelly <ben@wanderview.com>
Fri, 02 Mar 2018 13:02:50 -0800
changeset 407231 42f6cbb08529
parent 407230 bcea03ca0cda
child 407232 b93a9c630a0c
push id33596
push userncsoregi@mozilla.com
push date2018-03-09 00:18 +0000
treeherdermozilla-central@31a33fc61956 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1438211
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1438211 P9 Remove nsPIDOMWindowInner::GetServiceWorkerRegistration() and InvalidateServiceWorkerRegistration(). r=asuth
dom/base/nsGlobalWindowInner.cpp
dom/base/nsPIDOMWindow.h
dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -1258,18 +1258,16 @@ nsGlobalWindowInner::CleanUp()
   }
   mAudioContexts.Clear();
 
   if (mIdleTimer) {
     mIdleTimer->Cancel();
     mIdleTimer = nullptr;
   }
 
-  mServiceWorkerRegistrationTable.Clear();
-
   mIntlUtils = nullptr;
 }
 
 void
 nsGlobalWindowInner::FreeInnerObjects()
 {
   // Make sure that this is called before we null out the document and
   // other members that the window destroyed observers could
@@ -1463,18 +1461,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   } else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGlobalWindowInner, tmp->mRefCnt.get())
   }
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNavigator)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPerformance)
 
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorkerRegistrationTable)
-
 #ifdef MOZ_WEBSPEECH
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSpeechSynthesis)
 #endif
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOuterWindow)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTopInnerWindow)
 
@@ -1548,17 +1544,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner)
   tmp->CleanupCachedXBLHandlers();
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mNavigator)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPerformance)
 
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mServiceWorkerRegistrationTable)
 
 #ifdef MOZ_WEBSPEECH
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mSpeechSynthesis)
 #endif
 
   if (tmp->mOuterWindow) {
     nsGlobalWindowOuter::Cast(tmp->mOuterWindow)->
       MaybeClearInnerWindow(tmp);
@@ -5200,36 +5195,16 @@ nsGlobalWindowInner::GetCaches(ErrorResu
                                                      storageBlocked,
                                                      forceTrustedOrigin, aRv);
   }
 
   RefPtr<CacheStorage> ref = mCacheStorage;
   return ref.forget();
 }
 
-already_AddRefed<ServiceWorkerRegistration>
-nsPIDOMWindowInner::GetServiceWorkerRegistration(const ServiceWorkerRegistrationDescriptor& aDescriptor)
-{
-  NS_ConvertUTF8toUTF16 scope(aDescriptor.Scope());
-  RefPtr<ServiceWorkerRegistration> registration;
-  if (!mServiceWorkerRegistrationTable.Get(scope,
-                                           getter_AddRefs(registration))) {
-    registration =
-      ServiceWorkerRegistration::CreateForMainThread(this, aDescriptor);
-    mServiceWorkerRegistrationTable.Put(scope, registration);
-  }
-  return registration.forget();
-}
-
-void
-nsPIDOMWindowInner::InvalidateServiceWorkerRegistration(const nsAString& aScope)
-{
-  mServiceWorkerRegistrationTable.Remove(aScope);
-}
-
 void
 nsGlobalWindowInner::FireOfflineStatusEventIfChanged()
 {
   if (!IsCurrentInnerWindow())
     return;
 
   // Don't fire an event if the status hasn't changed
   if (mWasOffline == NS_IsOffline()) {
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -50,18 +50,16 @@ class ClientInfo;
 class ClientState;
 class DocGroup;
 class TabGroup;
 class Element;
 class Navigator;
 class Performance;
 class ServiceWorker;
 class ServiceWorkerDescriptor;
-class ServiceWorkerRegistration;
-class ServiceWorkerRegistrationDescriptor;
 class Timeout;
 class TimeoutManager;
 class CustomElementRegistry;
 enum class CallerType : uint32_t;
 } // namespace dom
 } // namespace mozilla
 
 // Popup control state enum. The values in this enum must go from most
@@ -185,20 +183,16 @@ public:
   bool AddAudioContext(mozilla::dom::AudioContext* aAudioContext);
   void RemoveAudioContext(mozilla::dom::AudioContext* aAudioContext);
   void MuteAudioContexts();
   void UnmuteAudioContexts();
 
   bool GetAudioCaptured() const;
   nsresult SetAudioCapture(bool aCapture);
 
-  already_AddRefed<mozilla::dom::ServiceWorkerRegistration>
-    GetServiceWorkerRegistration(const mozilla::dom::ServiceWorkerRegistrationDescriptor& aDescriptor);
-  void InvalidateServiceWorkerRegistration(const nsAString& aScope);
-
   mozilla::dom::Performance* GetPerformance();
 
   bool HasMutationListeners(uint32_t aMutationEventType) const
   {
     if (!mOuterWindow) {
       NS_ERROR("HasMutationListeners() called on orphan inner window!");
 
       return false;
@@ -650,21 +644,16 @@ protected:
 
   nsCOMPtr<mozilla::dom::EventTarget> mParentTarget; // strong
 
   RefPtr<mozilla::dom::Performance> mPerformance;
   mozilla::UniquePtr<mozilla::dom::TimeoutManager> mTimeoutManager;
 
   RefPtr<mozilla::dom::Navigator> mNavigator;
 
-  typedef nsRefPtrHashtable<nsStringHashKey,
-                            mozilla::dom::ServiceWorkerRegistration>
-          ServiceWorkerRegistrationTable;
-  ServiceWorkerRegistrationTable mServiceWorkerRegistrationTable;
-
   // These variables are only used on inner windows.
   uint32_t mMutationBits;
 
   uint32_t mActivePeerConnections;
 
   bool mIsDocumentLoaded;
   bool mIsHandlingResizeEvent;
   bool mMayHavePaintEventListener;
--- a/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
@@ -82,22 +82,17 @@ ServiceWorkerRegistrationMainThread::Sto
   }
   mListeningForEvents = false;
 }
 
 void
 ServiceWorkerRegistrationMainThread::RegistrationRemovedInternal()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  // If the registration is being removed completely, remove it from the
-  // window registration hash table so that a new registration would get a new
-  // wrapper JS object.
-  if (mOuter && mOuter->GetOwner()) {
-    mOuter->GetOwner()->InvalidateServiceWorkerRegistration(mScope);
-  }
+
   StopListeningForEvents();
 
   // Since the registration is effectively dead in the SWM we can break
   // the ref-cycle and let the binding object clean up.
   mOuter = nullptr;
 }
 
 void