Bug 834732 - Move cx pushing into nsPluginProtoChainInstallRunner. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Tue, 26 Feb 2013 11:04:10 -0800
changeset 123055 90724209f5552fc11863bf81d4d0b82074276684
parent 123054 34e3e1156a7f177b8300a330bb18934174dd2f90
child 123056 471fe31fc325774e0aa26b39ec442e23b5cb1e2e
push id24372
push useremorley@mozilla.com
push dateWed, 27 Feb 2013 13:22:59 +0000
treeherdermozilla-central@0a91da5f5eab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs834732
milestone22.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 834732 - Move cx pushing into nsPluginProtoChainInstallRunner. r=mrbkap This gets rid of the last use of REQUIRE_SCRIPT_CONTEXT. \o/
content/base/src/nsObjectLoadingContent.cpp
dom/base/nsDOMClassInfo.cpp
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -2565,16 +2565,18 @@ nsObjectLoadingContent::NotifyContentObj
   if (!sgo)
     return;
 
   nsIScriptContext *scx = sgo->GetContext();
   if (!scx)
     return;
 
   JSContext *cx = scx->GetNativeContext();
+  nsCxPusher pusher;
+  pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT);
 
   nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
   nsContentUtils::XPConnect()->
   GetWrappedNativeOfNativeObject(cx, sgo->GetGlobalJSObject(), thisContent,
                                  NS_GET_IID(nsISupports),
                                  getter_AddRefs(wrapper));
 
   if (!wrapper) {
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -7768,27 +7768,20 @@ public:
                                   nsIScriptContext* scriptContext)
     : mWrapper(wrapper),
       mContext(scriptContext)
   {
   }
 
   NS_IMETHOD Run()
   {
-    JSContext* cx = nullptr;
-    if (mContext) {
-      cx = mContext->GetNativeContext();
-    } else {
-      nsCOMPtr<nsIThreadJSContextStack> stack =
-        do_GetService("@mozilla.org/js/xpc/ContextStack;1");
-      NS_ENSURE_TRUE(stack, NS_OK);
-
-      cx = stack->GetSafeJSContext();
-      NS_ENSURE_TRUE(cx, NS_OK);
-    }
+    nsCxPusher pusher;
+    JSContext* cx = mContext ? mContext->GetNativeContext()
+                             : nsContentUtils::GetSafeJSContext();
+    pusher.Push(cx, nsCxPusher::ALWAYS_PUSH);
 
     JSObject* obj = nullptr;
     mWrapper->GetJSObject(&obj);
     NS_ASSERTION(obj, "Should never be null");
     nsHTMLPluginObjElementSH::SetupProtoChain(mWrapper, cx, obj);
     return NS_OK;
   }
 
@@ -7802,21 +7795,17 @@ NS_IMPL_ISUPPORTS1(nsPluginProtoChainIns
 // static
 nsresult
 nsHTMLPluginObjElementSH::SetupProtoChain(nsIXPConnectWrappedNative *wrapper,
                                           JSContext *cx,
                                           JSObject *obj)
 {
   NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
                "Shouldn't have gotten in here");
-
-  nsCxPusher cxPusher;
-  if (!cxPusher.Push(cx, nsCxPusher::REQUIRE_SCRIPT_CONTEXT)) {
-    return NS_OK;
-  }
+  MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext());
 
   JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, obj);
 
   nsRefPtr<nsNPAPIPluginInstance> pi;
   nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, cx, getter_AddRefs(pi));
   NS_ENSURE_SUCCESS(rv, rv);