Miscellaneous changes for streams based objects. Added more comments.

This commit is contained in:
gagan%netscape.com 1998-09-16 10:13:48 +00:00
Родитель 8a2851d090
Коммит ef02d0cbf7
19 изменённых файлов: 182 добавлений и 75 удалений

25
network/cache/nu/public/CacheStubs.h поставляемый
Просмотреть файл

@ -17,12 +17,13 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Design and original implementation by Gagan Saksena '98 */
/* Ideally we should be using the C++ api directly, but since the core of
Netlib is still in C, this file uses the stub functions that call the C++
API internally, allowing C programs to use the new cache architecture.
If you are accessing the cache, see if you can directly use the C++ api. */
/* Design and original implementation by Gagan Saksena '98
* Ideally we should be using the C++ api directly, but since the core of
* Netlib is still in C, this file uses the stub functions that call the C++
* API internally, allowing C programs to use the new cache architecture.
* If you are accessing the cache, see if you can directly use the C++ api.
* -Gagan Saksena 09/15/98
*/
#ifndef CacheStubs_h__
#define CacheStubs_h__
@ -56,17 +57,18 @@ PR_BEGIN_EXTERN_C
extern void* CacheObject_Create(const char* i_url);
extern void CacheObject_Destroy(void* pThis);
extern const char* CacheObject_GetAddress(const void* pThis);
extern const char* CacheObject_GetCharset(void* pThis);
extern const char* CacheObject_GetContentEncoding(void* pThis);
extern PRUint32 CacheObject_GetContentLength(void* pThis);
extern const char* CacheObject_GetContentType(void* pThis);
extern const char* CacheObject_GetCharset(const void* pThis);
extern const char* CacheObject_GetContentEncoding(const void* pThis);
extern PRUint32 CacheObject_GetContentLength(const void* pThis);
extern const char* CacheObject_GetContentType(const void* pThis);
extern const char* CacheObject_GetEtag(const void* pThis);
extern PRIntervalTime CacheObject_GetExpires(const void* pThis);
extern const char* CacheObject_GetFilename(const void* pThis);
extern PRBool CacheObject_GetIsCompleted(const void* pThis);
extern PRIntervalTime CacheObject_GetLastAccessed(const void* pThis);
extern PRIntervalTime CacheObject_GetLastModified(const void* pThis);
extern PRInt16 CacheObject_GetModule(const void* pThis);
extern const char* CacheObject_GetPageServicesURL(void* pThis);
extern const char* CacheObject_GetPageServicesURL(const void* pThis);
extern const char* CacheObject_GetPostData(const void* pThis);
extern PRUint32 CacheObject_GetPostDataLen(const void* pThis);
extern PRUint32 CacheObject_GetSize(const void* pThis);
@ -82,6 +84,7 @@ PR_BEGIN_EXTERN_C
extern void CacheObject_SetEtag(void* pThis, const char* i_Etag);
extern void CacheObject_SetExpires(void *pThis, const PRIntervalTime i_Time);
extern void CacheObject_SetFilename(void *pThis, const char* i_Filename);
extern void CacheObject_SetIsCompleted(void *pThis, PRBool bComplete);
extern void CacheObject_SetLastModified(void* pThis, const PRIntervalTime i_Time);
extern void CacheObject_SetModule(void* pThis, const PRInt16 i_Module);
extern void CacheObject_SetPageServicesURL(void* pThis, const char* i_Url);

2
network/cache/nu/public/makefile.win поставляемый
Просмотреть файл

@ -25,7 +25,7 @@ EXPORTS=nsCacheObject.h nsMemModule.h nsCacheManager.h \
nsCachePref.h nsCacheBkgThd.h nsBkgThread.h \
CacheStubs.h nsCacheIterator.h nsIterator.h \
nsMonitorable.h nsStream.h nsFileStream.h \
nsMemStream.h \
nsMemStream.h nsEnumeration.h \
$(NULL)
include <$(DEPTH)\config\rules.mak>

21
network/cache/nu/public/nsBkgThread.h поставляемый
Просмотреть файл

@ -16,6 +16,16 @@
* Reserved.
*/
/* This is a super cool class that does the background thread magic using
* NSPR Threads. This class is used to maintain odd tasks in the background
* like like updating, expiration, validation and garbage collection.
*
* Note that this is a noop active when the cache manager is offline.
*
* In PRThread terms, this is a PR_USER_THREAD with local scope.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsBkgThread_h__
#define nsBkgThread_h__
@ -23,17 +33,6 @@
#include "prthread.h"
#include "prinrval.h"
/*
Creates a background thread that maintains odd
tasks like updating, expiration, validation and
garbage collection.
Note that this is a noop active when the cache
manager is offline.
In PRThread terms, this is a PR_USER_THREAD with
local scope.
*/
class nsBkgThread//: public nsISupports
{

6
network/cache/nu/public/nsCacheBkgThd.h поставляемый
Просмотреть файл

@ -16,6 +16,12 @@
* Reserved.
*/
/* This class is the actual implementation of the original class nsBkgThread,
* but I am too lazy to move the comments from nsBkgThread's
* header file to here. :-)
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsCacheBkgThd_h__
#define nsCacheBkgThd_h__

6
network/cache/nu/public/nsCacheIterator.h поставляемый
Просмотреть файл

@ -17,6 +17,12 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
/* A simple cache iterator for cache architecture. This is a temporary class
* which will be (should be) replaced by more professional quality code, or
* at least moved to a more common area later on.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsCacheIterator_h__
#define nsCacheIterator_h__

15
network/cache/nu/public/nsCacheManager.h поставляемый
Просмотреть файл

@ -16,15 +16,20 @@
* Reserved.
*/
#ifndef _CacheManager_H_
#define _CacheManager_H_
/*
* nsCacheManager
* Design and original implementation
* by Gagan Saksena 02/02/98
* nsCacheManager- The boss of cache architecture. Contains all "external"
* functions for use by people who don't care/want to know the internals
* of the cache architecture.
*
* - Gagan Saksena 09/15/98
*
* Design and original implementation by Gagan Saksena 02/02/98
*
*/
#ifndef _CacheManager_H_
#define _CacheManager_H_
#if 0
# include "nsISupports.h"
#endif

11
network/cache/nu/public/nsCacheModule.h поставляемый
Просмотреть файл

@ -16,15 +16,18 @@
* Reserved.
*/
#ifndef nsCacheModule_h__
#define nsCacheModule_h__
/*
* nsCacheModule
* nsCacheModule. A class that defines the way a cache module
* should be written. Its the super class for any new modules.
* Two sample modules derived from this one are nsMemModule and nsDiskModule.
*
* Gagan Saksena 02/03/98
*
*/
#ifndef nsCacheModule_h__
#define nsCacheModule_h__
//#include <nsISupports.h>
#include "nsCacheObject.h"
#include "nsEnumeration.h"

62
network/cache/nu/public/nsCacheObject.h поставляемый
Просмотреть файл

@ -16,6 +16,12 @@
* Reserved.
*/
/* nsCacheObject is the class that holds the basic definition of the
* cache object. A lot of changes are likely to occur before this
* goes on stage.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsCacheObject_h__
#define nsCacheObject_h__
@ -87,6 +93,9 @@ public:
PRUint32 InfoSize(void) const;
PRBool IsCompleted(void) const;
void IsCompleted(PRBool bComplete);
PRBool IsExpired(void) const;
PRBool IsPartial(void) const;
@ -112,6 +121,8 @@ public:
PRUint32 Size(void) const;
void Size(PRUint32 i_Size);
nsStream* Stream(void) const;
const char* Trace() const;
PRUint32 Write(const char* i_Buffer, const PRUint32 len);
@ -130,6 +141,7 @@ protected:
char* m_Filename;
PRUint16 m_Hits;
PRUint32 m_info_size;
PRBool m_bIsCompleted; /* Marked when the stream complete is called */
PRIntervalTime m_LastAccessed, m_LastModified;
void* m_pInfo;
char* m_PageServicesURL;
@ -139,7 +151,6 @@ protected:
PRUint32 m_Size;
nsStream* m_pStream;
char* m_URL;
private:
nsCacheObject& operator=(const nsCacheObject& x);
@ -148,7 +159,7 @@ private:
inline
const char* nsCacheObject::Address(void) const
{
return m_URL;
return m_URL;
};
inline
@ -166,37 +177,37 @@ const char* nsCacheObject::ContentEncoding(void) const
inline
PRUint32 nsCacheObject::ContentLength(void) const
{
return m_ContentLength;
return m_ContentLength;
};
inline
void nsCacheObject::ContentLength(PRUint32 i_Size)
{
m_ContentLength = i_Size;
m_ContentLength = i_Size;
};
inline
const char* nsCacheObject::ContentType(void) const
{
return m_ContentType;
return m_ContentType;
};
inline
const char* nsCacheObject::Etag(void) const
{
return m_Etag;
return m_Etag;
};
inline
PRIntervalTime nsCacheObject::Expires(void) const
{
return m_Expires;
return m_Expires;
};
inline
void nsCacheObject::Expires(PRIntervalTime i_Expires)
{
m_Expires = i_Expires;
m_Expires = i_Expires;
};
inline
@ -208,38 +219,50 @@ const char* nsCacheObject::Filename(void) const
inline
PRUint16 nsCacheObject::Hits(void) const
{
return m_Hits;
return m_Hits;
};
inline
PRBool nsCacheObject::IsCompleted(void) const
{
return m_bIsCompleted;
}
inline
void nsCacheObject::IsCompleted(PRBool bComplete)
{
m_bIsCompleted = bComplete;
}
inline
PRBool nsCacheObject::IsExpired(void) const
{
PRIntervalTime now = PR_IntervalNow();
return (m_Expires <= now);
PRIntervalTime now = PR_IntervalNow();
return (m_Expires <= now);
};
inline
PRBool nsCacheObject::IsPartial(void) const
{
return (m_Flags & nsCacheObject::PARTIAL);
return (m_Flags & nsCacheObject::PARTIAL);
};
inline
PRIntervalTime nsCacheObject::LastAccessed(void) const
{
return m_LastAccessed;
return m_LastAccessed;
};
inline
PRIntervalTime nsCacheObject::LastModified(void) const
{
return m_LastModified;
return m_LastModified;
};
inline
void nsCacheObject::LastModified(const PRIntervalTime i_LastModified)
{
m_LastModified = i_LastModified;
m_LastModified = i_LastModified;
};
inline
@ -275,14 +298,19 @@ PRUint32 nsCacheObject::PostDataLen(void) const
inline
PRUint32 nsCacheObject::Size(void) const
{
return m_Size;
return m_Size;
};
inline
void nsCacheObject::Size(PRUint32 i_Size)
{
m_Size = i_Size;
m_Size = i_Size;
};
inline
nsStream* nsCacheObject::Stream(void) const
{
return m_pStream;
}
#endif // nsCacheObject_h__

8
network/cache/nu/public/nsCachePref.h поставляемый
Просмотреть файл

@ -16,6 +16,14 @@
* Reserved.
*/
/* nsCachePref. A class to separate the preference related code to
* one place. This is an incomplete implementation, I need to access
* the libprefs directly, but that would add another dependency. And
* libpref comes with a JS dependency... so holding this off for the
* moment.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsCachePref_h__
#define nsCachePref_h__

14
network/cache/nu/public/nsDiskModule.h поставляемый
Просмотреть файл

@ -16,14 +16,16 @@
* Reserved.
*/
/*
* nsDiskModule. The disk cache module that stores the cache objects
* on the disk.
*
* Gagan Saksena 02/03/98
*
*/
#ifndef _nsDiskModule_H_
#define _nsDiskModule_H_
/*
* nsDiskModule
*
* Gagan Saksena 02/03/98
*
*/
#include "nsCacheModule.h"
#include "nsCachePref.h"
#include "mcom_db.h"

5
network/cache/nu/public/nsEnumeration.h поставляемый
Просмотреть файл

@ -17,6 +17,11 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Another temporary class that needs to be replaced by a commonly
* used one, or made a commonly used one.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsEnumeration_h__
#define nsEnumeration_h__

5
network/cache/nu/public/nsFileStream.h поставляемый
Просмотреть файл

@ -17,6 +17,11 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
/* nsFileStream. The file/disk based implementation of the nsStream class.
* It basically maps the read write functions to the file equivalents.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsFileStream_h__
#define nsFileStream_h__

4
network/cache/nu/public/nsHash.h поставляемый
Просмотреть файл

@ -16,6 +16,10 @@
* Reserved.
*/
/* A dummy class. Probably will be replaced/removed/recycled.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsHash_h__
#define nsHash_h__

4
network/cache/nu/public/nsIterator.h поставляемый
Просмотреть файл

@ -17,6 +17,10 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Another common class that needs to be replaced/removed/recycled.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsIterator_h__
#define nsIterator_h__

29
network/cache/nu/public/nsMemCacheObject.h поставляемый
Просмотреть файл

@ -16,11 +16,18 @@
* Reserved.
*/
/* The nsMemCacheObject class holds the actual nsCacheObject and a pointer
* to the next nsMemCacheObject. Pretty simple solution for the time being.
* Should be replaced once the memory hash table stuff gets up and running.
*
* -Gagan Saksena 09/15/98.
*/
#ifndef _nsMemCacheObject_h_
#define _nsMemCacheObject_h_
#include "prtypes.h"
#include "prlog.h"
#include "nsCacheObject.h"
class nsMemCacheObject
@ -32,8 +39,6 @@ public:
nsMemCacheObject(const char* i_url);
~nsMemCacheObject();
void* Data(void) const;
void Next(nsMemCacheObject* pObject);
void Next(nsCacheObject* io_pObject);
@ -44,7 +49,6 @@ public:
private:
nsMemCacheObject* m_pNextObject;
nsCacheObject* m_pObject;
void* m_pData;
nsMemCacheObject& operator=(const nsMemCacheObject& mco);
nsMemCacheObject(const nsMemCacheObject&);
@ -53,31 +57,22 @@ private:
inline nsMemCacheObject::nsMemCacheObject(void):
m_pObject(new nsCacheObject()),
m_pNextObject(0),
m_pData(0)
m_pNextObject(0)
{
}
inline nsMemCacheObject::nsMemCacheObject(nsCacheObject* io_pObject):
m_pObject(io_pObject),
m_pNextObject(0),
m_pData(0)
m_pNextObject(0)
{
}
inline nsMemCacheObject::nsMemCacheObject(const char* i_url):
m_pObject(new nsCacheObject(i_url)),
m_pNextObject(0),
m_pData(0)
m_pNextObject(0)
{
}
inline void* nsMemCacheObject::Data(void) const
{
// PR_ASSERT(m_pData);
return m_pData;
}
inline nsMemCacheObject* nsMemCacheObject::Next(void) const
{
return m_pNextObject;
@ -85,11 +80,13 @@ inline nsMemCacheObject* nsMemCacheObject::Next(void) const
inline void nsMemCacheObject::Next(nsMemCacheObject* pObject)
{
PR_ASSERT(0==m_pNextObject);
m_pNextObject = pObject;
}
inline void nsMemCacheObject::Next(nsCacheObject* pObject)
{
PR_ASSERT(0==m_pNextObject);
m_pNextObject = new nsMemCacheObject(pObject);
}

8
network/cache/nu/public/nsMemModule.h поставляемый
Просмотреть файл

@ -15,16 +15,18 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsMemModule_H_
#define _nsMemModule_H_
/*
* nsMemModule
* nsMemModule. The memory based cache module.
*
* Gagan Saksena
* 02/03/98
*
*/
#ifndef _nsMemModule_H_
#define _nsMemModule_H_
#include "nsCacheModule.h"
#include "nsMemCacheObject.h"
#include "nsCachePref.h"

9
network/cache/nu/public/nsMemStream.h поставляемый
Просмотреть файл

@ -17,6 +17,10 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
/* nsMemStream. A memory based stream for use with memory objects
*
* -Gagan Saksena 09/15/98.
*/
#ifndef nsMemStream_h__
#define nsMemStream_h__
@ -43,7 +47,10 @@ protected:
private:
nsMemStream(const nsMemStream& o);
nsMemStream& operator=(const nsMemStream& o);
void* m_pCurrent;
PRUint32 m_AllocSize;
PRUint32 m_ReadOffset;
PRUint32 m_WriteOffset;
void* m_pStart;
PRUint32 m_Size;
};

6
network/cache/nu/public/nsMonitorable.h поставляемый
Просмотреть файл

@ -17,6 +17,12 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
/* nsMonitorable. This is a cool class too. Its an easy of adding monitors
* actually PRMonitor behaviour to existing classes. The nsMonitorLocker is
* an excursion class that locks the scope in which is declared (on stack).
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsMonitorable_h__
#define nsMonitorable_h__

17
network/cache/nu/public/nsStream.h поставляемый
Просмотреть файл

@ -17,6 +17,12 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
/* A placeholder for the actual professional strength streams class. Works
* ok for me for now.
*
* -Gagan Saksena 09/15/98
*/
#ifndef nsStream_h__
#define nsStream_h__
@ -47,5 +53,16 @@ private:
nsStream& operator=(const nsStream& o);
};
inline
nsStream::nsStream(void)
{
//noop
}
inline
nsStream::~nsStream()
{
//noop
}
#endif // nsStream_h__