Bug 723362 - Make an asynchronous variant of nsCacheEntryDescriptor::Doom, r=hurley

This commit is contained in:
Michal Novotny
2012-09-17 23:31:46 +02:00
parent ccf36f52ad
commit 73105817a9
8 changed files with 188 additions and 60 deletions

View File

@@ -15,6 +15,7 @@
#include "nsCacheService.h"
#include "nsIDiskCacheStreamInternal.h"
#include "zlib.h"
#include "mozilla/Mutex.h"
/******************************************************************************
* nsCacheEntryDescriptor
@@ -27,7 +28,9 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSICACHEENTRYDESCRIPTOR
NS_DECL_NSICACHEENTRYINFO
friend class nsAsyncDoomEvent;
nsCacheEntryDescriptor(nsCacheEntry * entry, nsCacheAccessMode mode);
virtual ~nsCacheEntryDescriptor();
@@ -40,7 +43,20 @@ public:
* methods callbacks for nsCacheService
*/
nsCacheEntry * CacheEntry(void) { return mCacheEntry; }
void ClearCacheEntry(void) { mCacheEntry = nullptr; }
void ClearCacheEntry(void)
{
bool asyncDoomPending;
{
mozilla::MutexAutoLock lock(mLock);
asyncDoomPending = mAsyncDoomPending;
}
if (asyncDoomPending && mCacheEntry) {
nsCacheService::gService->DoomEntry_Internal(mCacheEntry, true);
mDoomedOnClose = true;
}
mCacheEntry = nullptr;
}
nsresult CloseOutput(void)
{
@@ -208,6 +224,9 @@ private:
nsCacheEntry * mCacheEntry; // we are a child of the entry
nsCacheAccessMode mAccessGranted;
nsIOutputStream * mOutput;
mozilla::Mutex mLock;
bool mAsyncDoomPending;
bool mDoomedOnClose;
};