NS_RootUntilShutdown
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 88 3c4963bbc6b89c5e784bc7f4017305a65bef9b3f
permissions -rw-r--r--
State as of now

diff --git a/xpcom/build/nsXPCOM.h b/xpcom/build/nsXPCOM.h
--- a/xpcom/build/nsXPCOM.h
+++ b/xpcom/build/nsXPCOM.h
@@ -66,6 +66,7 @@
 # define NS_CycleCollectorSuspect    NS_CycleCollectorSuspect_P
 # define NS_CycleCollectorForget     NS_CycleCollectorForget_P
 # define NS_GetGC                    NS_GetGC_P
+# define NS_RootUntilShutdown        NS_RootUntilShutdown_P
 #endif
 
 #include "nscore.h"
@@ -479,6 +480,9 @@
 NS_GetGC();
 #endif
 
+XPCOM_API(void)
+NS_RootUntilShutdown(void *obj);
+
 /**
  * Categories (in the category manager service) used by XPCOM:
  */
diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -3524,3 +3524,12 @@
     *result = nsComponentManagerImpl::gComponentManager->instance;
     return NS_OK;
 }
+
+void
+NS_RootUntilShutdown(void *obj)
+{
+    NS_ASSERTION(nsComponentManagerImpl::gComponentManager,
+                 "Not initialized.");
+
+    nsComponentManagerImpl::gComponentManager->extraRoots.AppendElement(obj);
+}
diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -179,6 +179,8 @@
         }
 
         nsComponentManagerImpl* instance;
+
+        nsVoidArrayBase<GCAllocator> extraRoots;
     };
 
     static Root *gComponentManager;
diff --git a/xpcom/stub/nsXPComStub.cpp b/xpcom/stub/nsXPComStub.cpp
--- a/xpcom/stub/nsXPComStub.cpp
+++ b/xpcom/stub/nsXPComStub.cpp
@@ -553,3 +553,10 @@
 {
   return NS_GetGC_P();
 }
+
+#undef NS_RootUntilShutdown
+EXPORT_XPCOM_API(void)
+NS_RootUntilShutdown(void *obj)
+{
+  NS_RootUntilShutdown_P(obj);
+}