Updated new cache source to build with recent changes to interface files. These files are not part of the build. r=beard, darin.

This commit is contained in:
gordon%netscape.com 2001-02-24 01:02:37 +00:00
Родитель 897e3b6058
Коммит cb127e5457
10 изменённых файлов: 88 добавлений и 101 удалений

4
netwerk/cache/src/Makefile.in поставляемый
Просмотреть файл

@ -27,7 +27,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = nkcache
LIBRARY_NAME = nkcachemgr_s
LIBRARY_NAME = nkcacheservice_s
REQUIRES = xpcom necko pref js
EXPORTS = \
@ -38,7 +38,9 @@ CPPSRCS = \
nsCacheEntry.cpp \
nsCacheEntryDescriptor.cpp \
nsCacheMetaData.cpp \
nsCacheModule.cpp \
nsCacheService.cpp \
nsCacheSession.cpp \
nsDiskCacheDevice.cpp \
nsMemoryCacheDevice.cpp \
$(NULL)

17
netwerk/cache/src/nsCacheDevice.h поставляемый
Просмотреть файл

@ -26,6 +26,8 @@
#include "nspr.h"
#include "nsError.h"
#include "nsITransport.h"
#include "nsCacheEntry.h"
class nsCacheEntry;
@ -33,25 +35,20 @@ class nsCacheEntry;
class nsCacheDevice {
public:
nsCacheDevice(PRUint32 deviceID) : mDeviceID(deviceID){}
virtual ~nsCacheDevice() = 0;
//** decide on strings or ints for IDs
virtual PRUint32 GetDeviceID(void) { return mDeviceID; }
virtual const char * GetDeviceID(void) = 0;
virtual nsresult ActivateEntryIfFound( nsCacheEntry * entry ) = 0;
virtual nsresult DeactivateEntry( nsCacheEntry * entry ) = 0;
virtual nsresult BindEntry( nsCacheEntry * entry ) = 0;
//** need to define stream factory methods
virtual nsresult GetTransportForEntry( nsCacheEntry * entry,
nsITransport **transport ) = 0;
virtual nsresult OnDataSizeChanged( nsCacheEntry * entry ) = 0;
//** need to define methods for enumerating entries
//** need notification methods for size changes on non-streamBased entries
protected:
PRUint32 mDeviceID;
};
#endif // _nsCacheDevice_h_

8
netwerk/cache/src/nsCacheEntry.cpp поставляемый
Просмотреть файл

@ -116,17 +116,17 @@ nsCacheEntry::CommonOpen(nsCacheRequest * request, PRUint32 *accessGranted)
if (!IsInitialized()) {
// brand new, unbound entry
NS_ASSERTION(request->mAccessRequested & nsICacheService::WRITE,
NS_ASSERTION(request->mAccessRequested & nsICache::ACCESS_WRITE,
"new cache entry for READ-ONLY request");
if (request->mStreamBased) MarkStreamBased();
mFetchCount = 1;
MarkInitialized();
*accessGranted = request->mAccessRequested & ~nsICacheService::WRITE;
*accessGranted = request->mAccessRequested & ~nsICache::ACCESS_WRITE;
return rv;
}
if (IsStreamData() != request->mStreamBased) {
*accessGranted = nsICacheService::NO_ACCESS;
*accessGranted = nsICache::ACCESS_NONE;
return request->mStreamBased ?
NS_ERROR_CACHE_DATA_IS_NOT_STREAM : NS_ERROR_CACHE_DATA_IS_STREAM;
}
@ -136,7 +136,7 @@ nsCacheEntry::CommonOpen(nsCacheRequest * request, PRUint32 *accessGranted)
*accessGranted = request->mAccessRequested;
} else {
// nth request for existing, bound entry
*accessGranted = request->mAccessRequested & ~nsICacheService::WRITE;
*accessGranted = request->mAccessRequested & ~nsICache::ACCESS_WRITE;
if (!IsValid())
rv = NS_ERROR_CACHE_WAIT_FOR_VALIDATION;
}

4
netwerk/cache/src/nsCacheEntry.h поставляемый
Просмотреть файл

@ -59,8 +59,8 @@ public:
void GetKey( nsCString ** key) { if (key) *key = mKey; }
void GetFetchCount( PRUint32 * result) { if (result) *result = mFetchCount; }
void SetFetchCount( PRUint32 count) { mFetchCount = count; }
void GetFetchCount( PRInt32 * result) { if (result) *result = mFetchCount; }
void SetFetchCount( PRInt32 count) { mFetchCount = count; }
void GetLastFetched( PRTime * result) { if (result) *result = mLastFetched; }
void SetLastFetched( PRTime lastFetched)

45
netwerk/cache/src/nsCacheEntryDescriptor.cpp поставляемый
Просмотреть файл

@ -91,7 +91,7 @@ nsCacheEntryDescriptor::GetKey(char ** result)
/* readonly attribute unsigned long fetchCount; */
NS_IMETHODIMP
nsCacheEntryDescriptor::GetFetchCount(PRUint32 *fetchCount)
nsCacheEntryDescriptor::GetFetchCount(PRInt32 *fetchCount)
{
if (!fetchCount) return NS_ERROR_NULL_POINTER;
mCacheEntry->GetFetchCount(fetchCount);
@ -165,40 +165,14 @@ nsCacheEntryDescriptor::GetAccessGranted(PRUint32 *accessGranted)
/* attribute unsigned long storageFlags; */
NS_IMETHODIMP
nsCacheEntryDescriptor::GetStorageFlags(PRUint32 *storageFlags)
nsCacheEntryDescriptor::GetStoragePolicy(nsCacheStoragePolicy *policy)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCacheEntryDescriptor::SetStorageFlags(PRUint32 storageFlags)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute boolean allowInMemory; */
NS_IMETHODIMP
nsCacheEntryDescriptor::GetAllowInMemory(PRBool *aAllowInMemory)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCacheEntryDescriptor::SetAllowInMemory(PRBool aAllowInMemory)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute boolean allowOnDisk; */
NS_IMETHODIMP
nsCacheEntryDescriptor::GetAllowOnDisk(PRBool *aAllowOnDisk)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCacheEntryDescriptor::SetAllowOnDisk(PRBool aAllowOnDisk)
nsCacheEntryDescriptor::SetStoragePolicy(nsCacheStoragePolicy policy)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -217,19 +191,6 @@ nsCacheEntryDescriptor::DoomAndFailPendingRequests(nsresult status)
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void truncateExistingData (in unsigned long newLength); */
NS_IMETHODIMP
nsCacheEntryDescriptor::TruncateExistingData(PRUint32 newLength)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void appendToExistingData (); */
NS_IMETHODIMP
nsCacheEntryDescriptor::AppendToExistingData()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void markValid (); */
NS_IMETHODIMP

53
netwerk/cache/src/nsCacheService.cpp поставляемый
Просмотреть файл

@ -143,6 +143,19 @@ nsCacheService::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
return rv;
}
/* nsICacheSession createSession (in string clientID, in long storagePolicy, in boolean streamBased); */
NS_IMETHODIMP nsCacheService::CreateSession(const char *clientID, PRInt32 storagePolicy, PRBool streamBased, nsICacheSession **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void visitEntries (in nsICacheVisitor visitor); */
NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsCacheService::CommonOpenCacheEntry(const char *clientID, const char *clientKey,
@ -170,7 +183,7 @@ nsCacheService::CommonOpenCacheEntry(const char *clientID, const char *clientKey
}
NS_IMETHODIMP
nsresult
nsCacheService::OpenCacheEntry(const char *clientID, const char *clientKey,
PRUint32 accessRequested, PRBool streamBased,
nsICacheEntryDescriptor **result)
@ -197,7 +210,7 @@ nsCacheService::OpenCacheEntry(const char *clientID, const char *clientKey,
}
NS_IMETHODIMP
nsresult
nsCacheService::AsyncOpenCacheEntry(const char * clientID, const char * key,
PRUint32 accessRequested, PRBool streamBased,
nsICacheListener *listener)
@ -219,7 +232,6 @@ nsCacheService::AsyncOpenCacheEntry(const char * clientID, const char * key,
return rv;
}
nsresult
nsCacheService::ActivateEntry(nsCacheRequest * request,
nsCacheEntry ** result)
@ -241,7 +253,7 @@ nsCacheService::ActivateEntry(nsCacheRequest * request,
nsCacheEntry *entry = mActiveEntries.GetEntry(request->mKey);
// doom existing entry if we are processing a FORCE-WRITE
if (entry && (request->mAccessRequested == nsICacheService::WRITE)) {
if (entry && (request->mAccessRequested == nsICache::ACCESS_WRITE)) {
entry->Doom();
}
@ -259,7 +271,7 @@ nsCacheService::ActivateEntry(nsCacheRequest * request,
rv = SearchCacheDevices(entry, &device);
if ((rv == NS_ERROR_CACHE_KEY_NOT_FOUND) &&
!(request->mAccessRequested & nsICacheService::WRITE)) {
!(request->mAccessRequested & nsICache::ACCESS_WRITE)) {
// this was a READ-ONLY request, deallocate entry
//** dealloc entry, call listener with error, etc.
*result = nsnull;
@ -305,37 +317,6 @@ nsCacheService::SearchActiveEntries(const nsCString * key)
}
NS_IMETHODIMP
nsCacheService::EnumerateDeviceIDs(nsISimpleEnumerator **_retval)
{
if (!mCacheServiceLock)
return NS_ERROR_NOT_INITIALIZED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCacheService::EnumerateClientIDs(nsISimpleEnumerator **_retval)
{
if (!mCacheServiceLock)
return NS_ERROR_NOT_INITIALIZED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCacheService::EnumerateEntries(const char *deviceID, const char *clientID,
nsISimpleEnumerator **_retval)
{
if (!mCacheServiceLock)
return NS_ERROR_NOT_INITIALIZED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/*
* nsCacheClientHashTable

8
netwerk/cache/src/nsCacheService.h поставляемый
Просмотреть файл

@ -127,6 +127,14 @@ private:
PRUint32 accessRequested, PRBool streamBased,
nsCacheRequest **request, nsCacheEntry **entry);
nsresult OpenCacheEntry(const char *clientID, const char *clientKey,
PRUint32 accessRequested, PRBool streamBased,
nsICacheEntryDescriptor **result);
nsresult AsyncOpenCacheEntry(const char * clientID, const char * key,
PRUint32 accessRequested, PRBool streamBased,
nsICacheListener *listener);
/**
* Data Members
*/

21
netwerk/cache/src/nsDiskCacheDevice.cpp поставляемый
Просмотреть файл

@ -26,7 +26,6 @@
nsDiskCacheDevice::nsDiskCacheDevice()
: nsCacheDevice(kDiskCacheID)
{
}
@ -61,6 +60,13 @@ nsDiskCacheDevice::Create(nsCacheDevice **result)
}
const char *
nsDiskCacheDevice::GetDeviceID()
{
return "disk";
}
nsresult
nsDiskCacheDevice::ActivateEntryIfFound(nsCacheEntry * entry)
{
@ -81,6 +87,17 @@ nsDiskCacheDevice::BindEntry(nsCacheEntry * entry)
return NS_ERROR_NOT_IMPLEMENTED;
}
//** need stream factory methods
nsresult
nsDiskCacheDevice::GetTransportForEntry( nsCacheEntry * entry,
nsITransport **transport )
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsDiskCacheDevice::OnDataSizeChanged( nsCacheEntry * entry )
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//** need methods for enumerating entries

6
netwerk/cache/src/nsDiskCacheDevice.h поставляемый
Просмотреть файл

@ -39,10 +39,16 @@ public:
static nsresult Create(nsCacheDevice **result);
virtual const char * GetDeviceID(void);
virtual nsresult ActivateEntryIfFound( nsCacheEntry * entry );
virtual nsresult DeactivateEntry( nsCacheEntry * entry );
virtual nsresult BindEntry( nsCacheEntry * entry );
virtual nsresult GetTransportForEntry( nsCacheEntry * entry,
nsITransport **transport );
virtual nsresult OnDataSizeChanged( nsCacheEntry * entry );
private:
};

23
netwerk/cache/src/nsMemoryCacheDevice.cpp поставляемый
Просмотреть файл

@ -26,7 +26,6 @@
nsMemoryCacheDevice::nsMemoryCacheDevice()
: nsCacheDevice(kMemoryCacheID)
{
}
@ -66,6 +65,13 @@ nsMemoryCacheDevice::Create(nsCacheDevice **result)
}
const char *
nsMemoryCacheDevice::GetDeviceID()
{
return "memory";
}
nsresult
nsMemoryCacheDevice::ActivateEntryIfFound(nsCacheEntry * entry)
{
@ -112,8 +118,17 @@ nsMemoryCacheDevice::BindEntry(nsCacheEntry * entry)
return NS_ERROR_NOT_IMPLEMENTED;
}
//** need stream factory methods
nsresult
nsMemoryCacheDevice::GetTransportForEntry( nsCacheEntry * entry,
nsITransport **transport )
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsMemoryCacheDevice::OnDataSizeChanged( nsCacheEntry * entry )
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//** need methods for enumerating entries
//** need notification methods for size changes on non-streamBased entries (for eviction)