Bug 1381921, part 1 - Remove nsIXPConnect::CurrentNativeCallContext. r=mrbkap draft
authorAndrew McCreight <continuation@gmail.com>
Tue, 18 Jul 2017 10:36:05 -0700
changeset 610793 97051115deaa1426462438a65cf1655a755788e7
parent 610792 3e8c8f2c39a04a7b3a3bfeee4b997892f0501524
child 610794 20e76e8d3520b9e77a343dcf6a69741feb62836d
push id69000
push userbmo:continuation@gmail.com
push dateTue, 18 Jul 2017 19:00:19 +0000
reviewersmrbkap
bugs1381921
milestone56.0a1
Bug 1381921, part 1 - Remove nsIXPConnect::CurrentNativeCallContext. r=mrbkap It is only called in a single place, and can't be called from JS, so inline it and eliminate it. MozReview-Commit-ID: DWfyfoO5Zht
js/xpconnect/idl/nsIXPConnect.idl
js/xpconnect/src/Sandbox.cpp
js/xpconnect/src/nsXPConnect.cpp
--- a/js/xpconnect/idl/nsIXPConnect.idl
+++ b/js/xpconnect/idl/nsIXPConnect.idl
@@ -12,32 +12,30 @@
 #include "jspubtd.h"
 #include "js/TypeDecls.h"
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 
 struct JSFreeOp;
 
 class nsWrapperCache;
-class nsAXPCNativeCallContext;
 %}
 
 /***************************************************************************/
 
 // NB: jsval and jsid are declared in nsrootidl.idl
 
 [ptr] native JSContextPtr(JSContext);
 [ptr] native JSClassPtr(JSClass);
 [ptr] native JSFreeOpPtr(JSFreeOp);
 [ptr] native JSObjectPtr(JSObject);
 [ptr] native JSValConstPtr(const JS::Value);
       native JSEqualityOp(JSEqualityOp);
 [ptr] native JSScriptPtr(JSScript);
 [ptr] native voidPtrPtr(void*);
-[ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext);
 [ptr] native nsWrapperCachePtr(nsWrapperCache);
 [ref] native JSCompartmentOptions(JS::CompartmentOptions);
 [ref] native JSCallArgsRef(const JS::CallArgs);
       native JSHandleId(JS::Handle<jsid>);
 
 /***************************************************************************/
 
 // forward declarations...
@@ -410,17 +408,16 @@ interface nsIXPConnect : nsISupports
     * A new wrapper is *never* constructed.
     */
     nsIXPConnectWrappedNative
     getWrappedNativeOfJSObject(in JSContextPtr aJSContext,
                                in JSObjectPtr  aJSObj);
 
     // Will return null if there is no JS stack right now.
     readonly attribute nsIStackFrame                CurrentJSStack;
-    readonly attribute nsAXPCNativeCallContextPtr   CurrentNativeCallContext;
 
     void debugDump(in short depth);
     void debugDumpObject(in nsISupports aCOMObj, in short depth);
     void debugDumpJSStack(in boolean showArgs,
                           in boolean showLocals,
                           in boolean showThisProps);
 
     /**
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -1698,25 +1698,23 @@ SandboxOptions::Parse()
 
 static nsresult
 AssembleSandboxMemoryReporterName(JSContext* cx, nsCString& sandboxName)
 {
     // Use a default name when the caller did not provide a sandboxName.
     if (sandboxName.IsEmpty())
         sandboxName = NS_LITERAL_CSTRING("[anonymous sandbox]");
 
-    nsXPConnect* xpc = nsXPConnect::XPConnect();
     // Get the xpconnect native call context.
-    nsAXPCNativeCallContext* cc = nullptr;
-    xpc->GetCurrentNativeCallContext(&cc);
+    XPCCallContext* cc = XPCJSContext::Get()->GetCallContext();
     NS_ENSURE_TRUE(cc, NS_ERROR_INVALID_ARG);
 
     // Get the current source info from xpc.
     nsCOMPtr<nsIStackFrame> frame;
-    xpc->GetCurrentJSStack(getter_AddRefs(frame));
+    nsXPConnect::XPConnect()->GetCurrentJSStack(getter_AddRefs(frame));
 
     // Append the caller's location information.
     if (frame) {
         nsString location;
         int32_t lineNumber = 0;
         frame->GetFilename(cx, location);
         frame->GetLineNumber(cx, &lineNumber);
 
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -832,25 +832,16 @@ nsXPConnect::GetCurrentJSStack(nsIStackF
 
     nsCOMPtr<nsIStackFrame> currentStack = dom::GetCurrentJSStack();
     currentStack.forget(aCurrentJSStack);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsXPConnect::GetCurrentNativeCallContext(nsAXPCNativeCallContext * *aCurrentNativeCallContext)
-{
-    MOZ_ASSERT(aCurrentNativeCallContext, "bad param");
-
-    *aCurrentNativeCallContext = XPCJSContext::Get()->GetCallContext();
-    return NS_OK;
-}
-
-NS_IMETHODIMP
 nsXPConnect::SetFunctionThisTranslator(const nsIID & aIID,
                                        nsIXPCFunctionThisTranslator* aTranslator)
 {
     XPCJSRuntime* rt = GetRuntimeInstance();
     IID2ThisTranslatorMap* map = rt->GetThisTranslatorMap();
     map->Add(aIID, aTranslator);
     return NS_OK;
 }