mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 896414 - Make nsDirectoryService::mHashtable an nsInterfaceHashtable; r=bsmedberg
This commit is contained in:
parent
4f51466484
commit
adbb8bab14
@ -219,9 +219,9 @@ nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
|
||||
|
||||
nsDirectoryService* nsDirectoryService::gService = nullptr;
|
||||
|
||||
nsDirectoryService::nsDirectoryService() :
|
||||
mHashtable(256, true)
|
||||
nsDirectoryService::nsDirectoryService()
|
||||
{
|
||||
mHashtable.Init(256);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -276,14 +276,6 @@ nsDirectoryService::RealInit()
|
||||
self.swap(gService);
|
||||
}
|
||||
|
||||
bool
|
||||
nsDirectoryService::ReleaseValues(nsHashKey* key, void* data, void* closure)
|
||||
{
|
||||
nsISupports* value = (nsISupports*)data;
|
||||
NS_IF_RELEASE(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
nsDirectoryService::~nsDirectoryService()
|
||||
{
|
||||
}
|
||||
@ -296,11 +288,11 @@ nsDirectoryService::Undefine(const char* prop)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
|
||||
nsCStringKey key(prop);
|
||||
if (!mHashtable.Exists(&key))
|
||||
nsDependentCString key(prop);
|
||||
if (!mHashtable.Get(key, nullptr))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mHashtable.Remove (&key);
|
||||
mHashtable.Remove(key);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -372,17 +364,12 @@ nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
|
||||
nsCStringKey key(prop);
|
||||
nsDependentCString key(prop);
|
||||
|
||||
nsCOMPtr<nsISupports> value = dont_AddRef(mHashtable.Get(&key));
|
||||
nsCOMPtr<nsIFile> cachedFile = mHashtable.Get(key);
|
||||
|
||||
if (value)
|
||||
{
|
||||
if (cachedFile) {
|
||||
nsCOMPtr<nsIFile> cloneFile;
|
||||
nsCOMPtr<nsIFile> cachedFile = do_QueryInterface(value);
|
||||
NS_ASSERTION(cachedFile,
|
||||
"nsDirectoryService::Get nsIFile expected");
|
||||
|
||||
cachedFile->Clone(getter_AddRefs(cloneFile));
|
||||
return cloneFile->QueryInterface(uuid, result);
|
||||
}
|
||||
@ -426,17 +413,16 @@ nsDirectoryService::Set(const char* prop, nsISupports* value)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
|
||||
nsCStringKey key(prop);
|
||||
if (mHashtable.Exists(&key) || value == nullptr)
|
||||
nsDependentCString key(prop);
|
||||
if (mHashtable.Get(key, nullptr) || !value) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> ourFile;
|
||||
value->QueryInterface(NS_GET_IID(nsIFile), getter_AddRefs(ourFile));
|
||||
if (ourFile)
|
||||
{
|
||||
nsCOMPtr<nsIFile> ourFile = do_QueryInterface(value);
|
||||
if (ourFile) {
|
||||
nsCOMPtr<nsIFile> cloneFile;
|
||||
ourFile->Clone (getter_AddRefs (cloneFile));
|
||||
mHashtable.Put(&key, cloneFile);
|
||||
mHashtable.Put(key, cloneFile);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define nsDirectoryService_h___
|
||||
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsTArray.h"
|
||||
@ -48,8 +48,7 @@ class nsDirectoryService MOZ_FINAL : public nsIDirectoryService,
|
||||
private:
|
||||
nsresult GetCurrentProcessDirectory(nsIFile** aFile);
|
||||
|
||||
static bool ReleaseValues(nsHashKey* key, void* data, void* closure);
|
||||
nsSupportsHashtable mHashtable;
|
||||
nsInterfaceHashtable<nsCStringHashKey, nsIFile> mHashtable;
|
||||
nsTArray<nsCOMPtr<nsIDirectoryServiceProvider> > mProviders;
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user