xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* vim: set ts=4 et sw=4 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_XPTInterfaceInfoManager_h_
michael@0 8 #define mozilla_XPTInterfaceInfoManager_h_
michael@0 9
michael@0 10 #include "nsIInterfaceInfoManager.h"
michael@0 11 #include "nsIMemoryReporter.h"
michael@0 12
michael@0 13 #include "mozilla/MemoryReporting.h"
michael@0 14 #include "mozilla/Mutex.h"
michael@0 15 #include "mozilla/ReentrantMonitor.h"
michael@0 16 #include "nsDataHashtable.h"
michael@0 17
michael@0 18 template<typename T> class nsCOMArray;
michael@0 19 class nsIMemoryReporter;
michael@0 20 class XPTHeader;
michael@0 21 class XPTInterfaceDirectoryEntry;
michael@0 22 class xptiInterfaceEntry;
michael@0 23 class xptiInterfaceInfo;
michael@0 24 class xptiTypelibGuts;
michael@0 25
michael@0 26 namespace mozilla {
michael@0 27
michael@0 28 class XPTInterfaceInfoManager MOZ_FINAL
michael@0 29 : public nsIInterfaceInfoManager
michael@0 30 , public nsIMemoryReporter
michael@0 31 {
michael@0 32 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 33 NS_DECL_NSIINTERFACEINFOMANAGER
michael@0 34 NS_DECL_NSIMEMORYREPORTER
michael@0 35
michael@0 36 public:
michael@0 37 // GetSingleton() is infallible
michael@0 38 static XPTInterfaceInfoManager* GetSingleton();
michael@0 39 static void FreeInterfaceInfoManager();
michael@0 40
michael@0 41 void GetScriptableInterfaces(nsCOMArray<nsIInterfaceInfo>& aInterfaces);
michael@0 42
michael@0 43 void RegisterBuffer(char *buf, uint32_t length);
michael@0 44
michael@0 45 static Mutex& GetResolveLock()
michael@0 46 {
michael@0 47 return GetSingleton()->mResolveLock;
michael@0 48 }
michael@0 49
michael@0 50 xptiInterfaceEntry* GetInterfaceEntryForIID(const nsIID *iid);
michael@0 51
michael@0 52 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
michael@0 53
michael@0 54 private:
michael@0 55 XPTInterfaceInfoManager();
michael@0 56 ~XPTInterfaceInfoManager();
michael@0 57
michael@0 58 void InitMemoryReporter();
michael@0 59
michael@0 60 void RegisterXPTHeader(XPTHeader* aHeader);
michael@0 61
michael@0 62 // idx is the index of this interface in the XPTHeader
michael@0 63 void VerifyAndAddEntryIfNew(XPTInterfaceDirectoryEntry* iface,
michael@0 64 uint16_t idx,
michael@0 65 xptiTypelibGuts* typelib);
michael@0 66
michael@0 67 private:
michael@0 68
michael@0 69 class xptiWorkingSet
michael@0 70 {
michael@0 71 public:
michael@0 72 xptiWorkingSet();
michael@0 73 ~xptiWorkingSet();
michael@0 74
michael@0 75 bool IsValid() const;
michael@0 76
michael@0 77 void InvalidateInterfaceInfos();
michael@0 78 void ClearHashTables();
michael@0 79
michael@0 80 // utility methods...
michael@0 81
michael@0 82 enum {NOT_FOUND = 0xffffffff};
michael@0 83
michael@0 84 // Directory stuff...
michael@0 85
michael@0 86 uint32_t GetDirectoryCount();
michael@0 87 nsresult GetCloneOfDirectoryAt(uint32_t i, nsIFile** dir);
michael@0 88 nsresult GetDirectoryAt(uint32_t i, nsIFile** dir);
michael@0 89 bool FindDirectory(nsIFile* dir, uint32_t* index);
michael@0 90 bool FindDirectoryOfFile(nsIFile* file, uint32_t* index);
michael@0 91 bool DirectoryAtMatchesPersistentDescriptor(uint32_t i, const char* desc);
michael@0 92
michael@0 93 private:
michael@0 94 uint32_t mFileCount;
michael@0 95 uint32_t mMaxFileCount;
michael@0 96
michael@0 97 public:
michael@0 98 // XXX make these private with accessors
michael@0 99 // mTableMonitor must be held across:
michael@0 100 // * any read from or write to mIIDTable or mNameTable
michael@0 101 // * any writing to the links between an xptiInterfaceEntry
michael@0 102 // and its xptiInterfaceInfo (mEntry/mInfo)
michael@0 103 mozilla::ReentrantMonitor mTableReentrantMonitor;
michael@0 104 nsDataHashtable<nsIDHashKey, xptiInterfaceEntry*> mIIDTable;
michael@0 105 nsDataHashtable<nsDepCharHashKey, xptiInterfaceEntry*> mNameTable;
michael@0 106 };
michael@0 107
michael@0 108 // XXX xptiInterfaceInfo want's to poke at the working set itself
michael@0 109 friend class ::xptiInterfaceInfo;
michael@0 110 friend class ::xptiInterfaceEntry;
michael@0 111 friend class ::xptiTypelibGuts;
michael@0 112
michael@0 113 xptiWorkingSet mWorkingSet;
michael@0 114 Mutex mResolveLock;
michael@0 115 };
michael@0 116
michael@0 117 }
michael@0 118
michael@0 119 #endif

mercurial