Bug 1289136 - Fifth argument to XPCConvert::NativeInterface2JSObject() is always null. r=gabor
authorAndrew McCreight <continuation@gmail.com>
Wed, 27 Jul 2016 10:11:40 -0700
changeset 331996 b807e09863ff0d989aa95f1d5176cb983b1d7789
parent 331995 44d0ef641fa71923e29f50b130fd604144951d58
child 331997 bd5e978762ce6e91f6431a81ce971ea551901c19
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1289136
milestone50.0a1
Bug 1289136 - Fifth argument to XPCConvert::NativeInterface2JSObject() is always null. r=gabor
dom/bindings/BindingUtils.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -1009,17 +1009,17 @@ NativeInterface2JSObjectAndThrowIfFailed
         aRetval.setObject(*obj);
         return true;
       }
   }
 
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!XPCConvert::NativeInterface2JSObject(aRetval, nullptr, aHelper, aIID,
-                                            nullptr, aAllowNativeWrapper, &rv)) {
+                                            aAllowNativeWrapper, &rv)) {
     // I can't tell if NativeInterface2JSObject throws JS exceptions
     // or not.  This is a sloppy stab at the right semantics; the
     // method really ought to be fixed to behave consistently.
     if (!JS_IsExceptionPending(aCx)) {
       Throw(aCx, NS_FAILED(rv) ? rv : NS_ERROR_UNEXPECTED);
     }
     return false;
   }
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -336,17 +336,17 @@ XPCConvert::NativeData2JS(MutableHandleV
             if (!variant)
                 return false;
 
             return XPCVariant::VariantDataToJS(variant,
                                                pErr, d);
         }
 
         xpcObjectHelper helper(iface);
-        return NativeInterface2JSObject(d, nullptr, helper, iid, nullptr, true, pErr);
+        return NativeInterface2JSObject(d, nullptr, helper, iid, true, pErr);
     }
 
     default:
         NS_ERROR("bad type");
         return false;
     }
     return true;
 }
@@ -739,21 +739,19 @@ CreateHolderIfNeeded(HandleObject obj, M
 
 /***************************************************************************/
 // static
 bool
 XPCConvert::NativeInterface2JSObject(MutableHandleValue d,
                                      nsIXPConnectJSObjectHolder** dest,
                                      xpcObjectHelper& aHelper,
                                      const nsID* iid,
-                                     XPCNativeInterface** Interface,
                                      bool allowNativeWrapper,
                                      nsresult* pErr)
 {
-    MOZ_ASSERT_IF(Interface, iid);
     if (!iid)
         iid = &NS_GET_IID(nsISupports);
 
     d.setNull();
     if (dest)
         *dest = nullptr;
     if (!aHelper.Object())
         return true;
@@ -818,27 +816,20 @@ XPCConvert::NativeInterface2JSObject(Mut
         if (!JS_WrapObject(cx, &cpow))
             return false;
         d.setObject(*cpow);
         return true;
     }
 
     // Go ahead and create an XPCWrappedNative for this object.
     AutoMarkingNativeInterfacePtr iface(cx);
-    if (Interface)
-        iface = *Interface;
 
-    if (!iface) {
-        iface = XPCNativeInterface::GetNewOrUsed(iid);
-        if (!iface)
-            return false;
-
-        if (Interface)
-            *Interface = iface;
-    }
+    iface = XPCNativeInterface::GetNewOrUsed(iid);
+    if (!iface)
+        return false;
 
     RefPtr<XPCWrappedNative> wrapper;
     nsresult rv = XPCWrappedNative::GetNewOrUsed(aHelper, xpcscope, iface,
                                                  getter_AddRefs(wrapper));
     if (NS_FAILED(rv) && pErr)
         *pErr = rv;
 
     // If creating the wrapped native failed, then return early.
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -1054,17 +1054,17 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
                                 goto pre_call_clean_up;
                             }
                             if (newThis) {
                                 RootedValue v(cx);
                                 xpcObjectHelper helper(newThis);
                                 bool ok =
                                   XPCConvert::NativeInterface2JSObject(
                                       &v, nullptr, helper, nullptr,
-                                      nullptr, false, nullptr);
+                                      false, nullptr);
                                 if (!ok) {
                                     goto pre_call_clean_up;
                                 }
                                 thisObj = v.toObjectOrNull();
                                 if (!JS_WrapObject(cx, &thisObj))
                                     goto pre_call_clean_up;
                             }
                         }
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -190,17 +190,17 @@ XPCWrappedNativeScope::GetComponentsJSOb
         bool system = nsXPConnect::SecurityManager()->IsSystemPrincipal(p);
         mComponents = system ? new nsXPCComponents(this)
                              : new nsXPCComponentsBase(this);
     }
 
     RootedValue val(cx);
     xpcObjectHelper helper(mComponents);
     bool ok = XPCConvert::NativeInterface2JSObject(&val, nullptr, helper,
-                                                   nullptr, nullptr, false,
+                                                   nullptr, false,
                                                    nullptr);
     if (NS_WARN_IF(!ok))
         return false;
 
     if (NS_WARN_IF(!val.isObject()))
         return false;
 
     // The call to wrap() here is necessary even though the object is same-
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -533,17 +533,17 @@ NativeInterface2JSObject(HandleObject aS
                          nsIXPConnectJSObjectHolder** aHolder)
 {
     AutoJSContext cx;
     JSAutoCompartment ac(cx, aScope);
 
     nsresult rv;
     xpcObjectHelper helper(aCOMObj, aCache);
     if (!XPCConvert::NativeInterface2JSObject(aVal, aHolder, helper, aIID,
-                                              nullptr, aAllowWrapping, &rv))
+                                              aAllowWrapping, &rv))
         return rv;
 
     MOZ_ASSERT(aAllowWrapping || !xpc::WrapperFactory::IsXrayWrapper(&aVal.toObject()),
                "Shouldn't be returning a xray wrapper here");
 
     return NS_OK;
 }
 
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -2402,30 +2402,28 @@ public:
                               nsresult* pErr);
 
     /**
      * Convert a native nsISupports into a JSObject.
      *
      * @param dest [out] the resulting JSObject
      * @param src the native object we're working with
      * @param iid the interface of src that we want (may be null)
-     * @param Interface the interface of src that we want
      * @param cache the wrapper cache for src (may be null, in which case src
      *              will be QI'ed to get the cache)
      * @param allowNativeWrapper if true, this method may wrap the resulting
      *        JSObject in an XPCNativeWrapper and return that, as needed.
      * @param pErr [out] relevant error code, if any.
      * @param src_is_identity optional performance hint. Set to true only
      *                        if src is the identity pointer.
      */
     static bool NativeInterface2JSObject(JS::MutableHandleValue d,
                                          nsIXPConnectJSObjectHolder** dest,
                                          xpcObjectHelper& aHelper,
                                          const nsID* iid,
-                                         XPCNativeInterface** Interface,
                                          bool allowNativeWrapper,
                                          nsresult* pErr);
 
     static bool GetNativeInterfaceFromJSObject(void** dest, JSObject* src,
                                                const nsID* iid,
                                                nsresult* pErr);
     static bool JSObject2NativeInterface(void** dest, JS::HandleObject src,
                                          const nsID* iid,