Prefs changes. All cache preferences are now read directly by NuCache.

This commit is contained in:
gagan%netscape.com 1998-09-28 20:30:54 +00:00
parent affbb78927
commit 57bcdca26e
3 changed files with 45 additions and 39 deletions

View File

@ -70,12 +70,19 @@ public:
/* Singleton */
static nsCacheManager* GetInstance();
nsCacheObject* GetObj(const char* i_url) const;
nsDiskModule* GetDiskModule() const;
nsMemModule* GetMemModule() const;
nsCacheModule* GetModule(PRInt16 i_index) const;
nsMemModule* GetMemModule() const;
nsDiskModule* GetDiskModule() const;
nsCacheObject* GetObj(const char* i_url) const;
nsCachePref* GetPrefs(void) const;
// Initialize the cache manager. Constructor doesn't call this.
// So you must specify this separately.
void Init();
void InfoAsHTML(char* o_Buffer) const;
@ -94,8 +101,6 @@ protected:
PRBool ContainsExactly(const char* i_url) const;
void Init();
nsCacheModule* LastModule() const;
//PRBool Lock(void);
//void Unlock(void);
@ -112,13 +117,14 @@ protected:
*/
private:
nsCacheBkgThd* m_pBkgThd;
nsCacheModule* m_pFirstModule;
PRMonitor* m_pMonitor;
PRBool m_bOffline;
nsCachePref* m_pPrefs;
nsCacheManager(const nsCacheManager& cm);
nsCacheManager& operator=(const nsCacheManager& cm);
nsCacheBkgThd* m_pBkgThd;
PRBool m_bOffline;
};
inline
@ -135,41 +141,23 @@ nsMemModule* nsCacheManager::GetMemModule() const
return (nsMemModule*) m_pFirstModule;
}
inline
nsCachePref* nsCacheManager::GetPrefs(void) const
{
PR_ASSERT(m_pPrefs);
return m_pPrefs;
}
inline
PRBool nsCacheManager::IsOffline(void) const
{
return m_bOffline;
}
/*
inline
PRBool nsCacheManager::Lock(void)
{
if (!m_pMonitor)
{
m_pMonitor = PR_NewMonitor();
if (!m_pMonitor)
return PR_FALSE;
}
PR_EnterMonitor(m_pMonitor);
return PR_TRUE;
}
*/
inline
void nsCacheManager::Offline(PRBool i_bSet)
{
m_bOffline = i_bSet;
}
/*
inline
void nsCacheManager::Unlock(void)
{
PR_ASSERT(m_pMonitor);
if (m_pMonitor)
PR_ExitMonitor(m_pMonitor);
}
*/
#endif

View File

@ -41,10 +41,10 @@ public:
enum Refresh
{
NEVER,
ONCE,
ALWAYS
} r;
ALWAYS,
NEVER
};
const PRUint32 BkgSleepTime(void);
@ -68,6 +68,9 @@ public:
than the cache cleanup routine */
PRBool RevalidateInBkg(void);
/* Setup all prefs */
void SetupPrefs(const char* i_Pref);
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);

View File

@ -40,6 +40,8 @@ public:
// Cache module interface
PRBool AddObject(nsCacheObject* io_pObject);
PRUint32 AverageSize(void) const;
PRBool Contains(nsCacheObject* io_pObject) const;
PRBool Contains(const char* i_url) const;
@ -50,9 +52,8 @@ public:
nsStream* GetStreamFor(const nsCacheObject* i_pObject);
PRBool ReduceSizeTo(const PRUint32 i_NewSize);
PRBool Remove(const char* i_url);
PRBool Remove(nsCacheObject* pObject);
PRBool Remove(const PRUint32 i_index);
// To do cleanup set size to zero. Else initialize disk cache
@ -60,6 +61,10 @@ public:
PRBool Revalidate(void);
protected:
PRBool ReduceSizeTo(const PRUint32 i_NewSize);
private:
enum sync_frequency
{
@ -76,4 +81,14 @@ private:
DB* m_pDB;
};
inline
PRUint32 nsDiskModule::AverageSize(void) const
{
MonitorLocker ml((nsDiskModule*)this);
if (Entries()>0)
{
return (PRUint32)(m_SizeInUse/m_Entries);
}
return 0;
}
#endif