Bug 1379786, part 3 - Remove sSecurityManager from nsJSEnvironment.cpp. r=mrbkap draft
authorAndrew McCreight <continuation@gmail.com>
Mon, 10 Jul 2017 14:17:24 -0700
changeset 609156 f07a2c5875140eca390e7480a67616378909e60d
parent 609155 2a2a14ed02e6ed1154c7217cccdd04c86f8253e3
child 609157 3feb90bcd8892709476aac6e342cc2975aac5a0f
push id68525
push userbmo:continuation@gmail.com
push dateFri, 14 Jul 2017 22:48:28 +0000
reviewersmrbkap
bugs1379786
milestone56.0a1
Bug 1379786, part 3 - Remove sSecurityManager from nsJSEnvironment.cpp. r=mrbkap MozReview-Commit-ID: G04P7k1Dxki
dom/base/nsJSEnvironment.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -198,19 +198,16 @@ static bool sIncrementalCC = false;
 static int32_t sActiveIntersliceGCBudget = 5; // ms;
 static nsScriptNameSpaceManager *gNameSpaceManager;
 
 static PRTime sFirstCollectionTime;
 
 static bool sIsInitialized;
 static bool sDidShutdown;
 static bool sShuttingDown;
-static int32_t sContextCount;
-
-static nsIScriptSecurityManager *sSecurityManager;
 
 // nsJSEnvironmentObserver observes the memory-pressure notifications
 // and forces a garbage collection and cycle collection when it happens, if
 // the appropriate pref is set.
 
 static bool sGCOnMemoryPressure;
 
 // nsJSEnvironmentObserver observes the user-interaction-inactive notifications
@@ -765,37 +762,26 @@ static const char js_options_dot_str[]  
 nsJSContext::nsJSContext(bool aGCOnDestruction,
                          nsIScriptGlobalObject* aGlobalObject)
   : mWindowProxy(nullptr)
   , mGCOnDestruction(aGCOnDestruction)
   , mGlobalObjectRef(aGlobalObject)
 {
   EnsureStatics();
 
-  ++sContextCount;
-
   mIsInitialized = false;
   mProcessingScriptTag = false;
   HoldJSObjects(this);
 }
 
 nsJSContext::~nsJSContext()
 {
   mGlobalObjectRef = nullptr;
 
   Destroy();
-
-  --sContextCount;
-
-  if (!sContextCount && sDidShutdown) {
-    // The last context is being deleted, and we're already in the
-    // process of shutting down, release the security manager.
-
-    NS_IF_RELEASE(sSecurityManager);
-  }
 }
 
 void
 nsJSContext::Destroy()
 {
   if (mGCOnDestruction) {
     PokeGC(JS::gcreason::NSJSCONTEXT_DESTROY, mWindowProxy);
   }
@@ -2574,18 +2560,16 @@ mozilla::dom::StartupJSEnvironment()
   sPostGCEventsToConsole = false;
   sNeedsFullCC = false;
   sNeedsFullGC = true;
   sNeedsGCAfterCC = false;
   gNameSpaceManager = nullptr;
   sIsInitialized = false;
   sDidShutdown = false;
   sShuttingDown = false;
-  sContextCount = 0;
-  sSecurityManager = nullptr;
   gCCStats.Init();
   sExpensiveCollectorPokes = 0;
 }
 
 static void
 SetGCParameter(JSGCParamKey aParam, uint32_t aValue)
 {
   AutoJSAPI jsapi;
@@ -2770,22 +2754,16 @@ nsJSContext::EnsureStatics()
 {
   if (sIsInitialized) {
     if (!nsContentUtils::XPConnect()) {
       MOZ_CRASH();
     }
     return;
   }
 
-  nsresult rv = CallGetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID,
-                               &sSecurityManager);
-  if (NS_FAILED(rv)) {
-    MOZ_CRASH();
-  }
-
   // Let's make sure that our main thread is the same as the xpcom main thread.
   MOZ_ASSERT(NS_IsMainThread());
 
   AutoJSAPI jsapi;
   jsapi.Init();
 
   sPrevGCSliceCallback = JS::SetGCSliceCallback(jsapi.cx(), DOMGCSliceCallback);
 
@@ -2924,22 +2902,16 @@ mozilla::dom::PeekNameSpaceManager()
 
 void
 mozilla::dom::ShutdownJSEnvironment()
 {
   KillTimers();
 
   NS_IF_RELEASE(gNameSpaceManager);
 
-  if (!sContextCount) {
-    // We're being shutdown, and there are no more contexts
-    // alive, release the security manager.
-    NS_IF_RELEASE(sSecurityManager);
-  }
-
   sShuttingDown = true;
   sDidShutdown = true;
 }
 
 // A fast-array class for JS.  This class supports both nsIJSScriptArray and
 // nsIArray.  If it is JS itself providing and consuming this class, all work
 // can be done via nsIJSScriptArray, and avoid the conversion of elements
 // to/from nsISupports.