Bug 1421355, part 2 - Remove nsIXPConnect::getWrappedNativeOfNativeObject. r=mrbkap
This method is unused. It is the only caller of
XPCWrappedNative::GetUsedOnly(), so remove that, too.
MozReview-Commit-ID: LRMB2bAwgoS
--- a/js/xpconnect/idl/nsIXPConnect.idl
+++ b/js/xpconnect/idl/nsIXPConnect.idl
@@ -399,26 +399,16 @@ interface nsIXPConnect : nsISupports
wrapJSAggregatedToNative(in nsISupports aOuter,
in JSContextPtr aJSContext,
in JSObjectPtr aJSObj,
in nsIIDRef aIID,
[iid_is(aIID),retval] out nsQIResult result);
// Methods added since mozilla 0.6....
- /**
- * This only succeeds if the native object is already wrapped by xpconnect.
- * A new wrapper is *never* constructed.
- */
- nsIXPConnectWrappedNative
- getWrappedNativeOfNativeObject(in JSContextPtr aJSContext,
- in JSObjectPtr aScope,
- in nsISupports aCOMObj,
- in nsIIDRef aIID);
-
void
setFunctionThisTranslator(in nsIIDRef aIID,
in nsIXPCFunctionThisTranslator aTranslator);
JSObjectPtr
getWrappedNativePrototype(in JSContextPtr aJSContext,
in JSObjectPtr aScope,
in nsIClassInfo aClassInfo);
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -474,64 +474,16 @@ FinishCreate(XPCWrappedNativeScope* Scop
cache->SetWrapper(flat);
}
DEBUG_CheckClassInfoClaims(wrapper);
wrapper.forget(resultWrapper);
return NS_OK;
}
-// static
-nsresult
-XPCWrappedNative::GetUsedOnly(nsISupports* Object,
- XPCWrappedNativeScope* Scope,
- XPCNativeInterface* Interface,
- XPCWrappedNative** resultWrapper)
-{
- AutoJSContext cx;
- MOZ_ASSERT(Object, "XPCWrappedNative::GetUsedOnly was called with a null Object");
- MOZ_ASSERT(Interface);
-
- RefPtr<XPCWrappedNative> wrapper;
- nsWrapperCache* cache = nullptr;
- CallQueryInterface(Object, &cache);
- if (cache) {
- RootedObject flat(cx, cache->GetWrapper());
- if (!flat) {
- *resultWrapper = nullptr;
- return NS_OK;
- }
- wrapper = XPCWrappedNative::Get(flat);
- } else {
- nsCOMPtr<nsISupports> identity = do_QueryInterface(Object);
-
- if (!identity) {
- NS_ERROR("This XPCOM object fails in QueryInterface to nsISupports!");
- return NS_ERROR_FAILURE;
- }
-
- Native2WrappedNativeMap* map = Scope->GetWrappedNativeMap();
-
- wrapper = map->Find(identity);
- if (!wrapper) {
- *resultWrapper = nullptr;
- return NS_OK;
- }
- }
-
- nsresult rv;
- if (!wrapper->FindTearOff(Interface, false, &rv)) {
- MOZ_ASSERT(NS_FAILED(rv), "returning NS_OK on failure");
- return rv;
- }
-
- wrapper.forget(resultWrapper);
- return NS_OK;
-}
-
// This ctor is used if this object will have a proto.
XPCWrappedNative::XPCWrappedNative(already_AddRefed<nsISupports>&& aIdentity,
XPCWrappedNativeProto* aProto)
: mMaybeProto(aProto),
mSet(aProto->GetSet())
{
MOZ_ASSERT(NS_IsMainThread());
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -764,50 +764,16 @@ xpc::UnwrapReflectorToISupports(JSObject
// this if non-null our thing will definitely be a DOM object, and we know
// their QI to nsISupports doesn't do anything weird.
nsCOMPtr<nsISupports> canonical =
do_QueryInterface(mozilla::dom::UnwrapDOMObjectToISupports(reflector));
return canonical.forget();
}
NS_IMETHODIMP
-nsXPConnect::GetWrappedNativeOfNativeObject(JSContext * aJSContext,
- JSObject * aScopeArg,
- nsISupports* aCOMObj,
- const nsIID & aIID,
- nsIXPConnectWrappedNative** _retval)
-{
- MOZ_ASSERT(aJSContext, "bad param");
- MOZ_ASSERT(aScopeArg, "bad param");
- MOZ_ASSERT(aCOMObj, "bad param");
- MOZ_ASSERT(_retval, "bad param");
-
- *_retval = nullptr;
-
- RootedObject aScope(aJSContext, aScopeArg);
-
- XPCWrappedNativeScope* scope = ObjectScope(aScope);
- if (!scope)
- return UnexpectedFailure(NS_ERROR_FAILURE);
-
- RefPtr<XPCNativeInterface> iface =
- XPCNativeInterface::GetNewOrUsed(&aIID);
- if (!iface)
- return NS_ERROR_FAILURE;
-
- XPCWrappedNative* wrapper;
-
- nsresult rv = XPCWrappedNative::GetUsedOnly(aCOMObj, scope, iface, &wrapper);
- if (NS_FAILED(rv))
- return NS_ERROR_FAILURE;
- *_retval = static_cast<nsIXPConnectWrappedNative*>(wrapper);
- 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;
}
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -1646,22 +1646,16 @@ public:
XPCWrappedNative** wrappedGlobal);
static nsresult
GetNewOrUsed(xpcObjectHelper& helper,
XPCWrappedNativeScope* Scope,
XPCNativeInterface* Interface,
XPCWrappedNative** wrapper);
- static nsresult
- GetUsedOnly(nsISupports* Object,
- XPCWrappedNativeScope* Scope,
- XPCNativeInterface* Interface,
- XPCWrappedNative** wrapper);
-
void FlatJSObjectFinalized();
void FlatJSObjectMoved(JSObject* obj, const JSObject* old);
void SystemIsBeingShutDown();
enum CallMode {CALL_METHOD, CALL_GETTER, CALL_SETTER};
static bool CallMethod(XPCCallContext& ccx,