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
--- 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;
}