Bug 1333573 P6 Move ForgetMainThreadObjects() into WorkerLoadInfo. r=baku
authorBen Kelly <ben@wanderview.com>
Tue, 07 Feb 2017 10:28:39 -0500
changeset 387840 d60942e5c631de61156ad115b40563846b396fd8
parent 387839 fad843873cf7f84dc678a3eb8d3042f6c16792b7
child 387841 7dd9da392d9331452f2c31b50b2cc304754fee63
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1333573
milestone54.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 1333573 P6 Move ForgetMainThreadObjects() into WorkerLoadInfo. r=baku
dom/workers/WorkerPrivate.cpp
dom/workers/Workers.h
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -1999,16 +1999,38 @@ WorkerLoadInfo::FinalChannelPrincipalIsV
   if (principal->Equals(mPrincipal)) {
     return true;
   }
 
   return false;
 }
 #endif // defined(DEBUG) || !defined(RELEASE_OR_BETA)
 
+void
+WorkerLoadInfo::ForgetMainThreadObjects(nsTArray<nsCOMPtr<nsISupports> >& aDoomed)
+{
+  static const uint32_t kDoomedCount = 10;
+
+  aDoomed.SetCapacity(kDoomedCount);
+
+  SwapToISupportsArray(mWindow, aDoomed);
+  SwapToISupportsArray(mScriptContext, aDoomed);
+  SwapToISupportsArray(mBaseURI, aDoomed);
+  SwapToISupportsArray(mResolvedScriptURI, aDoomed);
+  SwapToISupportsArray(mPrincipal, aDoomed);
+  SwapToISupportsArray(mChannel, aDoomed);
+  SwapToISupportsArray(mCSP, aDoomed);
+  SwapToISupportsArray(mLoadGroup, aDoomed);
+  SwapToISupportsArray(mLoadFailedAsyncRunnable, aDoomed);
+  SwapToISupportsArray(mInterfaceRequestor, aDoomed);
+  // Before adding anything here update kDoomedCount above!
+
+  MOZ_ASSERT(aDoomed.Length() == kDoomedCount);
+}
+
 template <class Derived>
 class WorkerPrivateParent<Derived>::EventTarget final
   : public nsIEventTarget
 {
   // This mutex protects mWorkerPrivate and must be acquired *before* the
   // WorkerPrivate's mutex whenever they must both be held.
   mozilla::Mutex mMutex;
   WorkerPrivate* mWorkerPrivate;
@@ -3202,33 +3224,17 @@ WorkerPrivateParent<Derived>::ForgetOver
 template <class Derived>
 void
 WorkerPrivateParent<Derived>::ForgetMainThreadObjects(
                                       nsTArray<nsCOMPtr<nsISupports> >& aDoomed)
 {
   AssertIsOnParentThread();
   MOZ_ASSERT(!mMainThreadObjectsForgotten);
 
-  static const uint32_t kDoomedCount = 10;
-
-  aDoomed.SetCapacity(kDoomedCount);
-
-  SwapToISupportsArray(mLoadInfo.mWindow, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mScriptContext, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mBaseURI, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mResolvedScriptURI, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mPrincipal, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mChannel, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mCSP, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mLoadGroup, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mLoadFailedAsyncRunnable, aDoomed);
-  SwapToISupportsArray(mLoadInfo.mInterfaceRequestor, aDoomed);
-  // Before adding anything here update kDoomedCount above!
-
-  MOZ_ASSERT(aDoomed.Length() == kDoomedCount);
+  mLoadInfo.ForgetMainThreadObjects(aDoomed);
 
   mMainThreadObjectsForgotten = true;
 }
 
 template <class Derived>
 void
 WorkerPrivateParent<Derived>::PostMessageInternal(JSContext* aCx,
                                                   JS::Handle<JS::Value> aMessage,
--- a/dom/workers/Workers.h
+++ b/dom/workers/Workers.h
@@ -288,16 +288,19 @@ struct WorkerLoadInfo
 
   nsresult
   SetPrincipalFromChannel(nsIChannel* aChannel);
 
 #if defined(DEBUG) || !defined(RELEASE_OR_BETA)
   bool
   FinalChannelPrincipalIsValid(nsIChannel* aChannel);
 #endif
+
+  void
+  ForgetMainThreadObjects(nsTArray<nsCOMPtr<nsISupports> >& aDoomed);
 };
 
 // All of these are implemented in RuntimeService.cpp
 
 void
 CancelWorkersForWindow(nsPIDOMWindowInner* aWindow);
 
 void