Bug 996785 - Rename CPOW makeId/unwrap (r=mrbkap)
authorBill McCloskey <wmccloskey@mozilla.com>
Fri, 16 May 2014 16:40:35 -0700
changeset 183653 4b7c1b82d2aa722406acf8e83c75b3e2a8759503
parent 183652 9631faa6ed6754f5ab7b07ce40725e31482ec55f
child 183654 85e6824afa65a9ab3b1eb7afc705143a7d104f0a
push id6844
push userphilringnalda@gmail.com
push dateSun, 18 May 2014 01:12:08 +0000
treeherderfx-team@41a54c8add09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs996785
milestone32.0a1
Bug 996785 - Rename CPOW makeId/unwrap (r=mrbkap)
js/ipc/JavaScriptChild.cpp
js/ipc/JavaScriptChild.h
js/ipc/JavaScriptParent.cpp
js/ipc/JavaScriptParent.h
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptShared.h
--- a/js/ipc/JavaScriptChild.cpp
+++ b/js/ipc/JavaScriptChild.cpp
@@ -62,17 +62,17 @@ JavaScriptChild::RecvDropObject(const Ob
     if (obj) {
         ids_.remove(obj);
         objects_.remove(objId);
     }
     return true;
 }
 
 bool
-JavaScriptChild::makeId(JSContext *cx, JSObject *obj, ObjectId *idp)
+JavaScriptChild::toId(JSContext *cx, JSObject *obj, ObjectId *idp)
 {
     if (!obj) {
         *idp = 0;
         return true;
     }
 
     ObjectId id = ids_.find(obj);
     if (id) {
@@ -95,17 +95,17 @@ JavaScriptChild::makeId(JSContext *cx, J
     if (!ids_.add(cx, obj, id))
         return false;
 
     *idp = id;
     return true;
 }
 
 JSObject *
-JavaScriptChild::unwrap(JSContext *cx, ObjectId id)
+JavaScriptChild::fromId(JSContext *cx, ObjectId id)
 {
     JSObject *obj = findObjectById(id);
     MOZ_ASSERT(obj);
     return obj;
 }
 
 bool
 JavaScriptChild::fail(JSContext *cx, ReturnStatus *rs)
--- a/js/ipc/JavaScriptChild.h
+++ b/js/ipc/JavaScriptChild.h
@@ -63,21 +63,20 @@ class JavaScriptChild
 
     bool AnswerGetPropertyNames(const ObjectId &objId, const uint32_t &flags,
                                 ReturnStatus *rs, nsTArray<nsString> *names) MOZ_OVERRIDE;
     bool AnswerInstanceOf(const ObjectId &objId, const JSIID &iid,
                           ReturnStatus *rs, bool *instanceof) MOZ_OVERRIDE;
     bool AnswerDOMInstanceOf(const ObjectId &objId, const int &prototypeID, const int &depth,
                              ReturnStatus *rs, bool *instanceof) MOZ_OVERRIDE;
 
-  protected:
-    JSObject *unwrap(JSContext *cx, ObjectId id);
+  private:
+    JSObject *fromId(JSContext *cx, ObjectId id);
+    bool toId(JSContext *cx, JSObject *obj, ObjectId *idp);
 
-  private:
-    bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp);
     bool fail(JSContext *cx, ReturnStatus *rs);
     bool ok(ReturnStatus *rs);
 
   private:
     ObjectId lastId_;
     JSRuntime *rt_;
     ObjectToIdMap ids_;
 };
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -521,17 +521,17 @@ JavaScriptParent::init()
 {
     if (!JavaScriptShared::init())
         return false;
 
     return true;
 }
 
 bool
-JavaScriptParent::makeId(JSContext *cx, JSObject *obj, ObjectId *idp)
+JavaScriptParent::toId(JSContext *cx, JSObject *obj, ObjectId *idp)
 {
     obj = js::CheckedUnwrap(obj, false);
     if (!obj || !IsProxy(obj) || GetProxyHandler(obj) != &CPOWProxyHandler::singleton) {
         JS_ReportError(cx, "cannot ipc non-cpow object");
         return false;
     }
 
     *idp = idOf(obj);
@@ -557,17 +557,17 @@ JavaScriptParent::getPropertyNames(JSCon
         if (!props.append(name))
             return false;
     }
 
     return true;
 }
 
 JSObject *
-JavaScriptParent::unwrap(JSContext *cx, ObjectId objId)
+JavaScriptParent::fromId(JSContext *cx, ObjectId objId)
 {
     RootedObject obj(cx, findCPOWById(objId));
     if (obj) {
         if (!JS_WrapObject(cx, &obj))
             return nullptr;
         return obj;
     }
 
--- a/js/ipc/JavaScriptParent.h
+++ b/js/ipc/JavaScriptParent.h
@@ -74,21 +74,20 @@ class JavaScriptParent
      * Check that |obj| is a DOM wrapper whose prototype chain contains
      * |prototypeID| at depth |depth|.
      */
     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);
+  private:
+    JSObject *fromId(JSContext *cx, ObjectId objId);
+    bool toId(JSContext *cx, JSObject *obj, ObjectId *idp);
 
-  private:
-    bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp);
     bool getPropertyNames(JSContext *cx, JS::HandleObject proxy, uint32_t flags,
                           JS::AutoIdVector &props);
     ObjectId idOf(JSObject *obj);
 
     // Catastrophic IPC failure.
     bool ipcfail(JSContext *cx);
 
     // Check whether a return status is okay, and if not, propagate its error.
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -190,17 +190,17 @@ JavaScriptShared::toVariant(JSContext *c
             JSIID iid;
             const nsID *id = xpc_JSObjectToID(cx, obj);
             ConvertID(*id, &iid);
             *to = iid;
             return true;
         }
 
         ObjectId id;
-        if (!makeId(cx, obj, &id))
+        if (!toId(cx, obj, &id))
             return false;
         *to = uint64_t(id);
         return true;
       }
 
       case JSTYPE_STRING:
       {
         nsDependentJSString dep;
@@ -234,17 +234,17 @@ JavaScriptShared::fromVariant(JSContext 
         case JSVariant::Tvoid_t:
           to.set(UndefinedValue());
           return true;
 
         case JSVariant::Tuint64_t:
         {
           ObjectId id = from.get_uint64_t();
           if (id) {
-              JSObject *obj = unwrap(cx, id);
+              JSObject *obj = fromId(cx, id);
               if (!obj)
                   return false;
               to.set(ObjectValue(*obj));
           } else {
               to.set(JSVAL_NULL);
           }
           return true;
         }
@@ -326,37 +326,37 @@ static const uint32_t UnknownPropertyOp 
 bool
 JavaScriptShared::fromDescriptor(JSContext *cx, Handle<JSPropertyDescriptor> desc,
                                  PPropertyDescriptor *out)
 {
     out->attrs() = desc.attributes();
     if (!toVariant(cx, desc.value(), &out->value()))
         return false;
 
-    if (!makeId(cx, desc.object(), &out->objId()))
+    if (!toId(cx, desc.object(), &out->objId()))
         return false;
 
     if (!desc.getter()) {
         out->getter() = 0;
     } else if (desc.hasGetterObject()) {
         JSObject *getter = desc.getterObject();
-        if (!makeId(cx, getter, &out->getter()))
+        if (!toId(cx, getter, &out->getter()))
             return false;
     } else {
         if (desc.getter() == JS_PropertyStub)
             out->getter() = DefaultPropertyOp;
         else
             out->getter() = UnknownPropertyOp;
     }
 
     if (!desc.setter()) {
         out->setter() = 0;
     } else if (desc.hasSetterObject()) {
         JSObject *setter = desc.setterObject();
-        if (!makeId(cx, setter, &out->setter()))
+        if (!toId(cx, setter, &out->setter()))
             return false;
     } else {
         if (desc.setter() == JS_StrictPropertyStub)
             out->setter() = DefaultPropertyOp;
         else if (desc.setter() == js_GetterOnlyPropertyStub)
             out->setter() = GetterOnlyPropertyStub;
         else
             out->setter() = UnknownPropertyOp;
@@ -382,39 +382,39 @@ UnknownStrictPropertyStub(JSContext *cx,
 bool
 JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
                                MutableHandle<JSPropertyDescriptor> out)
 {
     out.setAttributes(in.attrs());
     if (!fromVariant(cx, in.value(), out.value()))
         return false;
     Rooted<JSObject*> obj(cx);
-    if (!unwrap(cx, in.objId(), &obj))
+    if (!fromId(cx, in.objId(), &obj))
         return false;
     out.object().set(obj);
 
     if (!in.getter()) {
         out.setGetter(nullptr);
     } else if (in.attrs() & JSPROP_GETTER) {
         Rooted<JSObject*> getter(cx);
-        if (!unwrap(cx, in.getter(), &getter))
+        if (!fromId(cx, in.getter(), &getter))
             return false;
         out.setGetter(JS_DATA_TO_FUNC_PTR(JSPropertyOp, getter.get()));
     } else {
         if (in.getter() == DefaultPropertyOp)
             out.setGetter(JS_PropertyStub);
         else
             out.setGetter(UnknownPropertyStub);
     }
 
     if (!in.setter()) {
         out.setSetter(nullptr);
     } else if (in.attrs() & JSPROP_SETTER) {
         Rooted<JSObject*> setter(cx);
-        if (!unwrap(cx, in.setter(), &setter))
+        if (!fromId(cx, in.setter(), &setter))
             return false;
         out.setSetter(JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, setter.get()));
     } else {
         if (in.setter() == DefaultPropertyOp)
             out.setSetter(JS_StrictPropertyStub);
         else if (in.setter() == GetterOnlyPropertyStub)
             out.setSetter(js_GetterOnlyPropertyStub);
         else
--- a/js/ipc/JavaScriptShared.h
+++ b/js/ipc/JavaScriptShared.h
@@ -98,26 +98,26 @@ class JavaScriptShared
     bool fromDescriptor(JSContext *cx, JS::Handle<JSPropertyDescriptor> desc,
                         PPropertyDescriptor *out);
     bool toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
                       JS::MutableHandle<JSPropertyDescriptor> out);
 
     bool convertIdToGeckoString(JSContext *cx, JS::HandleId id, nsString *to);
     bool convertGeckoStringToId(JSContext *cx, const nsString &from, JS::MutableHandleId id);
 
-    virtual bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp) = 0;
-    virtual JSObject *unwrap(JSContext *cx, ObjectId id) = 0;
+    virtual bool toId(JSContext *cx, JSObject *obj, ObjectId *idp) = 0;
+    virtual JSObject *fromId(JSContext *cx, ObjectId id) = 0;
 
-    bool unwrap(JSContext *cx, ObjectId id, JS::MutableHandle<JSObject*> objp) {
+    bool fromId(JSContext *cx, ObjectId id, JS::MutableHandle<JSObject*> objp) {
         if (!id) {
             objp.set(nullptr);
             return true;
         }
 
-        objp.set(unwrap(cx, id));
+        objp.set(fromId(cx, id));
         return bool(objp.get());
     }
 
     static void ConvertID(const nsID &from, JSIID *to);
     static void ConvertID(const JSIID &from, nsID *to);
 
     JSObject *findCPOWById(uint32_t objId) {
         return objects_.find(objId);