Bug 540858 part I: separate the refcount logging of NPObject (which works for both plugin and proxy NPObject) from ctor/dtor logging of ChildNPObject (proxy only), r=bent
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 22 Jan 2010 10:05:29 -0500
changeset 37476 d4d28cc35858af6c0007b61a057d628b12d3b8be
parent 37475 c1e297cb449ee147e27d078d6e0b067760782ac9
child 37477 7145c2f478d9b75b9afb03f7c8a5d6a875e84f2c
push id11325
push userbsmedberg@mozilla.com
push dateMon, 25 Jan 2010 14:50:07 +0000
treeherdermozilla-central@38e86af96757 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs540858
milestone1.9.3a1pre
Bug 540858 part I: separate the refcount logging of NPObject (which works for both plugin and proxy NPObject) from ctor/dtor logging of ChildNPObject (proxy only), r=bent
dom/plugins/PluginModuleChild.cpp
dom/plugins/PluginScriptableObjectChild.cpp
dom/plugins/PluginScriptableObjectChild.h
--- a/dom/plugins/PluginModuleChild.cpp
+++ b/dom/plugins/PluginModuleChild.cpp
@@ -1062,39 +1062,39 @@ NPObject* NP_CALLBACK
     }
     else {
         newObject = reinterpret_cast<NPObject*>(_memalloc(sizeof(NPObject)));
     }
 
     if (newObject) {
         newObject->_class = aClass;
         newObject->referenceCount = 1;
-        NS_LOG_ADDREF(newObject, 1, "ChildNPObject", sizeof(NPObject));
+        NS_LOG_ADDREF(newObject, 1, "NPObject", sizeof(NPObject));
     }
     return newObject;
 }
 
 NPObject* NP_CALLBACK
 _retainobject(NPObject* aNPObj)
 {
     AssertPluginThread();
 
     int32_t refCnt = PR_AtomicIncrement((PRInt32*)&aNPObj->referenceCount);
-    NS_LOG_ADDREF(aNPObj, refCnt, "ChildNPObject", sizeof(NPObject));
+    NS_LOG_ADDREF(aNPObj, refCnt, "NPObject", sizeof(NPObject));
 
     return aNPObj;
 }
 
 void NP_CALLBACK
 _releaseobject(NPObject* aNPObj)
 {
     AssertPluginThread();
 
     int32_t refCnt = PR_AtomicDecrement((PRInt32*)&aNPObj->referenceCount);
-    NS_LOG_RELEASE(aNPObj, refCnt, "ChildNPObject");
+    NS_LOG_RELEASE(aNPObj, refCnt, "NPObject");
 
     if (refCnt == 0) {
         if (aNPObj->_class && aNPObj->_class->deallocate) {
             aNPObj->_class->deallocate(aNPObj);
         } else {
             _memfree(aNPObj);
         }
     }
--- a/dom/plugins/PluginScriptableObjectChild.cpp
+++ b/dom/plugins/PluginScriptableObjectChild.cpp
@@ -530,17 +530,17 @@ PluginScriptableObjectChild::CreateProxy
   ChildNPObject* object = static_cast<ChildNPObject*>(npobject);
   NS_ASSERTION(!object->invalidated, "Bad object!");
   NS_ASSERTION(!object->parent, "Bad object!");
 
   // We don't want to have the actor own this object but rather let the object
   // own this actor. Set the reference count to 0 here so that when the object
   // dies we will send the destructor message to the child.
   object->referenceCount = 0;
-  NS_LOG_RELEASE(object, 0, "ChildNPObject");
+  NS_LOG_RELEASE(object, 0, "NPObject");
 
   object->parent = const_cast<PluginScriptableObjectChild*>(this);
   return object;
 }
 
 bool
 PluginScriptableObjectChild::ResurrectProxyObject()
 {
--- a/dom/plugins/PluginScriptableObjectChild.h
+++ b/dom/plugins/PluginScriptableObjectChild.h
@@ -47,17 +47,25 @@ namespace mozilla {
 namespace plugins {
 
 class PluginInstanceChild;
 class PluginScriptableObjectChild;
 
 struct ChildNPObject : NPObject
 {
   ChildNPObject()
-    : NPObject(), parent(NULL), invalidated(false) { }
+    : NPObject(), parent(NULL), invalidated(false)
+  {
+    MOZ_COUNT_CTOR(ChildNPObject);
+  }
+
+  ~ChildNPObject()
+  {
+    MOZ_COUNT_DTOR(ChildNPObject);
+  }
 
   // |parent| is always valid as long as the actor is alive. Once the actor is
   // destroyed this will be set to null.
   PluginScriptableObjectChild* parent;
   bool invalidated;
 };
 
 class PluginScriptableObjectChild : public PPluginScriptableObjectChild