Bug 996785 - Move global CPOW functions to top level (r=mrbkap)
authorBill McCloskey <wmccloskey@mozilla.com>
Fri, 16 May 2014 16:40:35 -0700
changeset 202862 48a84f76656dea28f489c306212c17a4b5edbff8
parent 202861 cb9571f1400bc39a5fa52b2ef8c901733d40ab17
child 202863 737d5beb60c4f59acd68bb233893b9188d55bf98
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs996785
milestone32.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 996785 - Move global CPOW functions to top level (r=mrbkap)
dom/bindings/BindingUtils.cpp
js/ipc/JavaScriptParent.cpp
js/ipc/JavaScriptParent.h
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCJSID.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -1902,19 +1902,19 @@ InterfaceHasInstance(JSContext* cx, JS::
 
   if (domClass &&
       domClass->mInterfaceChain[clasp->mDepth] == clasp->mPrototypeID) {
     *bp = true;
     return true;
   }
 
   JS::Rooted<JSObject*> unwrapped(cx, js::CheckedUnwrap(instance, true));
-  if (unwrapped && jsipc::JavaScriptParent::IsCPOW(unwrapped)) {
+  if (unwrapped && jsipc::IsCPOW(unwrapped)) {
     bool boolp = false;
-    if (!jsipc::JavaScriptParent::DOMInstanceOf(cx, unwrapped, clasp->mPrototypeID,
+    if (!jsipc::DOMInstanceOf(cx, unwrapped, clasp->mPrototypeID,
                                                 clasp->mDepth, &boolp)) {
       return false;
     }
     *bp = boolp;
     return true;
   }
 
   JS::Rooted<JS::Value> protov(cx);
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -25,24 +25,24 @@ JavaScriptParent::JavaScriptParent()
   : refcount_(1),
     inactive_(false)
 {
 }
 
 static inline JavaScriptParent *
 ParentOf(JSObject *obj)
 {
-    MOZ_ASSERT(JavaScriptParent::IsCPOW(obj));
+    MOZ_ASSERT(IsCPOW(obj));
     return reinterpret_cast<JavaScriptParent *>(GetProxyExtra(obj, 0).toPrivate());
 }
 
 ObjectId
 JavaScriptParent::idOf(JSObject *obj)
 {
-    MOZ_ASSERT(JavaScriptParent::IsCPOW(obj));
+    MOZ_ASSERT(IsCPOW(obj));
 
     Value v = GetProxyExtra(obj, 1);
     MOZ_ASSERT(v.isDouble());
 
     ObjectId objId = BitwiseCast<uint64_t>(v.toDouble());
     MOZ_ASSERT(findObject(objId) == obj);
     MOZ_ASSERT(objId);
 
@@ -642,31 +642,43 @@ JavaScriptParent::incref()
 }
 
 void
 JavaScriptParent::ActorDestroy(ActorDestroyReason why)
 {
     inactive_ = true;
 }
 
-/* static */ bool
-JavaScriptParent::IsCPOW(JSObject *obj)
+namespace mozilla {
+namespace jsipc {
+
+bool
+IsCPOW(JSObject *obj)
 {
     return IsProxy(obj) && GetProxyHandler(obj) == &CPOWProxyHandler::singleton;
 }
 
-/* static */ nsresult
-JavaScriptParent::InstanceOf(JSObject *proxy, const nsID *id, bool *bp)
+nsresult
+InstanceOf(JSObject *proxy, const nsID *id, bool *bp)
 {
     JavaScriptParent *parent = ParentOf(proxy);
     if (!parent->active())
         return NS_ERROR_UNEXPECTED;
     return parent->instanceOf(proxy, id, bp);
 }
 
+bool
+DOMInstanceOf(JSContext *cx, JSObject *proxy, int prototypeID, int depth, bool *bp)
+{
+    FORWARD(domInstanceOf, (cx, proxy, prototypeID, depth, bp));
+}
+
+} /* namespace jsipc */
+} /* namespace mozilla */
+
 nsresult
 JavaScriptParent::instanceOf(JSObject *obj, const nsID *id, bool *bp)
 {
     ObjectId objId = idOf(obj);
 
     JSIID iid;
     ConvertID(*id, &iid);
 
@@ -675,22 +687,16 @@ JavaScriptParent::instanceOf(JSObject *o
         return NS_ERROR_UNEXPECTED;
 
     if (status.type() != ReturnStatus::TReturnSuccess)
         return NS_ERROR_UNEXPECTED;
 
     return NS_OK;
 }
 
-/* static */ bool
-JavaScriptParent::DOMInstanceOf(JSContext *cx, JSObject *proxy, int prototypeID, int depth, bool *bp)
-{
-    FORWARD(domInstanceOf, (cx, proxy, prototypeID, depth, bp));
-}
-
 bool
 JavaScriptParent::domInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp)
 {
     ObjectId objId = idOf(obj);
 
     ReturnStatus status;
     if (!CallDOMInstanceOf(objId, prototypeID, depth, &status, bp))
         return ipcfail(cx);
--- a/js/ipc/JavaScriptParent.h
+++ b/js/ipc/JavaScriptParent.h
@@ -63,26 +63,22 @@ class JavaScriptParent
 
     void decref();
     void incref();
 
     bool active() { return !inactive_; }
 
     void drop(JSObject *obj);
 
-    static bool IsCPOW(JSObject *obj);
-
-    static nsresult InstanceOf(JSObject *obj, const nsID *id, bool *bp);
     nsresult instanceOf(JSObject *obj, const nsID *id, bool *bp);
 
     /*
      * Check that |obj| is a DOM wrapper whose prototype chain contains
      * |prototypeID| at depth |depth|.
      */
-    static bool DOMInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp);
     bool domInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp);
 
     mozilla::ipc::IProtocol*
     CloneProtocol(Channel* aChannel, ProtocolCloneContext* aCtx) MOZ_OVERRIDE;
 
   protected:
     JSObject *unwrap(JSContext *cx, ObjectId objId);
 
@@ -98,13 +94,22 @@ class JavaScriptParent
     // Check whether a return status is okay, and if not, propagate its error.
     bool ok(JSContext *cx, const ReturnStatus &status);
 
   private:
     uintptr_t refcount_;
     bool inactive_;
 };
 
+bool
+IsCPOW(JSObject *obj);
+
+nsresult
+InstanceOf(JSObject *obj, const nsID *id, bool *bp);
+
+bool
+DOMInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp);
+
 } // jsipc
 } // mozilla
 
 #endif // mozilla_jsipc_JavaScriptWrapper_h__
 
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -61,17 +61,17 @@ XPCConvert::IsMethodReflectable(const XP
 }
 
 static JSObject*
 UnwrapNativeCPOW(nsISupports* wrapper)
 {
     nsCOMPtr<nsIXPConnectWrappedJS> underware = do_QueryInterface(wrapper);
     if (underware) {
         JSObject* mainObj = underware->GetJSObject();
-        if (mainObj && mozilla::jsipc::JavaScriptParent::IsCPOW(mainObj))
+        if (mainObj && mozilla::jsipc::IsCPOW(mainObj))
             return mainObj;
     }
     return nullptr;
 }
 
 /***************************************************************************/
 
 // static
--- a/js/xpconnect/src/XPCJSID.cpp
+++ b/js/xpconnect/src/XPCJSID.cpp
@@ -460,17 +460,17 @@ nsJSIID::Enumerate(nsIXPConnectWrappedNa
  * DOM object, or null. The object may well be cross-compartment from |cx|.
  */
 static JSObject *
 FindObjectForHasInstance(JSContext *cx, HandleObject objArg)
 {
     RootedObject obj(cx, objArg), proto(cx);
 
     while (obj && !IS_WN_REFLECTOR(obj) &&
-           !IsDOMObject(obj) && !mozilla::jsipc::JavaScriptParent::IsCPOW(obj))
+           !IsDOMObject(obj) && !mozilla::jsipc::IsCPOW(obj))
     {
         if (js::IsWrapper(obj)) {
             obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
             continue;
         }
         if (!js::GetObjectProto(cx, obj, &proto))
             return nullptr;
         obj = proto;
@@ -482,18 +482,18 @@ nsresult
 xpc::HasInstance(JSContext *cx, HandleObject objArg, const nsID *iid, bool *bp)
 {
     *bp = false;
 
     RootedObject obj(cx, FindObjectForHasInstance(cx, objArg));
     if (!obj)
         return NS_OK;
 
-    if (mozilla::jsipc::JavaScriptParent::IsCPOW(obj))
-        return mozilla::jsipc::JavaScriptParent::InstanceOf(obj, iid, bp);
+    if (mozilla::jsipc::IsCPOW(obj))
+        return mozilla::jsipc::InstanceOf(obj, iid, bp);
 
     nsISupports *identity = UnwrapReflectorToISupports(obj);
     if (!identity)
         return NS_OK;
 
     nsCOMPtr<nsISupports> supp;
     identity->QueryInterface(*iid, getter_AddRefs(supp));
     *bp = supp;