mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 20:22:00 +00:00
bug 860027 - export a header declaring XPTInterfaceInfoManager r=bsmedberg
This commit is contained in:
parent
d61ea30a20
commit
3f28a1017c
@ -48,6 +48,7 @@
|
||||
#include "xptinfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptiprivate.h"
|
||||
#include "mozilla/XPTInterfaceInfoManager.h"
|
||||
|
||||
#include "nsTimerImpl.h"
|
||||
#include "TimerThread.h"
|
||||
@ -126,6 +127,7 @@ extern nsresult nsStringInputStreamConstructor(nsISupports *, REFNSIID, void **)
|
||||
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using base::AtExitManager;
|
||||
using mozilla::ipc::BrowserProcessSubThread;
|
||||
#ifdef MOZ_VISUAL_EVENT_TRACER
|
||||
@ -228,7 +230,7 @@ nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* outer,
|
||||
NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim
|
||||
(xptiInterfaceInfoManager::GetSingleton());
|
||||
(XPTInterfaceInfoManager::GetSingleton());
|
||||
if (!iim)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -470,7 +472,7 @@ NS_InitXPCOM2(nsIServiceManager* *result,
|
||||
|
||||
// The iimanager constructor searches and registers XPT files.
|
||||
// (We trigger the singleton's lazy construction here to make that happen.)
|
||||
(void) xptiInterfaceInfoManager::GetSingleton();
|
||||
(void) XPTInterfaceInfoManager::GetSingleton();
|
||||
|
||||
// After autoreg, but before we actually instantiate any components,
|
||||
// add any services listed in the "xpcom-directory-providers" category
|
||||
@ -688,7 +690,7 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
|
||||
// Do this _after_ shutting down the component manager, because the
|
||||
// JS component loader will use XPConnect to call nsIModule::canUnload,
|
||||
// and that will spin up the InterfaceInfoManager again -- bad mojo
|
||||
xptiInterfaceInfoManager::FreeInterfaceInfoManager();
|
||||
XPTInterfaceInfoManager::FreeInterfaceInfoManager();
|
||||
|
||||
// Finally, release the component manager last because it unloads the
|
||||
// libraries:
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "nsCategoryManager.h"
|
||||
#include "nsCategoryManagerUtils.h"
|
||||
#include "xptiprivate.h"
|
||||
#include "mozilla/XPTInterfaceInfoManager.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIObserverService.h"
|
||||
@ -613,8 +614,7 @@ nsComponentManagerImpl::ManifestXPT(ManifestProcessingContext& cx, int lineno, c
|
||||
rv = data.Copy(buf, len);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
xptiInterfaceInfoManager::GetSingleton()
|
||||
->RegisterBuffer(buf, len);
|
||||
XPTInterfaceInfoManager::GetSingleton()->RegisterBuffer(buf, len);
|
||||
} else {
|
||||
nsCString uri;
|
||||
f.GetURIString(uri);
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptiprivate.h"
|
||||
#include "mozilla/XPTInterfaceInfoManager.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPTCStubBase::QueryInterface(REFNSIID aIID,
|
||||
@ -39,8 +42,8 @@ NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
|
||||
{
|
||||
NS_ENSURE_ARG(aOuter && aResult);
|
||||
|
||||
xptiInterfaceInfoManager *iim =
|
||||
xptiInterfaceInfoManager::GetSingleton();
|
||||
XPTInterfaceInfoManager *iim =
|
||||
XPTInterfaceInfoManager::GetSingleton();
|
||||
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
xptiInterfaceEntry *iie = iim->GetInterfaceEntryForIID(&aIID);
|
||||
|
@ -15,6 +15,11 @@ EXPORTS = \
|
||||
xptinfo.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS_NAMESPACES := mozilla
|
||||
EXPORTS_mozilla := \
|
||||
XPTInterfaceInfoManager.h \
|
||||
$(null)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
114
xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h
Normal file
114
xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h
Normal file
@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=4 et sw=4 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_XPTInterfaceInfoManager_h_
|
||||
#define mozilla_XPTInterfaceInfoManager_h_
|
||||
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/ReentrantMonitor.h"
|
||||
#include "nsDataHashtable.h"
|
||||
|
||||
template<typename T> class nsCOMArray;
|
||||
class XPTHeader;
|
||||
class XPTInterfaceDirectoryEntry;
|
||||
class xptiInterfaceEntry;
|
||||
class xptiInterfaceInfo;
|
||||
class xptiTypelibGuts;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class XPTInterfaceInfoManager MOZ_FINAL
|
||||
: public nsIInterfaceInfoManager
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEINFOMANAGER
|
||||
|
||||
public:
|
||||
// GetSingleton() is infallible
|
||||
static XPTInterfaceInfoManager* GetSingleton();
|
||||
static void FreeInterfaceInfoManager();
|
||||
|
||||
void GetScriptableInterfaces(nsCOMArray<nsIInterfaceInfo>& aInterfaces);
|
||||
|
||||
void RegisterBuffer(char *buf, uint32_t length);
|
||||
|
||||
static Mutex& GetResolveLock()
|
||||
{
|
||||
return GetSingleton()->mResolveLock;
|
||||
}
|
||||
|
||||
xptiInterfaceEntry* GetInterfaceEntryForIID(const nsIID *iid);
|
||||
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
|
||||
|
||||
static int64_t GetXPTIWorkingSetSize();
|
||||
|
||||
private:
|
||||
XPTInterfaceInfoManager();
|
||||
~XPTInterfaceInfoManager();
|
||||
|
||||
void RegisterXPTHeader(XPTHeader* aHeader);
|
||||
|
||||
// idx is the index of this interface in the XPTHeader
|
||||
void VerifyAndAddEntryIfNew(XPTInterfaceDirectoryEntry* iface,
|
||||
uint16_t idx,
|
||||
xptiTypelibGuts* typelib);
|
||||
|
||||
private:
|
||||
|
||||
class xptiWorkingSet
|
||||
{
|
||||
public:
|
||||
xptiWorkingSet();
|
||||
~xptiWorkingSet();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
void InvalidateInterfaceInfos();
|
||||
void ClearHashTables();
|
||||
|
||||
// utility methods...
|
||||
|
||||
enum {NOT_FOUND = 0xffffffff};
|
||||
|
||||
// Directory stuff...
|
||||
|
||||
uint32_t GetDirectoryCount();
|
||||
nsresult GetCloneOfDirectoryAt(uint32_t i, nsIFile** dir);
|
||||
nsresult GetDirectoryAt(uint32_t i, nsIFile** dir);
|
||||
bool FindDirectory(nsIFile* dir, uint32_t* index);
|
||||
bool FindDirectoryOfFile(nsIFile* file, uint32_t* index);
|
||||
bool DirectoryAtMatchesPersistentDescriptor(uint32_t i, const char* desc);
|
||||
|
||||
private:
|
||||
uint32_t mFileCount;
|
||||
uint32_t mMaxFileCount;
|
||||
|
||||
public:
|
||||
// XXX make these private with accessors
|
||||
// mTableMonitor must be held across:
|
||||
// * any read from or write to mIIDTable or mNameTable
|
||||
// * any writing to the links between an xptiInterfaceEntry
|
||||
// and its xptiInterfaceInfo (mEntry/mInfo)
|
||||
mozilla::ReentrantMonitor mTableReentrantMonitor;
|
||||
nsDataHashtable<nsIDHashKey, xptiInterfaceEntry*> mIIDTable;
|
||||
nsDataHashtable<nsDepCharHashKey, xptiInterfaceEntry*> mNameTable;
|
||||
};
|
||||
|
||||
// XXX xptiInterfaceInfo want's to poke at the working set itself
|
||||
friend class ::xptiInterfaceInfo;
|
||||
friend class ::xptiInterfaceEntry;
|
||||
friend class ::xptiTypelibGuts;
|
||||
|
||||
xptiWorkingSet mWorkingSet;
|
||||
Mutex mResolveLock;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -6,6 +6,7 @@
|
||||
/* Implementation of xptiInterfaceEntry and xptiInterfaceInfo. */
|
||||
|
||||
#include "xptiprivate.h"
|
||||
#include "mozilla/XPTInterfaceInfoManager.h"
|
||||
#include "nsAtomicRefcnt.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -70,7 +71,7 @@ xptiInterfaceEntry::xptiInterfaceEntry(const char* name,
|
||||
bool
|
||||
xptiInterfaceEntry::Resolve()
|
||||
{
|
||||
MutexAutoLock lock(xptiInterfaceInfoManager::GetResolveLock());
|
||||
MutexAutoLock lock(XPTInterfaceInfoManager::GetResolveLock());
|
||||
return ResolveLocked();
|
||||
}
|
||||
|
||||
@ -540,7 +541,7 @@ nsresult
|
||||
xptiInterfaceEntry::GetInterfaceInfo(xptiInterfaceInfo** info)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
xptiInterfaceInfoManager::GetSingleton()->GetWorkingSet()->mTableReentrantMonitor.
|
||||
XPTInterfaceInfoManager::GetSingleton()->mWorkingSet.mTableReentrantMonitor.
|
||||
AssertCurrentThreadIn();
|
||||
#endif
|
||||
LOG_INFO_MONITOR_ENTRY;
|
||||
@ -572,8 +573,8 @@ xptiInterfaceEntry::LockedInvalidateInterfaceInfo()
|
||||
bool
|
||||
xptiInterfaceInfo::BuildParent()
|
||||
{
|
||||
mozilla::ReentrantMonitorAutoEnter monitor(xptiInterfaceInfoManager::GetSingleton()->
|
||||
GetWorkingSet()->mTableReentrantMonitor);
|
||||
mozilla::ReentrantMonitorAutoEnter monitor(XPTInterfaceInfoManager::GetSingleton()->
|
||||
mWorkingSet.mTableReentrantMonitor);
|
||||
NS_ASSERTION(mEntry &&
|
||||
mEntry->IsFullyResolved() &&
|
||||
!mParent &&
|
||||
@ -615,8 +616,8 @@ xptiInterfaceInfo::Release(void)
|
||||
NS_LOG_RELEASE(this, cnt, "xptiInterfaceInfo");
|
||||
if(!cnt)
|
||||
{
|
||||
mozilla::ReentrantMonitorAutoEnter monitor(xptiInterfaceInfoManager::
|
||||
GetSingleton()->GetWorkingSet()->
|
||||
mozilla::ReentrantMonitorAutoEnter monitor(XPTInterfaceInfoManager::
|
||||
GetSingleton()->mWorkingSet.
|
||||
mTableReentrantMonitor);
|
||||
LOG_INFO_MONITOR_ENTRY;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
/* Implementation of xptiInterfaceInfoManager. */
|
||||
|
||||
#include "mozilla/XPTInterfaceInfoManager.h"
|
||||
|
||||
#include "xptiprivate.h"
|
||||
#include "nsDependentString.h"
|
||||
#include "nsString.h"
|
||||
@ -16,10 +18,10 @@
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(xptiInterfaceInfoManager,
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(XPTInterfaceInfoManager,
|
||||
nsIInterfaceInfoManager)
|
||||
|
||||
static xptiInterfaceInfoManager* gInterfaceInfoManager = nullptr;
|
||||
static XPTInterfaceInfoManager* gInterfaceInfoManager = nullptr;
|
||||
#ifdef DEBUG
|
||||
static int gCallCount = 0;
|
||||
#endif
|
||||
@ -28,7 +30,7 @@ static int gCallCount = 0;
|
||||
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(XPTMallocSizeOf)
|
||||
|
||||
size_t
|
||||
xptiInterfaceInfoManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
XPTInterfaceInfoManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
{
|
||||
size_t n = aMallocSizeOf(this);
|
||||
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
|
||||
@ -41,7 +43,7 @@ xptiInterfaceInfoManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
|
||||
// static
|
||||
int64_t
|
||||
xptiInterfaceInfoManager::GetXPTIWorkingSetSize()
|
||||
XPTInterfaceInfoManager::GetXPTIWorkingSetSize()
|
||||
{
|
||||
size_t n = XPT_SizeOfArena(gXPTIStructArena, XPTMallocSizeOf);
|
||||
|
||||
@ -52,38 +54,38 @@ xptiInterfaceInfoManager::GetXPTIWorkingSetSize()
|
||||
return n;
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(xptiWorkingSet,
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(XPTInterfaceInfoManager,
|
||||
"explicit/xpti-working-set",
|
||||
KIND_HEAP,
|
||||
UNITS_BYTES,
|
||||
xptiInterfaceInfoManager::GetXPTIWorkingSetSize,
|
||||
XPTInterfaceInfoManager::GetXPTIWorkingSetSize,
|
||||
"Memory used by the XPCOM typelib system.")
|
||||
|
||||
// static
|
||||
xptiInterfaceInfoManager*
|
||||
xptiInterfaceInfoManager::GetSingleton()
|
||||
XPTInterfaceInfoManager*
|
||||
XPTInterfaceInfoManager::GetSingleton()
|
||||
{
|
||||
if (!gInterfaceInfoManager) {
|
||||
gInterfaceInfoManager = new xptiInterfaceInfoManager();
|
||||
gInterfaceInfoManager = new XPTInterfaceInfoManager();
|
||||
NS_ADDREF(gInterfaceInfoManager);
|
||||
}
|
||||
return gInterfaceInfoManager;
|
||||
}
|
||||
|
||||
void
|
||||
xptiInterfaceInfoManager::FreeInterfaceInfoManager()
|
||||
XPTInterfaceInfoManager::FreeInterfaceInfoManager()
|
||||
{
|
||||
NS_IF_RELEASE(gInterfaceInfoManager);
|
||||
}
|
||||
|
||||
xptiInterfaceInfoManager::xptiInterfaceInfoManager()
|
||||
XPTInterfaceInfoManager::XPTInterfaceInfoManager()
|
||||
: mWorkingSet(),
|
||||
mResolveLock("xptiInterfaceInfoManager.mResolveLock")
|
||||
mResolveLock("XPTInterfaceInfoManager.mResolveLock")
|
||||
{
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(xptiWorkingSet));
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPTInterfaceInfoManager));
|
||||
}
|
||||
|
||||
xptiInterfaceInfoManager::~xptiInterfaceInfoManager()
|
||||
XPTInterfaceInfoManager::~XPTInterfaceInfoManager()
|
||||
{
|
||||
// We only do this on shutdown of the service.
|
||||
mWorkingSet.InvalidateInterfaceInfos();
|
||||
@ -95,7 +97,7 @@ xptiInterfaceInfoManager::~xptiInterfaceInfoManager()
|
||||
}
|
||||
|
||||
void
|
||||
xptiInterfaceInfoManager::RegisterBuffer(char *buf, uint32_t length)
|
||||
XPTInterfaceInfoManager::RegisterBuffer(char *buf, uint32_t length)
|
||||
{
|
||||
XPTState *state = XPT_NewXDRState(XPT_DECODE, buf, length);
|
||||
if (!state)
|
||||
@ -116,7 +118,7 @@ xptiInterfaceInfoManager::RegisterBuffer(char *buf, uint32_t length)
|
||||
}
|
||||
|
||||
void
|
||||
xptiInterfaceInfoManager::RegisterXPTHeader(XPTHeader* aHeader)
|
||||
XPTInterfaceInfoManager::RegisterXPTHeader(XPTHeader* aHeader)
|
||||
{
|
||||
if (aHeader->major_version >= XPT_MAJOR_INCOMPATIBLE_VERSION) {
|
||||
NS_ASSERTION(!aHeader->num_interfaces,"bad libxpt");
|
||||
@ -131,9 +133,9 @@ xptiInterfaceInfoManager::RegisterXPTHeader(XPTHeader* aHeader)
|
||||
}
|
||||
|
||||
void
|
||||
xptiInterfaceInfoManager::VerifyAndAddEntryIfNew(XPTInterfaceDirectoryEntry* iface,
|
||||
uint16_t idx,
|
||||
xptiTypelibGuts* typelib)
|
||||
XPTInterfaceInfoManager::VerifyAndAddEntryIfNew(XPTInterfaceDirectoryEntry* iface,
|
||||
uint16_t idx,
|
||||
xptiTypelibGuts* typelib)
|
||||
{
|
||||
if (!iface->interface_descriptor)
|
||||
return;
|
||||
@ -199,14 +201,15 @@ EntryToInfo(xptiInterfaceEntry* entry, nsIInterfaceInfo **_retval)
|
||||
}
|
||||
|
||||
xptiInterfaceEntry*
|
||||
xptiInterfaceInfoManager::GetInterfaceEntryForIID(const nsIID *iid)
|
||||
XPTInterfaceInfoManager::GetInterfaceEntryForIID(const nsIID *iid)
|
||||
{
|
||||
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
|
||||
return mWorkingSet.mIIDTable.Get(*iid);
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo getInfoForIID (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForIID(const nsIID * iid, nsIInterfaceInfo **_retval)
|
||||
NS_IMETHODIMP
|
||||
XPTInterfaceInfoManager::GetInfoForIID(const nsIID * iid, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
NS_ASSERTION(iid, "bad param");
|
||||
NS_ASSERTION(_retval, "bad param");
|
||||
@ -217,7 +220,8 @@ NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForIID(const nsIID * iid, nsIInte
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo getInfoForName (in string name); */
|
||||
NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForName(const char *name, nsIInterfaceInfo **_retval)
|
||||
NS_IMETHODIMP
|
||||
XPTInterfaceInfoManager::GetInfoForName(const char *name, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
NS_ASSERTION(name, "bad param");
|
||||
NS_ASSERTION(_retval, "bad param");
|
||||
@ -228,7 +232,8 @@ NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForName(const char *name, nsIInte
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForName (in string name); */
|
||||
NS_IMETHODIMP xptiInterfaceInfoManager::GetIIDForName(const char *name, nsIID * *_retval)
|
||||
NS_IMETHODIMP
|
||||
XPTInterfaceInfoManager::GetIIDForName(const char *name, nsIID * *_retval)
|
||||
{
|
||||
NS_ASSERTION(name, "bad param");
|
||||
NS_ASSERTION(_retval, "bad param");
|
||||
@ -244,7 +249,8 @@ NS_IMETHODIMP xptiInterfaceInfoManager::GetIIDForName(const char *name, nsIID *
|
||||
}
|
||||
|
||||
/* string getNameForIID (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP xptiInterfaceInfoManager::GetNameForIID(const nsIID * iid, char **_retval)
|
||||
NS_IMETHODIMP
|
||||
XPTInterfaceInfoManager::GetNameForIID(const nsIID * iid, char **_retval)
|
||||
{
|
||||
NS_ASSERTION(iid, "bad param");
|
||||
NS_ASSERTION(_retval, "bad param");
|
||||
@ -271,7 +277,8 @@ xpti_ArrayAppender(const char* name, xptiInterfaceEntry* entry, void* arg)
|
||||
}
|
||||
|
||||
/* nsIEnumerator enumerateInterfaces (); */
|
||||
NS_IMETHODIMP xptiInterfaceInfoManager::EnumerateInterfaces(nsIEnumerator **_retval)
|
||||
NS_IMETHODIMP
|
||||
XPTInterfaceInfoManager::EnumerateInterfaces(nsIEnumerator **_retval)
|
||||
{
|
||||
// I didn't want to incur the size overhead of using nsHashtable just to
|
||||
// make building an enumerator easier. So, this code makes a snapshot of
|
||||
@ -312,7 +319,8 @@ xpti_ArrayPrefixAppender(const char* keyname, xptiInterfaceEntry* entry, void* a
|
||||
}
|
||||
|
||||
/* nsIEnumerator enumerateInterfacesWhoseNamesStartWith (in string prefix); */
|
||||
NS_IMETHODIMP xptiInterfaceInfoManager::EnumerateInterfacesWhoseNamesStartWith(const char *prefix, nsIEnumerator **_retval)
|
||||
NS_IMETHODIMP
|
||||
XPTInterfaceInfoManager::EnumerateInterfacesWhoseNamesStartWith(const char *prefix, nsIEnumerator **_retval)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
NS_NewISupportsArray(getter_AddRefs(array));
|
||||
@ -327,7 +335,8 @@ NS_IMETHODIMP xptiInterfaceInfoManager::EnumerateInterfacesWhoseNamesStartWith(c
|
||||
}
|
||||
|
||||
/* void autoRegisterInterfaces (); */
|
||||
NS_IMETHODIMP xptiInterfaceInfoManager::AutoRegisterInterfaces()
|
||||
NS_IMETHODIMP
|
||||
XPTInterfaceInfoManager::AutoRegisterInterfaces()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
/* Implementation of xptiTypelibGuts. */
|
||||
|
||||
#include "xptiprivate.h"
|
||||
#include "mozilla/XPTInterfaceInfoManager.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -38,15 +39,15 @@ xptiTypelibGuts::GetEntryAt(uint16_t i)
|
||||
|
||||
XPTInterfaceDirectoryEntry* iface = mHeader->interface_directory + i;
|
||||
|
||||
xptiWorkingSet* set =
|
||||
xptiInterfaceInfoManager::GetSingleton()->GetWorkingSet();
|
||||
XPTInterfaceInfoManager::xptiWorkingSet& set =
|
||||
XPTInterfaceInfoManager::GetSingleton()->mWorkingSet;
|
||||
|
||||
{
|
||||
ReentrantMonitorAutoEnter monitor(set->mTableReentrantMonitor);
|
||||
ReentrantMonitorAutoEnter monitor(set.mTableReentrantMonitor);
|
||||
if (iface->iid.Equals(zeroIID))
|
||||
r = set->mNameTable.Get(iface->name);
|
||||
r = set.mNameTable.Get(iface->name);
|
||||
else
|
||||
r = set->mIIDTable.Get(iface->iid);
|
||||
r = set.mIIDTable.Get(iface->iid);
|
||||
}
|
||||
|
||||
if (r)
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
/* Implementation of xptiWorkingSet. */
|
||||
|
||||
#include "mozilla/XPTInterfaceInfoManager.h"
|
||||
|
||||
#include "xptiprivate.h"
|
||||
#include "nsString.h"
|
||||
|
||||
@ -13,7 +15,7 @@ using namespace mozilla;
|
||||
#define XPTI_STRUCT_ARENA_BLOCK_SIZE (1024 * 16)
|
||||
#define XPTI_HASHTABLE_SIZE 2048
|
||||
|
||||
xptiWorkingSet::xptiWorkingSet()
|
||||
XPTInterfaceInfoManager::xptiWorkingSet::xptiWorkingSet()
|
||||
: mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor")
|
||||
{
|
||||
MOZ_COUNT_CTOR(xptiWorkingSet);
|
||||
@ -33,13 +35,13 @@ xpti_Invalidator(const char* keyname, xptiInterfaceEntry* entry, void* arg)
|
||||
}
|
||||
|
||||
void
|
||||
xptiWorkingSet::InvalidateInterfaceInfos()
|
||||
XPTInterfaceInfoManager::xptiWorkingSet::InvalidateInterfaceInfos()
|
||||
{
|
||||
ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor);
|
||||
mNameTable.EnumerateRead(xpti_Invalidator, NULL);
|
||||
}
|
||||
|
||||
xptiWorkingSet::~xptiWorkingSet()
|
||||
XPTInterfaceInfoManager::xptiWorkingSet::~xptiWorkingSet()
|
||||
{
|
||||
MOZ_COUNT_DTOR(xptiWorkingSet);
|
||||
|
||||
|
@ -75,7 +75,6 @@ class xptiInterfaceInfo;
|
||||
class xptiInterfaceInfoManager;
|
||||
class xptiInterfaceEntry;
|
||||
class xptiTypelibGuts;
|
||||
class xptiWorkingSet;
|
||||
|
||||
extern XPTArena* gXPTIStructArena;
|
||||
|
||||
@ -117,45 +116,6 @@ private:
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class xptiWorkingSet
|
||||
{
|
||||
public:
|
||||
xptiWorkingSet();
|
||||
~xptiWorkingSet();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
void InvalidateInterfaceInfos();
|
||||
void ClearHashTables();
|
||||
|
||||
// utility methods...
|
||||
|
||||
enum {NOT_FOUND = 0xffffffff};
|
||||
|
||||
// Directory stuff...
|
||||
|
||||
uint32_t GetDirectoryCount();
|
||||
nsresult GetCloneOfDirectoryAt(uint32_t i, nsIFile** dir);
|
||||
nsresult GetDirectoryAt(uint32_t i, nsIFile** dir);
|
||||
bool FindDirectory(nsIFile* dir, uint32_t* index);
|
||||
bool FindDirectoryOfFile(nsIFile* file, uint32_t* index);
|
||||
bool DirectoryAtMatchesPersistentDescriptor(uint32_t i, const char* desc);
|
||||
|
||||
private:
|
||||
uint32_t mFileCount;
|
||||
uint32_t mMaxFileCount;
|
||||
|
||||
public:
|
||||
// XXX make these private with accessors
|
||||
// mTableMonitor must be held across:
|
||||
// * any read from or write to mIIDTable or mNameTable
|
||||
// * any writing to the links between an xptiInterfaceEntry
|
||||
// and its xptiInterfaceInfo (mEntry/mInfo)
|
||||
mozilla::ReentrantMonitor mTableReentrantMonitor;
|
||||
nsDataHashtable<nsIDHashKey, xptiInterfaceEntry*> mIIDTable;
|
||||
nsDataHashtable<nsDepCharHashKey, xptiInterfaceEntry*> mNameTable;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
// This class exists to help xptiInterfaceInfo store a 4-state (2 bit) value
|
||||
@ -396,50 +356,4 @@ private:
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class xptiInterfaceInfoManager MOZ_FINAL
|
||||
: public nsIInterfaceInfoManager
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEINFOMANAGER
|
||||
|
||||
typedef mozilla::ReentrantMonitor ReentrantMonitor;
|
||||
typedef mozilla::Mutex Mutex;
|
||||
|
||||
public:
|
||||
// GetSingleton() is infallible
|
||||
static xptiInterfaceInfoManager* GetSingleton();
|
||||
static void FreeInterfaceInfoManager();
|
||||
|
||||
void RegisterBuffer(char *buf, uint32_t length);
|
||||
|
||||
xptiWorkingSet* GetWorkingSet() {return &mWorkingSet;}
|
||||
|
||||
static Mutex& GetResolveLock(xptiInterfaceInfoManager* self = nullptr)
|
||||
{
|
||||
self = self ? self : GetSingleton();
|
||||
return self->mResolveLock;
|
||||
}
|
||||
|
||||
xptiInterfaceEntry* GetInterfaceEntryForIID(const nsIID *iid);
|
||||
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
|
||||
|
||||
static int64_t GetXPTIWorkingSetSize();
|
||||
|
||||
private:
|
||||
xptiInterfaceInfoManager();
|
||||
~xptiInterfaceInfoManager();
|
||||
|
||||
void RegisterXPTHeader(XPTHeader* aHeader);
|
||||
|
||||
// idx is the index of this interface in the XPTHeader
|
||||
void VerifyAndAddEntryIfNew(XPTInterfaceDirectoryEntry* iface,
|
||||
uint16_t idx,
|
||||
xptiTypelibGuts* typelib);
|
||||
|
||||
private:
|
||||
xptiWorkingSet mWorkingSet;
|
||||
Mutex mResolveLock;
|
||||
};
|
||||
|
||||
#endif /* xptiprivate_h___ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user