mark-dirservice
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/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -65,6 +65,7 @@
 #include "nsDirectoryServiceDefs.h"
 #include "nsCategoryManager.h"
 #include "nsCategoryManagerUtils.h"
+#include "nsHashtable.h"
 #include "nsIEnumerator.h"
 #include "xptiprivate.h"
 #include "nsIConsoleService.h"
diff --git a/xpcom/io/nsDirectoryService.cpp b/xpcom/io/nsDirectoryService.cpp
--- a/xpcom/io/nsDirectoryService.cpp
+++ b/xpcom/io/nsDirectoryService.cpp
@@ -369,9 +369,9 @@ nsIAtom*  nsDirectoryService::sSystemDir
 
 nsDirectoryService* nsDirectoryService::gService = nsnull;
 
-nsDirectoryService::nsDirectoryService() :
-    mHashtable(256, PR_TRUE)
+nsDirectoryService::nsDirectoryService()
 {
+    mHashtable.Init(256);
 }
 
 NS_METHOD
@@ -512,14 +512,6 @@ nsDirectoryService::RealInit()
     return NS_OK;
 }
 
-PRBool
-nsDirectoryService::ReleaseValues(nsHashKey* key, void* data, void* closure)
-{
-    nsISupports* value = (nsISupports*)data;
-    NS_IF_RELEASE(value);
-    return PR_TRUE;
-}
-
 nsDirectoryService::~nsDirectoryService()
 {
 }
@@ -532,11 +524,10 @@ nsDirectoryService::Undefine(const char*
 {
     NS_ENSURE_ARG(prop);
 
-    nsCStringKey key(prop);
-    if (!mHashtable.Exists(&key))
+    if (!mHashtable.GetWeak(prop))
         return NS_ERROR_FAILURE;
 
-    mHashtable.Remove (&key);
+    mHashtable.Remove(prop);
     return NS_OK;
  }
 
@@ -612,9 +603,7 @@ nsDirectoryService::Get(const char* prop
 {
     NS_ENSURE_ARG(prop);
 
-    nsCStringKey key(prop);
-    
-    nsCOMPtr<nsISupports> value = dont_AddRef(mHashtable.Get(&key));
+    nsIFile* value = mHashtable.GetWeak(prop);
     
     if (value)
     {
@@ -662,17 +651,16 @@ nsDirectoryService::Set(const char* prop
 {
     NS_ENSURE_ARG(prop);
 
-    nsCStringKey key(prop);
-    if (mHashtable.Exists(&key) || value == nsnull)
+    if (mHashtable.GetWeak(prop) || value == nsnull)
         return NS_ERROR_FAILURE;
 
     nsCOMPtr<nsIFile> ourFile;
     value->QueryInterface(NS_GET_IID(nsIFile), getter_AddRefs(ourFile));
     if (ourFile)
     {
-      nsCOMPtr<nsIFile> cloneFile;
-      ourFile->Clone (getter_AddRefs (cloneFile));
-      mHashtable.Put(&key, cloneFile);
+      nsIFile* cloneFile = nsnull;
+      ourFile->Clone (&cloneFile);
+      mHashtable.Put(prop, cloneFile);
 
       return NS_OK;
     }
diff --git a/xpcom/io/nsDirectoryService.h b/xpcom/io/nsDirectoryService.h
--- a/xpcom/io/nsDirectoryService.h
+++ b/xpcom/io/nsDirectoryService.h
@@ -40,7 +40,7 @@
 #define nsDirectoryService_h___
 
 #include "nsIDirectoryService.h"
-#include "nsHashtable.h"
+#include "nsInterfaceHashtable.h"
 #include "nsILocalFile.h"
 #include "nsISupportsArray.h"
 #include "nsIAtom.h"
@@ -80,8 +80,7 @@ private:
 private:
     nsresult GetCurrentProcessDirectory(nsILocalFile** aFile);
     
-    static PRBool PR_CALLBACK ReleaseValues(nsHashKey* key, void* data, void* closure);
-    nsSupportsHashtable mHashtable;
+    nsInterfaceHashtable<nsCharPtrHashKey, nsIFile> mHashtable;
     nsCOMPtr<nsISupportsArray> mProviders;
 
 public: