xpcomproxy-gcalloc.patch
author benjamin@smedbergs.us
Thu, 29 Nov 2007 10:58:32 -0500
changeset 57 230d3f80e0bb18f55c4df42e2baefcd98e436b3d
parent 49 2dba947841b0525d01569a3133f4eb95a45a5d8e
child 84 1288e8ec20f77711058f7cd16268f9d1a00caf55
permissions -rw-r--r--
Merge related patches together and reorder

* * *
* * *

diff --git a/xpcom/proxy/src/nsProxyEvent.cpp b/xpcom/proxy/src/nsProxyEvent.cpp
--- a/xpcom/proxy/src/nsProxyEvent.cpp
+++ b/xpcom/proxy/src/nsProxyEvent.cpp
@@ -109,7 +109,6 @@ nsProxyCallCompletedEvent::QueryInterfac
     // needs to be allowed through during a synchronous proxy call.
     if (aIID.Equals(kFilterIID)) {
         *aResult = mInfo;
-        mInfo->AddRef();
         return NS_OK;
     }
     return nsRunnable::QueryInterface(aIID, aResult);
@@ -162,7 +161,6 @@ nsProxyObjectCallInfo::QueryInterface(RE
 {
     if (aIID.Equals(kFilterIID)) {
         *aResult = this;
-        AddRef();
         return NS_OK;
     }
     return nsRunnable::QueryInterface(aIID, aResult);
@@ -317,10 +315,6 @@ nsProxyObject::nsProxyObject(nsIEventTar
     NS_ASSERTION(target == canonicalTarget,
                  "Non-canonical nsISupports passed to nsProxyObject constructor");
 #endif
-
-    nsProxyObjectManager *pom = nsProxyObjectManager::GetInstance();
-    NS_ASSERTION(pom, "Creating a proxy without a global proxy-object-manager.");
-    pom->AddRef();
 }
 
 nsProxyObject::~nsProxyObject()
@@ -335,13 +329,11 @@ nsProxyObject::QueryInterface(REFNSIID a
 {
     if (aIID.Equals(GetIID())) {
         *aResult = this;
-        AddRef();
         return NS_OK;
     }
 
     if (aIID.Equals(NS_GET_IID(nsISupports))) {
         *aResult = static_cast<nsISupports*>(this);
-        AddRef();
         return NS_OK;
     }
 
diff --git a/xpcom/proxy/src/nsProxyEventClass.cpp b/xpcom/proxy/src/nsProxyEventClass.cpp
--- a/xpcom/proxy/src/nsProxyEventClass.cpp
+++ b/xpcom/proxy/src/nsProxyEventClass.cpp
@@ -70,10 +70,9 @@ nsProxyEventClass::nsProxyEventClass(REF
         if(methodCount)
         {
             int wordCount = (methodCount/32)+1;
-            if(NULL != (mDescriptors = new uint32[wordCount]))
-            {
-                memset(mDescriptors, 0, wordCount * sizeof(uint32));
-            }
+            mDescriptors = (uint32*)
+                NS_GetGC()->Alloc(wordCount * sizeof(uint32),
+                                  MMgc::GC::kZero);
         }
         else
         {
@@ -84,6 +83,4 @@ nsProxyEventClass::nsProxyEventClass(REF
 
 nsProxyEventClass::~nsProxyEventClass()
 {
-    if (mDescriptors && mDescriptors != &zero_methods_descriptor)
-        delete [] mDescriptors;
 }
diff --git a/xpcom/proxy/src/nsProxyEventPrivate.h b/xpcom/proxy/src/nsProxyEventPrivate.h
--- a/xpcom/proxy/src/nsProxyEventPrivate.h
+++ b/xpcom/proxy/src/nsProxyEventPrivate.h
@@ -51,7 +51,7 @@
 #include "nsCOMPtr.h"
 #include "nsThreadUtils.h"
 
-#include "nsClassHashtable.h"
+#include "nsInterfaceHashtable.h"
 #include "nsHashtable.h"
 
 #include "prmon.h"
@@ -81,7 +81,7 @@ typedef nsISupports nsISomeInterface;
  * An object representing an IID and its associated interfaceinfo. Instances
  * of this class are obtained via nsProxyObjectManager::GetClass.
  */
-class nsProxyEventClass
+class nsProxyEventClass : public XPCOMGCObject
 {
 public:
     nsIInterfaceInfo*        GetInterfaceInfo() const {return mInfo;}
@@ -92,7 +92,7 @@ public:
 
     nsIID                      mIID;
     nsCOMPtr<nsIInterfaceInfo> mInfo;
-    uint32*                    mDescriptors;
+    uint32*                    mDescriptors; // GC-allocated
 };
 
 /**
@@ -293,7 +293,7 @@ private:
 
     static nsProxyObjectManager* mInstance;
     nsHashtable  mProxyObjectMap;
-    nsClassHashtable<nsIDHashKey, nsProxyEventClass> mProxyClassMap;
+    nsInterfaceHashtable<nsIDHashKey, nsProxyEventClass> mProxyClassMap;
     PRLock *mProxyCreationLock;
 };