27 #ifndef __SBLOCALDATABASEPROPERTYCACHE_H__
28 #define __SBLOCALDATABASEPROPERTYCACHE_H__
30 #include <nsIStringEnumerator.h>
31 #include <sbILocalDatabasePropertyCache.h>
33 #include <nsCOMArray.h>
35 #include <nsIClassInfo.h>
36 #include <nsDataHashtable.h>
37 #include <nsInterfaceHashtable.h>
38 #include <nsIObserver.h>
39 #include <nsIThread.h>
40 #include <nsIThreadPool.h>
41 #include <nsStringGlue.h>
43 #include <nsTHashtable.h>
44 #include <nsIRunnable.h>
46 #include <sbIJobProgress.h>
47 #include <sbIMediaListListener.h>
85 NS_DECL_SBILOCALDATABASEPROPERTYCACHE
97 const nsAString& aLibraryResourceGUID);
99 PRBool
GetPropertyID(PRUint32 aPropertyDBID, nsAString& aPropertyID);
109 PRUint32 aPropertyDBID,
115 nsresult LoadProperties();
117 nsresult AddDirty(
const nsAString &aGuid,
120 nsresult InvalidateGUIDArrays();
122 PRUint32 GetPropertyDBIDInternal(
const nsAString& aPropertyID);
124 nsresult InsertPropertyIDInLibrary(
const nsAString& aPropertyID,
125 PRUint32 *aPropertyDBID);
129 nsresult GetSetInvalidSortDataPref(PRBool aWrite, PRBool&
aValue);
131 typedef nsInterfaceHashtable<nsUint32HashKey, sbLocalDatabaseResourcePropertyBag> IDToBagMap;
133 nsresult RetrieveSecondaryProperties(
sbIDatabaseQuery* query, nsTArray<PRUint32> itemIDs,
134 IDToBagMap
const & bags);
148 nsresult RetrieveProperties(T & aGUIDs,
149 nsCOMArray<sbLocalDatabaseResourcePropertyBag> & aBags);
169 IDToBagMap & aIDToBagMap,
170 nsCOMArray<sbLocalDatabaseResourcePropertyBag> & aBags,
171 nsTArray<PRUint32> & aItemIDs);
174 PRUint32 mWritePendingCount;
177 nsString mDatabaseGUID;
180 nsCOMPtr<nsIURI> mDatabaseLocation;
183 nsDataHashtableMT<nsUint32HashKey, nsString> mPropertyDBIDToID;
184 nsDataHashtableMT<nsStringHashKey, PRUint32> mPropertyIDToDBID;
187 PRMonitor* mDependentGUIDArrayMonitor;
189 nsCOMPtr<nsIWeakReference> > DependentGUIDArrays_t;
190 DependentGUIDArrays_t mDependentGUIDArrays;
199 nsInterfaceHashtable<nsStringHashKey, sbLocalDatabaseResourcePropertyBag> mDirty;
202 std::set<PRUint32> mDirtyForInvalidation;
205 struct FlushQueryData {
206 nsCOMPtr<sbIDatabaseQuery> query;
207 PRUint32 dirtyGuidCount;
209 nsresult DispatchFlush();
210 void RunFlushThread();
213 nsresult ProcessQueries(nsTArray<FlushQueryData> & aQueries);
216 nsString mLibraryResourceGUID;
219 nsCOMPtr<nsITimer> mFlushTimer;
220 nsCOMPtr<nsIThreadPool> mThreadPoolService;
223 nsCOMPtr<nsITimer> mInvalidateTimer;
229 nsCOMPtr<sbIPropertyManager> mPropertyManager;
233 nsRefPtr<sbLocalDatabaseSortInvalidateJob> mSortInvalidateJob;
236 nsCOMPtr<sbIDatabasePreparedStatement> mItemSelectPreparedStatement;
237 nsCOMPtr<sbIDatabasePreparedStatement> mSecondaryPropertySelectPreparedStatement;
238 nsCOMPtr<sbIDatabasePreparedStatement> mMediaItemsFtsAllDeletePreparedStatement;
239 nsCOMPtr<sbIDatabasePreparedStatement> mMediaItemsFtsAllInsertPreparedStatement;
240 nsCOMPtr<sbIDatabasePreparedStatement> mPropertiesDeletePreparedStatement;
241 nsCOMPtr<sbIDatabasePreparedStatement> mPropertiesInsertPreparedStatement;
246 nsInterfaceHashtable<nsUint32HashKey, sbIDatabasePreparedStatement> mMediaItemsUpdatePreparedStatements;
247 nsInterfaceHashtable<nsUint32HashKey, sbIDatabasePreparedStatement> mLibraryMediaItemUpdatePreparedStatements;
266 NS_DECL_SBIJOBPROGRESS
268 NS_DECL_SBIMEDIALISTENUMERATIONLISTENER
287 static nsresult RunLibraryBatch(
nsISupports* aUserData);
289 PRPackedBool mShouldShutdown;
290 nsCOMPtr<nsIThread> mThread;
296 nsCOMPtr<nsITimer> mNotificationTimer;
300 PRUint32 mCompletedItemCount;
301 PRUint32 mTotalItemCount;
303 nsString mStatusText;
304 nsString mFailedText;
305 nsCOMArray<sbIJobProgressListener> mListeners;
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
static PRUint32 const BATCH_READ_SIZE
Generic interface for exposing long running jobs to the UI.
virtual ~sbLocalDatabaseSortInvalidateJob()
NS_DECL_ISUPPORTS NS_DECL_SBILOCALDATABASEPROPERTYCACHE NS_DECL_NSIOBSERVER typedef sbFixedInterfaceCache< nsStringHashKey, sbLocalDatabaseResourcePropertyBag > InterfaceCache
PRBool GetPropertyID(PRUint32 aPropertyDBID, nsAString &aPropertyID)
nsresult Init(sbLocalDatabaseLibrary *aLibrary, const nsAString &aLibraryResourceGUID)
nsresult Init(sbLocalDatabasePropertyCache *aPropCache, sbLocalDatabaseLibrary *aLibrary)
[USER CODE SHOULD NOT REFERENCE THIS CLASS]
An object responsible for executing SQL queries on the database.
static PRUint32 const CACHE_SIZE
NS_DECL_ISUPPORTS NS_DECL_NSICLASSINFO NS_DECL_SBIJOBPROGRESS NS_DECL_NSIRUNNABLE NS_DECL_SBIMEDIALISTENUMERATIONLISTENER NS_DECL_NSIOBSERVER sbLocalDatabaseSortInvalidateJob()
~sbLocalDatabasePropertyCache()
nsresult CreateSecondarySortValue(sbILocalDatabaseResourcePropertyBag *aBag, PRUint32 aPropertyDBID, nsAString &_retval)
nsresult InvalidateSortDataComplete()
Manager for system wide metadata properties.
sbLocalDatabasePropertyCache()
A prepared database statement.
void GetColumnForPropertyID(PRUint32 aPropertyID, nsAString &aColumn)