[not part of build] Implemented nsCacheEntryDescriptor::GetFile().

This commit is contained in:
beard%netscape.com 2001-03-08 21:22:18 +00:00
parent 22e5a9f6da
commit 1f859d742c
8 changed files with 42 additions and 4 deletions

View File

@ -50,6 +50,9 @@ public:
nsCacheAccessMode mode,
nsITransport **result ) = 0;
virtual nsresult GetFileForEntry( nsCacheEntry * entry,
nsIFile ** result ) = 0;
virtual nsresult OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize ) = 0;
// XXX need to define methods for enumerating entries

View File

@ -279,7 +279,7 @@ nsCacheEntryDescriptor::GetFile(nsIFile ** result)
NS_ENSURE_ARG_POINTER(result);
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
return NS_ERROR_NOT_IMPLEMENTED;
return nsCacheService::GlobalInstance()->GetFileForEntry(mCacheEntry, result);
}

View File

@ -179,7 +179,7 @@ nsCacheService::CreateSession(const char * clientID,
/* void visitEntries (in nsICacheVisitor visitor); */
NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor)
{
nsAutoLock cacheService(mCacheServiceLock);
nsAutoLock lock(mCacheServiceLock);
// XXX record the fact that a visitation is in progress, i.e. keep
// list of visitors in progress.
@ -344,7 +344,7 @@ nsCacheService::OpenCacheEntry(nsCacheSession * session,
nsresult rv = CreateRequest(session, key, accessRequested, listener, &request);
if (NS_FAILED(rv)) return rv;
nsAutoLock cacheService(mCacheServiceLock);
nsAutoLock lock(mCacheServiceLock);
rv = ProcessRequest(request, result);
// delete requests that have completed
@ -466,6 +466,7 @@ nsCacheService::EnsureEntryHasDevice(nsCacheEntry * entry)
nsresult
nsCacheService::ValidateEntry(nsCacheEntry * entry)
{
nsAutoLock lock(mCacheServiceLock);
nsCacheDevice * device = EnsureEntryHasDevice(entry);
if (!device) return NS_ERROR_UNEXPECTED; // XXX need better error here
@ -566,6 +567,16 @@ nsCacheService::CloseDescriptor(nsCacheEntryDescriptor * descriptor)
}
nsresult
nsCacheService::GetFileForEntry(nsCacheEntry * entry,
nsIFile ** result)
{
nsAutoLock lock(mCacheServiceLock);
nsCacheDevice * device = EnsureEntryHasDevice(entry);
if (!device) return NS_ERROR_UNEXPECTED; // XXX need better error here
return device->GetFileForEntry(entry, result);
}
void
nsCacheService::DeactivateEntry(nsCacheEntry * entry)
{

View File

@ -84,10 +84,13 @@ public:
nsresult GetTransportForEntry(nsCacheEntry * entry,
nsCacheAccessMode mode,
nsITransport ** result);
nsITransport ** result);
void CloseDescriptor(nsCacheEntryDescriptor * descriptor);
nsresult GetFileForEntry(nsCacheEntry * entry,
nsIFile ** result);
/**
* Methods called by any cache classes

View File

@ -386,6 +386,13 @@ nsDiskCacheDevice::GetTransportForEntry(nsCacheEntry * entry,
return rv;
}
nsresult
nsDiskCacheDevice::GetFileForEntry(nsCacheEntry * entry,
nsIFile ** result)
{
return getFileForKey(entry->Key()->get(), PR_FALSE, result);
}
/**
* This routine will get called every time an open descriptor.
*/

View File

@ -48,6 +48,9 @@ public:
nsCacheAccessMode mode,
nsITransport ** result);
virtual nsresult GetFileForEntry(nsCacheEntry * entry,
nsIFile ** result);
virtual nsresult OnDataSizeChange(nsCacheEntry * entry, PRInt32 deltaSize);
virtual nsresult Visit(nsICacheVisitor * visitor);

View File

@ -206,6 +206,14 @@ nsMemoryCacheDevice::GetTransportForEntry( nsCacheEntry * entry,
}
nsresult
nsMemoryCacheDevice::GetFileForEntry( nsCacheEntry * entry,
nsIFile ** result )
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsMemoryCacheDevice::OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize)
{

View File

@ -48,6 +48,9 @@ public:
nsCacheAccessMode mode,
nsITransport **transport );
virtual nsresult GetFileForEntry( nsCacheEntry * entry,
nsIFile ** result );
virtual nsresult OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize );
virtual nsresult Visit( nsICacheVisitor * visitor );