Bug 1070696 - Implement a JSObject* override to AutoJSAPI::Init(). r=smaug
authorBobby Holley <bobbyholley@gmail.com>
Sun, 21 Sep 2014 21:31:53 +0200
changeset 229569 cafe6d84215b803077e99d2379cbbe0cf15d82c2
parent 229568 e1f3be2c48f65c462dc0a11b9852c03ef7200605
child 229570 178df0290ee1b1f79599142cb0d2e7af81630690
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1070696
milestone35.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 1070696 - Implement a JSObject* override to AutoJSAPI::Init(). r=smaug
dom/base/ScriptSettings.cpp
dom/base/ScriptSettings.h
js/xpconnect/src/nsXPConnect.cpp
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -298,16 +298,22 @@ AutoJSAPI::Init(nsIGlobalObject* aGlobal
 
 bool
 AutoJSAPI::Init(nsIGlobalObject* aGlobalObject)
 {
   return Init(aGlobalObject, nsContentUtils::GetDefaultJSContextForThread());
 }
 
 bool
+AutoJSAPI::Init(JSObject* aObject)
+{
+  return Init(xpc::NativeGlobal(aObject));
+}
+
+bool
 AutoJSAPI::InitWithLegacyErrorReporting(nsIGlobalObject* aGlobalObject)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   return Init(aGlobalObject, FindJSContext(aGlobalObject));
 }
 
 bool
--- a/dom/base/ScriptSettings.h
+++ b/dom/base/ScriptSettings.h
@@ -209,16 +209,20 @@ public:
   void Init();
 
   // This uses the SafeJSContext (or worker equivalent), and enters the
   // compartment of aGlobalObject.
   // If aGlobalObject or its associated JS global are null then it returns
   // false and use of cx() will cause an assertion.
   bool Init(nsIGlobalObject* aGlobalObject);
 
+  // This is a helper that grabs the native global associated with aObject and
+  // invokes the above Init() with that.
+  bool Init(JSObject* aObject);
+
   // Unsurprisingly, this uses aCx and enters the compartment of aGlobalObject.
   // If aGlobalObject or its associated JS global are null then it returns
   // false and use of cx() will cause an assertion.
   // If aCx is null it will cause an assertion.
   bool Init(nsIGlobalObject* aGlobalObject, JSContext* aCx);
 
   // This may only be used on the main thread.
   // This attempts to use the JSContext associated with aGlobalObject, otherwise
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -1519,17 +1519,17 @@ NewAddonId(JSContext *cx, const nsACStri
 bool
 SetAddonInterposition(const nsACString &addonIdStr, nsIAddonInterposition *interposition)
 {
     JSAddonId *addonId;
     {
         // We enter the junk scope just to allocate a string, which actually will go
         // in the system zone.
         AutoJSAPI jsapi;
-        jsapi.Init(xpc::NativeGlobal(xpc::PrivilegedJunkScope()));
+        jsapi.Init(xpc::PrivilegedJunkScope());
         addonId = NewAddonId(jsapi.cx(), addonIdStr);
         if (!addonId)
             return false;
     }
 
     return XPCWrappedNativeScope::SetAddonInterposition(addonId, interposition);
 }