зеркало из https://github.com/mozilla/gecko-dev.git
NOT in BUILD! Progress on new cache architecture-
Flat file design, Background Thread, C stubs, Flat file test, etc.
This commit is contained in:
Родитель
948d7d756a
Коммит
882fb4ad4c
|
@ -0,0 +1,132 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsFFEntry_h__
|
||||
#define nsFFEntry_h__
|
||||
|
||||
#include "nsFFObject.h"
|
||||
//#include "nsISupports.h"
|
||||
/** An FFEntry consists of several objects, all io takes place
|
||||
* through the FFEntry's read and write functions */
|
||||
|
||||
class nsFFEntry//: public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
nsFFEntry();
|
||||
nsFFEntry(const PRUint32 i_ID);
|
||||
//Single block entries can use this constructor
|
||||
nsFFEntry(const PRUint32 i_ID, const PRUint32 i_offset, const PRUint32 i_size);
|
||||
virtual ~nsFFEntry();
|
||||
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
*/
|
||||
|
||||
PRBool AddObject(const nsFFObject* i_object);
|
||||
|
||||
//Appends an entry to the list
|
||||
PRBool AddEntry(const nsFFEntry* i_pEntry);
|
||||
|
||||
nsFFObject* FirstObject(void) const;
|
||||
void FirstObject(const nsFFObject* i_object);
|
||||
|
||||
PRUint32 ID(void) const;
|
||||
void ID(const PRUint32 i_ID);
|
||||
|
||||
nsFFEntry* NextEntry(void) const;
|
||||
void NextEntry(const nsFFEntry* i_pEntry);
|
||||
|
||||
//Returns the number of objects in this entry.
|
||||
PRUint32 Objects(void) const;
|
||||
|
||||
PRBool Remove(void);
|
||||
|
||||
PRUint32 Size(void) const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsFFEntry(const nsFFEntry& o);
|
||||
nsFFEntry& operator=(const nsFFEntry& o);
|
||||
|
||||
nsFFObject* m_pFirstObject;
|
||||
nsFFEntry* m_pNextEntry;
|
||||
|
||||
PRUint32 m_ID;
|
||||
PRUint32 m_Objects;
|
||||
};
|
||||
|
||||
inline
|
||||
PRBool nsFFEntry::AddEntry(const nsFFEntry* i_Entry)
|
||||
{
|
||||
if (!i_Entry)
|
||||
return PR_FALSE;
|
||||
if (m_pNextEntry)
|
||||
return m_pNextEntry->AddEntry(i_Entry);
|
||||
m_pNextEntry = (nsFFEntry*) i_Entry;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
nsFFObject* nsFFEntry::FirstObject(void) const
|
||||
{
|
||||
return m_pFirstObject;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsFFEntry::ID(void) const
|
||||
{
|
||||
return m_ID;
|
||||
}
|
||||
|
||||
inline
|
||||
void nsFFEntry::ID(const PRUint32 i_id)
|
||||
{
|
||||
m_ID = i_id;
|
||||
}
|
||||
|
||||
inline
|
||||
nsFFEntry* nsFFEntry::NextEntry(void) const
|
||||
{
|
||||
return m_pNextEntry;
|
||||
}
|
||||
|
||||
inline
|
||||
void nsFFEntry::NextEntry(const nsFFEntry* i_pEntry)
|
||||
{
|
||||
m_pNextEntry = (nsFFEntry*) i_pEntry;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsFFEntry::Objects(void) const
|
||||
{
|
||||
return m_Objects;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsFFEntry::Size(void) const
|
||||
{
|
||||
return m_pFirstObject ? m_pFirstObject->TotalSize() : 0; // Assumption that there is no zero length files //TODO
|
||||
}
|
||||
|
||||
#endif // nsFFEntry_h__
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsFFObject_h__
|
||||
#define nsFFObject_h__
|
||||
|
||||
#include <prtypes.h>
|
||||
|
||||
class nsFFObject
|
||||
{
|
||||
|
||||
public:
|
||||
nsFFObject(
|
||||
PRUint32 i_ID,
|
||||
PRUint32 i_Offset,
|
||||
PRUint32 i_Size = 0);
|
||||
|
||||
virtual ~nsFFObject();
|
||||
|
||||
PRBool Add(const nsFFObject* i_object);
|
||||
|
||||
PRUint32 ID(void) const;
|
||||
void ID(const PRUint32 i_ID);
|
||||
|
||||
nsFFObject* Next(void) const;
|
||||
void Next(nsFFObject* io_pNext);
|
||||
|
||||
PRUint32 Offset(void) const;
|
||||
void Offset(const PRUint32 i_offset);
|
||||
|
||||
PRUint32 Size(void) const;
|
||||
void Size(const PRUint32 i_Size);
|
||||
|
||||
PRUint32 TotalSize(void) const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsFFObject(const nsFFObject& o);
|
||||
nsFFObject& operator=(const nsFFObject& o);
|
||||
|
||||
PRUint32 m_ID;
|
||||
PRUint32 m_Offset;
|
||||
PRUint32 m_Size;
|
||||
|
||||
nsFFObject* m_pNext;
|
||||
};
|
||||
|
||||
inline
|
||||
PRUint32 nsFFObject::ID(void) const
|
||||
{
|
||||
return m_ID;
|
||||
}
|
||||
|
||||
inline
|
||||
void nsFFObject::ID(const PRUint32 i_ID)
|
||||
{
|
||||
m_ID = i_ID;
|
||||
}
|
||||
|
||||
inline
|
||||
nsFFObject* nsFFObject::Next(void) const
|
||||
{
|
||||
return m_pNext;
|
||||
}
|
||||
|
||||
inline
|
||||
void nsFFObject::Next(nsFFObject* io_pNext)
|
||||
{
|
||||
if (io_pNext)
|
||||
io_pNext->ID(m_ID);
|
||||
m_pNext = io_pNext;
|
||||
// Overlap check! //TODO
|
||||
//PR_ASSERT(io_pNext->Offset() > m_Offset + m_Size) ||
|
||||
// (io_pNext->Offset() + io_pNext->Size() < m_Offset)
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsFFObject::Offset(void) const
|
||||
{
|
||||
return m_Offset;
|
||||
}
|
||||
|
||||
inline
|
||||
void nsFFObject::Offset(const PRUint32 i_Offset)
|
||||
{
|
||||
m_Offset = i_Offset;
|
||||
//TODO - overlap check.
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsFFObject::Size(void) const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
|
||||
inline
|
||||
void nsFFObject::Size(const PRUint32 i_Size)
|
||||
{
|
||||
m_Size = i_Size;
|
||||
//TODO - Overlap check.
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsFFObject::TotalSize(void) const
|
||||
{
|
||||
return m_Size + (m_pNext ? m_pNext->TotalSize() : 0);
|
||||
}
|
||||
#endif // nsFFObject_h__
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsFlatFile_h__
|
||||
#define nsFlatFile_h__
|
||||
|
||||
#include <prtypes.h>
|
||||
#include <prio.h>
|
||||
|
||||
//#include "nsISupports.h"
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#ifndef COPY_INT32
|
||||
#define COPY_INT32(_a,_b) memcpy(_a, _b, sizeof(int32))
|
||||
#else
|
||||
#define COPY_INT32(_a,_b) /* swap */ \
|
||||
do { \
|
||||
((char *)(_a))[0] = ((char *)(_b))[3]; \
|
||||
((char *)(_a))[1] = ((char *)(_b))[2]; \
|
||||
((char *)(_a))[2] = ((char *)(_b))[1]; \
|
||||
((char *)(_a))[3] = ((char *)(_b))[0]; \
|
||||
} while(0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** A class to handle flat file storage mechanism */
|
||||
static const PRUint32 kPAGE_SIZE =4096;
|
||||
|
||||
class nsFlatFile //: public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
nsFlatFile(const char* i_pFilename,
|
||||
const PRUint32 i_FileSize= 5242880); // 5 meg
|
||||
// TODO think if we want to substract the toc size from this?
|
||||
|
||||
virtual ~nsFlatFile();
|
||||
|
||||
const char* Filename(void) const;
|
||||
|
||||
PRUint32 HeaderSize(void) const;
|
||||
|
||||
void Init(void);
|
||||
|
||||
PRBool IsValid(void) const;
|
||||
|
||||
PRUint32 Size(void) const;
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
*/
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsFlatFile(const nsFlatFile& o);
|
||||
nsFlatFile& operator=(const nsFlatFile& o);
|
||||
|
||||
PRBool m_bIsValid;
|
||||
char* m_pFilename;
|
||||
PRUint32 m_Size;
|
||||
|
||||
PRFileDesc* m_pFD;
|
||||
PRUint32 m_HeaderSize;
|
||||
};
|
||||
|
||||
inline
|
||||
const char* nsFlatFile::Filename(void) const
|
||||
{
|
||||
return m_pFilename;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsFlatFile::HeaderSize(void) const
|
||||
{
|
||||
return m_HeaderSize;
|
||||
}
|
||||
|
||||
inline
|
||||
PRBool nsFlatFile::IsValid(void) const
|
||||
{
|
||||
return m_bIsValid;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsFlatFile::Size(void) const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
#endif // nsFlatFile_h__
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsTOC_h__
|
||||
#define nsTOC_h__
|
||||
|
||||
//#include "nsISupports.h"
|
||||
|
||||
#include "nsFlatFile.h"
|
||||
#include "nsFFEntry.h"
|
||||
|
||||
class nsTOC//: public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
nsTOC(const char* i_pFilename, nsFlatFile* i_pFlatFile);
|
||||
virtual ~nsTOC();
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
*/
|
||||
|
||||
nsFFEntry* AddEntry(PRUint32 i_size = kPAGE_SIZE);
|
||||
|
||||
PRUint32 Entries(void) const;
|
||||
|
||||
const char* Filename(void) const;
|
||||
|
||||
nsFFEntry* FirstDataEntry(void) const;
|
||||
|
||||
nsFFEntry* FreeEntry(void) const;
|
||||
|
||||
void Init(void);
|
||||
|
||||
PRBool IsValid(void) const;
|
||||
|
||||
protected:
|
||||
PRUint32 NextID(void) const;
|
||||
|
||||
PRBool Serialize(nsFFEntry* io_Entry, PRBool bRead = PR_FALSE);
|
||||
|
||||
|
||||
private:
|
||||
nsTOC(const nsTOC& o);
|
||||
nsTOC& operator=(const nsTOC& o);
|
||||
|
||||
nsFFEntry* m_pContents; // The first entry is reserved for free space list
|
||||
PRUint32 m_Entries;
|
||||
char* m_pFilename;
|
||||
nsFlatFile* m_pFlatFile;
|
||||
PRFileDesc* m_pFD;
|
||||
PRBool m_bIsValid;
|
||||
};
|
||||
|
||||
inline
|
||||
PRUint32 nsTOC::Entries(void) const
|
||||
{
|
||||
return m_Entries;
|
||||
}
|
||||
|
||||
inline
|
||||
const char* nsTOC::Filename(void) const
|
||||
{
|
||||
return m_pFilename;
|
||||
}
|
||||
|
||||
inline
|
||||
nsFFEntry* nsTOC::FirstDataEntry(void) const
|
||||
{
|
||||
return m_pContents ? m_pContents->NextEntry() : 0;
|
||||
}
|
||||
|
||||
inline
|
||||
nsFFEntry* nsTOC::FreeEntry(void) const
|
||||
{
|
||||
return m_pContents;
|
||||
}
|
||||
|
||||
inline
|
||||
PRBool nsTOC::IsValid(void) const
|
||||
{
|
||||
return m_bIsValid;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUint32 nsTOC::NextID(void) const
|
||||
{
|
||||
return m_Entries + 1;
|
||||
}
|
||||
#endif // nsTOC_h__
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsGeneric.h"
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsGeneric_h__
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/* Designed 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 */
|
||||
|
||||
#ifndef CacheStubs_h__
|
||||
#define CacheStubs_h__
|
||||
|
||||
#include <prtypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Cache Manager stub functions
|
||||
Does not include other functions not required in the current
|
||||
design like AddModule etc... */
|
||||
extern PRBool CacheManager_Contains(const char* i_url);
|
||||
extern PRUint32 CacheManager_Entries(void);
|
||||
extern PRBool CacheManager_IsOffline(void);
|
||||
extern void CacheManager_Offline(PRBool bSet);
|
||||
extern PRUint32 CacheManager_WorstCaseTime(void);
|
||||
|
||||
/* Disk Module functions */
|
||||
/*
|
||||
extern PRBool DiskModule_AddObject() */
|
||||
extern PRBool DiskModule_Contains(const char* i_url);
|
||||
extern PRUint32 DiskModule_Entries(void);
|
||||
extern PRUint32 DiskModule_GetSize(void);
|
||||
extern PRBool DiskModule_IsEnabled(void);
|
||||
extern PRBool DiskModule_Remove(const char* i_url);
|
||||
extern void DiskModule_SetSize(PRUint32 i_Size);
|
||||
|
||||
/* Mem Module functions */
|
||||
/*
|
||||
extern PRBool MemModule_AddObject() */
|
||||
extern PRBool MemModule_Contains(const char* i_url);
|
||||
extern PRUint32 MemModule_Entries(void);
|
||||
extern PRUint32 MemModule_GetSize(void);
|
||||
extern PRBool MemModule_IsEnabled(void);
|
||||
extern PRBool MemModule_Remove(const char* i_url);
|
||||
extern void MemModule_SetSize(PRUint32 i_Size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CacheStubs_h__
|
||||
|
|
@ -20,9 +20,10 @@ IGNORE_MANIFEST=1
|
|||
|
||||
MODULE=cache
|
||||
|
||||
EXPORTS=nsCacheObject.h nsMemModule.h nsCacheManager.h \
|
||||
nsDiskModule.h nsCacheModule.h nsMemCacheObject.h \
|
||||
nsCachePref.h \
|
||||
EXPORTS=nsCacheObject.h nsMemModule.h nsCacheManager.h \
|
||||
nsDiskModule.h nsCacheModule.h nsMemCacheObject.h \
|
||||
nsCachePref.h nsCacheBkgThd.h nsBkgThread.h \
|
||||
CacheStubs.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsBkgThread_h__
|
||||
#define nsBkgThread_h__
|
||||
|
||||
//#include "nsISupports.h"
|
||||
#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
|
||||
{
|
||||
|
||||
public:
|
||||
nsBkgThread(PRIntervalTime iSleepTime, PRBool bStart=PR_TRUE);
|
||||
virtual ~nsBkgThread();
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
*/
|
||||
void Process(void);
|
||||
virtual void Run(void) = 0;
|
||||
void Stop(void);
|
||||
protected:
|
||||
PRThread* m_pThread;
|
||||
PRBool m_bContinue;
|
||||
PRIntervalTime m_SleepTime;
|
||||
|
||||
private:
|
||||
nsBkgThread(const nsBkgThread& o);
|
||||
nsBkgThread& operator=(const nsBkgThread& o);
|
||||
|
||||
};
|
||||
|
||||
#endif // nsBkgThread_h__
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsCacheBkgThd_h__
|
||||
#define nsCacheBkgThd_h__
|
||||
|
||||
#include "nsBkgThread.h"
|
||||
|
||||
class nsCacheBkgThd: public nsBkgThread
|
||||
{
|
||||
|
||||
public:
|
||||
nsCacheBkgThd(PRIntervalTime iSleepTime);
|
||||
virtual ~nsCacheBkgThd();
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
*/
|
||||
void Run(void);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsCacheBkgThd(const nsCacheBkgThd& o);
|
||||
nsCacheBkgThd& operator=(const nsCacheBkgThd& o);
|
||||
};
|
||||
|
||||
#endif // nsCacheBkgThd_h__
|
||||
|
|
@ -20,31 +20,36 @@
|
|||
#define _CacheManager_H_
|
||||
/*
|
||||
* nsCacheManager
|
||||
*
|
||||
* Gagan Saksena 02/02/98
|
||||
* Designed and original implementation
|
||||
* by Gagan Saksena 02/02/98
|
||||
*
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#include "nsISupports.h"
|
||||
# include "nsISupports.h"
|
||||
#endif
|
||||
|
||||
#include <prlog.h>
|
||||
|
||||
#include "nsCacheModule.h"
|
||||
#include "nsCacheObject.h"
|
||||
|
||||
class nsMemModule;
|
||||
class nsDiskModule;
|
||||
class nsCachePref;
|
||||
class nsCacheBkgThd;
|
||||
|
||||
class nsCacheManager //: public nsISupports
|
||||
{
|
||||
/* Change entries from 32 to 16 bit */
|
||||
|
||||
public:
|
||||
enum modules
|
||||
{
|
||||
|
||||
//Reserved modules
|
||||
enum modules
|
||||
{
|
||||
MEM =0,
|
||||
DISK=1
|
||||
};
|
||||
};
|
||||
|
||||
nsCacheManager();
|
||||
~nsCacheManager();
|
||||
|
@ -66,6 +71,10 @@ public:
|
|||
nsMemModule* GetMemModule() const;
|
||||
nsDiskModule* GetDiskModule() const;
|
||||
|
||||
PRBool IsOffline(void) const;
|
||||
|
||||
void Offline(PRBool bSet);
|
||||
|
||||
const char* Trace() const;
|
||||
|
||||
/* Performance measure- microseconds */
|
||||
|
@ -77,10 +86,38 @@ protected:
|
|||
LastModule() const;
|
||||
|
||||
private:
|
||||
nsCacheModule* m_pFirstModule;
|
||||
nsCacheModule* m_pFirstModule;
|
||||
|
||||
nsCacheManager(const nsCacheManager& cm);
|
||||
nsCacheManager& operator=(const nsCacheManager& cm);
|
||||
nsCacheBkgThd* m_pBkgThd;
|
||||
PRBool m_bOffline;
|
||||
};
|
||||
|
||||
inline
|
||||
nsDiskModule* nsCacheManager::GetDiskModule() const
|
||||
{
|
||||
PR_ASSERT(m_pFirstModule && m_pFirstModule->Next());
|
||||
return (m_pFirstModule) ? (nsDiskModule*) m_pFirstModule->Next() : NULL;
|
||||
}
|
||||
|
||||
inline
|
||||
nsMemModule* nsCacheManager::GetMemModule() const
|
||||
{
|
||||
PR_ASSERT(m_pFirstModule);
|
||||
return (nsMemModule*) m_pFirstModule;
|
||||
}
|
||||
|
||||
inline
|
||||
PRBool nsCacheManager::IsOffline(void) const
|
||||
{
|
||||
return m_bOffline;
|
||||
}
|
||||
|
||||
inline
|
||||
void nsCacheManager::Offline(PRBool i_bSet)
|
||||
{
|
||||
m_bOffline = i_bSet;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,14 +48,21 @@ public:
|
|||
|
||||
virtual
|
||||
PRBool AddObject(nsCacheObject* i_pObject)=0;
|
||||
virtual
|
||||
|
||||
virtual
|
||||
PRBool Contains(const char* i_url) const=0;
|
||||
virtual
|
||||
PRBool Contains(nsCacheObject* i_pObject) const=0;
|
||||
|
||||
void Enable(PRBool i_Enable);
|
||||
const PRUint32 Entries() const;
|
||||
|
||||
const PRUint32 Entries(void) const;
|
||||
|
||||
nsCacheObject* GetFirstObject() const ;//TODO-?/
|
||||
//TODO move to own interface for both Garbage Collection and Revalidation
|
||||
virtual
|
||||
void GarbageCollect(void);
|
||||
|
||||
nsCacheObject* GetFirstObject(void) const ;//TODO-?/
|
||||
|
||||
virtual
|
||||
nsCacheObject* GetObject(const char* i_url) const=0;
|
||||
|
@ -63,15 +70,27 @@ public:
|
|||
virtual
|
||||
nsCacheObject* GetObject(const PRUint32 i_index) const =0;
|
||||
|
||||
PRBool IsEnabled() const;
|
||||
PRBool IsEnabled(void) const;
|
||||
|
||||
nsCacheModule* Next() const;
|
||||
/* Cant do additions, deletions, validations, expirations */
|
||||
PRBool IsReadOnly(void) const;
|
||||
|
||||
nsCacheModule* Next(void) const;
|
||||
void Next(nsCacheModule*);
|
||||
|
||||
const PRUint32 Size() const;
|
||||
virtual
|
||||
PRBool Remove(const char* i_url) = 0;
|
||||
|
||||
virtual
|
||||
PRBool Remove(const PRUint32 i_index) = 0;
|
||||
|
||||
virtual
|
||||
PRBool Revalidate(void) = 0;
|
||||
|
||||
const PRUint32 Size(void) const;
|
||||
void Size(const PRUint32 i_size);
|
||||
|
||||
const char* Trace() const;
|
||||
const char* Trace(void) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -92,11 +111,6 @@ inline void nsCacheModule::Enable(PRBool i_Enable)
|
|||
m_Enabled = i_Enable;
|
||||
}
|
||||
|
||||
inline PRBool nsCacheModule::IsEnabled() const
|
||||
{
|
||||
return m_Enabled;
|
||||
}
|
||||
|
||||
inline const PRUint32 nsCacheModule::Entries() const
|
||||
{
|
||||
return m_Entries;
|
||||
|
@ -107,7 +121,17 @@ inline nsCacheObject* nsCacheModule::GetFirstObject() const
|
|||
return this->GetObject((PRUint32)0);
|
||||
}
|
||||
|
||||
inline nsCacheModule* nsCacheModule::Next() const
|
||||
inline PRBool nsCacheModule::IsEnabled(void) const
|
||||
{
|
||||
return m_Enabled;
|
||||
}
|
||||
|
||||
inline PRBool nsCacheModule::IsReadOnly(void) const
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
inline nsCacheModule* nsCacheModule::Next(void) const
|
||||
{
|
||||
return m_pNext;
|
||||
}
|
||||
|
|
|
@ -68,10 +68,13 @@ public:
|
|||
/* Read and write info about this cache object */
|
||||
void* Info(void) const;
|
||||
PRBool Info(void*);
|
||||
|
||||
PRUint32 InfoSize(void) const;
|
||||
|
||||
PRBool IsExpired(void) const;
|
||||
|
||||
PRBool IsPartial(void) const;
|
||||
|
||||
PRIntervalTime
|
||||
LastAccessed(void) const;
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ class nsCachePref //: public nsISupports
|
|||
public:
|
||||
static nsCachePref* GetInstance(void);
|
||||
|
||||
// should really be protected/private
|
||||
nsCachePref(void);
|
||||
~nsCachePref();
|
||||
|
||||
|
@ -39,14 +38,21 @@ public:
|
|||
ALWAYS
|
||||
} r;
|
||||
|
||||
static const char* DiskCacheDBFilename(void); /* like Fat.db */
|
||||
static const char* DiskCacheFolder(void); /* Cache dir */
|
||||
static const PRUint32 BkgSleepTime(void);
|
||||
|
||||
static const char* DiskCacheDBFilename(void); /* like Fat.db */
|
||||
static const char* DiskCacheFolder(void); /* Cache dir */
|
||||
|
||||
static PRUint32 DiskCacheSize(void);
|
||||
static PRUint32 MemCacheSize(void);
|
||||
static PRUint32 DiskCacheSize(void);
|
||||
static PRUint32 MemCacheSize(void);
|
||||
|
||||
static nsCachePref::Refresh
|
||||
Frequency(void);
|
||||
Frequency(void);
|
||||
|
||||
/* Revalidating in background, makes IMS calls in the bkg thread to
|
||||
update cache entries. TODO, this should be at a bigger time period
|
||||
than the cache cleanup routine */
|
||||
static PRBool RevalidateInBkg(void);
|
||||
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
|
@ -57,7 +63,14 @@ public:
|
|||
private:
|
||||
nsCachePref(const nsCachePref& o);
|
||||
nsCachePref& operator=(const nsCachePref& o);
|
||||
static nsCachePref* m_pPref;
|
||||
|
||||
PRBool m_bRevalidateInBkg;
|
||||
nsCachePref::Refresh m_RefreshFreq;
|
||||
PRUint32 m_MemCacheSize;
|
||||
PRUint32 m_DiskCacheSize;
|
||||
char* m_DiskCacheDBFilename;
|
||||
char* m_DiskCacheFolder;
|
||||
PRUint32 m_BkgSleepTime;
|
||||
};
|
||||
|
||||
#endif // nsCachePref_h__
|
||||
|
|
|
@ -37,10 +37,19 @@ public:
|
|||
|
||||
// Cache module interface
|
||||
PRBool AddObject(nsCacheObject* io_pObject);
|
||||
PRBool Contains(nsCacheObject* io_pObject) const;
|
||||
|
||||
PRBool Contains(nsCacheObject* io_pObject) const;
|
||||
PRBool Contains(const char* i_url) const;
|
||||
nsCacheObject* GetObject(const PRUint32 i_index) const;
|
||||
nsCacheObject* GetObject(const char* i_url) const;
|
||||
|
||||
void GarbageCollect(void);
|
||||
|
||||
nsCacheObject* GetObject(const PRUint32 i_index) const;
|
||||
nsCacheObject* GetObject(const char* i_url) const;
|
||||
|
||||
PRBool Remove(const char* i_url);
|
||||
PRBool Remove(const PRUint32 i_index);
|
||||
|
||||
PRBool Revalidate(void);
|
||||
|
||||
private:
|
||||
enum sync_frequency
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsHash_h__
|
||||
#define nsHash_h__
|
||||
|
||||
#include <plhash.h>
|
||||
|
||||
class nsHashKey {
|
||||
protected:
|
||||
nsHashKey(void);
|
||||
public:
|
||||
virtual ~nsHashKey(void);
|
||||
virtual PRUint32 HashValue(void) const = 0;
|
||||
virtual PRBool Equals(const nsHashKey *aKey) const = 0;
|
||||
virtual nsHashKey *Clone(void) const = 0;
|
||||
};
|
||||
|
||||
// Enumerator callback function. Use
|
||||
|
||||
typedef PRBool (*nsHashEnumFunc)(nsHashKey *aKey, void *aData);
|
||||
|
||||
class nsHash {
|
||||
private:
|
||||
// members
|
||||
PLHashTable *hashtable;
|
||||
|
||||
public:
|
||||
nsHash(PRUint32 aSize = 256);
|
||||
~nsHash();
|
||||
|
||||
void *Put(nsHashKey *aKey, void *aData);
|
||||
void *Get(nsHashKey *aKey);
|
||||
void *Remove(nsHashKey *aKey);
|
||||
void Enumerate(nsHashEnumFunc aEnumFunc);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -52,11 +52,20 @@ public:
|
|||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
*/
|
||||
PRBool AddObject(nsCacheObject* io_pObject);
|
||||
PRBool Contains(nsCacheObject* io_pObject) const;
|
||||
PRBool AddObject(nsCacheObject* io_pObject);
|
||||
|
||||
PRBool Contains(nsCacheObject* io_pObject) const;
|
||||
PRBool Contains(const char* i_url) const;
|
||||
nsCacheObject* GetObject(const PRUint32 i_index) const;
|
||||
nsCacheObject* GetObject(const char* i_url) const;
|
||||
|
||||
void GarbageCollect(void);
|
||||
|
||||
nsCacheObject* GetObject(const PRUint32 i_index) const;
|
||||
nsCacheObject* GetObject(const char* i_url) const;
|
||||
|
||||
PRBool Remove(const char* i_url);
|
||||
PRBool Remove(const PRUint32 i_index);
|
||||
|
||||
PRBool Revalidate(void);
|
||||
|
||||
// Start of nsMemModule specific stuff...
|
||||
// Here is a sample implementation using linked list
|
||||
|
@ -86,4 +95,11 @@ private:
|
|||
*/
|
||||
};
|
||||
|
||||
inline
|
||||
PRBool nsMemModule::Revalidate(void)
|
||||
{
|
||||
/* Mem module elements are never revalidated */
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/* Designed and original implementation by Gagan Saksena '98 */
|
||||
|
||||
#include "CacheStubs.h"
|
||||
#include "nsCacheManager.h"
|
||||
#include "nsDiskModule.h"
|
||||
#include "nsMemModule.h"
|
||||
|
||||
#define CM nsCacheManager::GetInstance()
|
||||
|
||||
PRBool
|
||||
CacheManager_Contains(const char* i_url)
|
||||
{
|
||||
return CM->Entries();
|
||||
}
|
||||
|
||||
PRUint32
|
||||
CacheManager_Entries()
|
||||
{
|
||||
return CM->Entries();
|
||||
}
|
||||
|
||||
PRBool
|
||||
CacheManager_IsOffline(void)
|
||||
{
|
||||
return CM->IsOffline();
|
||||
}
|
||||
|
||||
void
|
||||
CacheManager_Offline(PRBool bSet)
|
||||
{
|
||||
CM->Offline(bSet);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
CacheManager_WorstCaseTime(void)
|
||||
{
|
||||
return CM->WorstCaseTime();
|
||||
}
|
||||
|
||||
#define DM nsCacheManager::GetInstance()->GetDiskModule()
|
||||
|
||||
PRBool
|
||||
DiskModule_Contains(const char* i_url)
|
||||
{
|
||||
return DM->Contains(i_url);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
DiskModule_Entries(void)
|
||||
{
|
||||
return DM->Entries();
|
||||
}
|
||||
|
||||
PRUint32
|
||||
DiskModule_GetSize(void)
|
||||
{
|
||||
return DM->Size();
|
||||
}
|
||||
|
||||
PRBool
|
||||
DiskModule_IsEnabled(void)
|
||||
{
|
||||
return DM->IsEnabled();
|
||||
}
|
||||
|
||||
PRBool
|
||||
DiskModule_Remove(const char* i_url)
|
||||
{
|
||||
return DM->Remove(i_url);
|
||||
}
|
||||
|
||||
void
|
||||
DiskModule_SetSize(PRUint32 i_Size)
|
||||
{
|
||||
DM->Size(i_Size);
|
||||
}
|
||||
|
||||
#define MM nsCacheManager::GetInstance()->GetMemModule()
|
||||
|
||||
PRBool
|
||||
MemModule_Contains(const char* i_url)
|
||||
{
|
||||
return MM->Contains(i_url);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
MemModule_Entries(void)
|
||||
{
|
||||
return MM->Entries();
|
||||
}
|
||||
|
||||
PRUint32
|
||||
MemModule_GetSize(void)
|
||||
{
|
||||
return MM->Size();
|
||||
}
|
||||
|
||||
PRBool
|
||||
MemModule_IsEnabled(void)
|
||||
{
|
||||
return MM->IsEnabled();
|
||||
}
|
||||
|
||||
PRBool
|
||||
MemModule_Remove(const char* i_url)
|
||||
{
|
||||
return MM->Remove(i_url);
|
||||
}
|
||||
|
||||
void
|
||||
MemModule_SetSize(PRUint32 i_Size)
|
||||
{
|
||||
MM->Size(i_Size);
|
||||
}
|
|
@ -25,7 +25,9 @@ DLLNAME = cachelib
|
|||
|
||||
LIBRARY_NAME=cachelib
|
||||
|
||||
#
|
||||
# Remember to change libplc21 to $whatever it is...
|
||||
#
|
||||
LLIBS = \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
|
@ -46,6 +48,9 @@ OBJS = \
|
|||
.\$(OBJDIR)\nsCacheManager.obj \
|
||||
.\$(OBJDIR)\nsCachePref.obj \
|
||||
.\$(OBJDIR)\nsMemCacheObject.obj \
|
||||
.\$(OBJDIR)\nsBkgThread.obj \
|
||||
.\$(OBJDIR)\nsCacheBkgThd.obj \
|
||||
.\$(OBJDIR)\CacheStubs.obj \
|
||||
$(NULL)
|
||||
|
||||
# .\$(OBJDIR)\nsHash.obj \
|
||||
|
@ -53,6 +58,7 @@ OBJS = \
|
|||
LINCS = \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\dbm \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I..\public \
|
||||
-I..\include \
|
||||
$(NULL)
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsBkgThread.h"
|
||||
#include <prlog.h>
|
||||
|
||||
static void PR_CALLBACK RunFunction(void* arg);
|
||||
|
||||
static void PR_CALLBACK RunFunction(void* arg)
|
||||
{
|
||||
nsBkgThread* pBT = (nsBkgThread*) arg;
|
||||
if (pBT)
|
||||
{
|
||||
pBT->Process();
|
||||
}
|
||||
}
|
||||
|
||||
nsBkgThread::nsBkgThread(PRIntervalTime iSleepTime, PRBool bStart /* =PR_TRUE */)
|
||||
{
|
||||
m_SleepTime = iSleepTime;
|
||||
m_bContinue = bStart;
|
||||
m_pThread = PR_CreateThread(
|
||||
PR_USER_THREAD,
|
||||
RunFunction,
|
||||
this,
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_LOCAL_THREAD,
|
||||
PR_JOINABLE_THREAD,
|
||||
0);
|
||||
PR_ASSERT(NULL != m_pThread);
|
||||
}
|
||||
|
||||
nsBkgThread::~nsBkgThread()
|
||||
{
|
||||
m_bContinue = PR_FALSE;
|
||||
if (m_pThread != NULL)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
/*
|
||||
nsrefcnt nsBkgThread::AddRef(void)
|
||||
{
|
||||
return ++m_RefCnt;
|
||||
}
|
||||
nsrefcnt nsBkgThread::Release(void)
|
||||
{
|
||||
if (--m_RefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_RefCnt;
|
||||
}
|
||||
|
||||
nsresult nsBkgThread::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*/
|
||||
void nsBkgThread::Process(void)
|
||||
{
|
||||
while (m_bContinue)
|
||||
{
|
||||
PR_Sleep(m_SleepTime);
|
||||
Run();
|
||||
}
|
||||
}
|
||||
|
||||
void nsBkgThread::Stop(void)
|
||||
{
|
||||
m_bContinue = PR_FALSE;
|
||||
PRStatus status = PR_Interrupt(m_pThread);
|
||||
PR_ASSERT(PR_SUCCESS == status);
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <prlog.h>
|
||||
#include "nsCacheBkgThd.h"
|
||||
#include "nsCacheManager.h"
|
||||
#include "nsCacheModule.h"
|
||||
#include "nsCachePref.h"
|
||||
|
||||
nsCacheBkgThd::nsCacheBkgThd(PRIntervalTime iSleepTime):
|
||||
nsBkgThread(iSleepTime)
|
||||
{
|
||||
}
|
||||
|
||||
nsCacheBkgThd::~nsCacheBkgThd()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
nsrefcnt nsCacheBkgThd::AddRef(void)
|
||||
{
|
||||
return ++m_RefCnt;
|
||||
}
|
||||
nsrefcnt nsCacheBkgThd::Release(void)
|
||||
{
|
||||
if (--m_RefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_RefCnt;
|
||||
}
|
||||
|
||||
nsresult nsCacheBkgThd::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
void nsCacheBkgThd::Run(void)
|
||||
{
|
||||
/* Step thru all the modules and call cleanup on each */
|
||||
nsCacheManager* pCM = nsCacheManager::GetInstance();
|
||||
PR_ASSERT(pCM);
|
||||
if (pCM->IsOffline())
|
||||
return; /* Dont update entries if offline */
|
||||
PRUint32 i = pCM->Entries();
|
||||
while (i>0)
|
||||
{
|
||||
nsCacheModule* pModule = pCM->GetModule(--i);
|
||||
PR_ASSERT(pModule);
|
||||
/* TODO change this based on if it supports garbage cleaning */
|
||||
if (!pModule->IsReadOnly())
|
||||
{
|
||||
pModule->GarbageCollect();
|
||||
if (nsCachePref::RevalidateInBkg())
|
||||
{
|
||||
pModule->Revalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,16 +34,22 @@
|
|||
#include "nsCacheModule.h"
|
||||
#include "nsMemModule.h"
|
||||
#include "nsDiskModule.h"
|
||||
#include "nsCacheBkgThd.h"
|
||||
|
||||
static nsCacheManager TheManager;
|
||||
|
||||
nsCacheManager::nsCacheManager(): m_pFirstModule(0)
|
||||
nsCacheManager::nsCacheManager(): m_pFirstModule(0), m_bOffline(PR_FALSE)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
nsCacheManager::~nsCacheManager()
|
||||
{
|
||||
if (m_pBkgThd)
|
||||
{
|
||||
m_pBkgThd->Stop();
|
||||
delete m_pBkgThd;
|
||||
}
|
||||
if (m_pFirstModule)
|
||||
delete m_pFirstModule;
|
||||
}
|
||||
|
@ -143,25 +149,15 @@ nsCacheManager::GetModule(PRInt32 i_index) const
|
|||
if ((i_index < 0) || (i_index >= Entries()))
|
||||
return 0;
|
||||
nsCacheModule* pModule = m_pFirstModule;
|
||||
for (PRInt32 i=0; i<=i_index; pModule = pModule->Next())
|
||||
i++;
|
||||
PR_ASSERT(pModule);
|
||||
for (PRInt32 i=0; i<i_index; pModule = pModule->Next())
|
||||
{
|
||||
i++;
|
||||
PR_ASSERT(pModule);
|
||||
}
|
||||
return pModule;
|
||||
}
|
||||
|
||||
nsMemModule*
|
||||
nsCacheManager::GetMemModule() const
|
||||
{
|
||||
return (nsMemModule*) m_pFirstModule;
|
||||
}
|
||||
|
||||
nsDiskModule*
|
||||
nsCacheManager::GetDiskModule() const
|
||||
{
|
||||
return (m_pFirstModule) ? (nsDiskModule*) m_pFirstModule->Next() : NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsCacheManager::Init()
|
||||
{
|
||||
|
@ -169,8 +165,10 @@ nsCacheManager::Init()
|
|||
delete m_pFirstModule;
|
||||
|
||||
m_pFirstModule = new nsMemModule(nsCachePref::MemCacheSize());
|
||||
PR_ASSERT(m_pFirstModule);
|
||||
// m_pFirstModule->Next((new nsDiskModule(nsCachePref::DiskCacheSize()));
|
||||
|
||||
m_pBkgThd = new nsCacheBkgThd(PR_SecondsToInterval(nsCachePref::BkgSleepTime()));
|
||||
PR_ASSERT(m_pBkgThd);
|
||||
}
|
||||
|
||||
nsCacheModule*
|
||||
|
|
|
@ -49,6 +49,10 @@ nsCacheModule::~nsCacheModule()
|
|||
}
|
||||
}
|
||||
|
||||
void nsCacheModule::GarbageCollect(void)
|
||||
{
|
||||
}
|
||||
|
||||
const char* nsCacheModule::Trace() const
|
||||
{
|
||||
char linebuffer[128];
|
||||
|
|
|
@ -44,7 +44,7 @@ ERROR! Must have a byte order
|
|||
#endif
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define COPY_INT32(_a,_b) memcpy(_a, _b, sizeof(int32));
|
||||
#define COPY_INT32(_a,_b) memcpy(_a, _b, sizeof(int32))
|
||||
#else
|
||||
#define COPY_INT32(_a,_b) /* swap */ \
|
||||
do { \
|
||||
|
@ -164,8 +164,8 @@ nsCacheObject::~nsCacheObject()
|
|||
|
||||
nsCacheObject::nsCacheObject(const nsCacheObject& another):
|
||||
m_Flags(another.m_Flags),
|
||||
m_Url(new char[strlen(another.m_Url)+1]),
|
||||
m_Etag(new char[strlen(another.m_Etag)+1]),
|
||||
m_Url(new char[PL_strlen(another.m_Url)+1]),
|
||||
m_Etag(new char[PL_strlen(another.m_Etag)+1]),
|
||||
m_pInfo(0)
|
||||
{
|
||||
strcpy(m_Url, another.m_Url);
|
||||
|
|
|
@ -17,24 +17,41 @@
|
|||
*/
|
||||
|
||||
#include "nsCachePref.h"
|
||||
//#include "prefapi.h"
|
||||
|
||||
static const PRUint32 MEM_CACHE_SIZE_DEFAULT = 1024*1024;
|
||||
static const PRUint32 DISK_CACHE_SIZE_DEFAULT = 5*MEM_CACHE_SIZE_DEFAULT;
|
||||
|
||||
static const PRUint32 BKG_THREAD_SLEEP = 15*60; /*in seconds, 15 minutes */
|
||||
static nsCachePref ThePrefs;
|
||||
|
||||
nsCachePref::nsCachePref(void)
|
||||
nsCachePref::nsCachePref(void):
|
||||
m_BkgSleepTime(BKG_THREAD_SLEEP),
|
||||
m_DiskCacheDBFilename(new char[6+1]),
|
||||
m_DiskCacheFolder(0),
|
||||
m_DiskCacheSize(DISK_CACHE_SIZE_DEFAULT),
|
||||
m_MemCacheSize(MEM_CACHE_SIZE_DEFAULT),
|
||||
m_RefreshFreq(ONCE)
|
||||
{
|
||||
//Read all the stuff from pref here.
|
||||
//If this changes to nsPref, here is all that needs to be changed.
|
||||
PRUint32 nTemp;
|
||||
//PREF_GetIntPref("browser.cache.memory_cache_size",&nTemp);
|
||||
//*1024
|
||||
}
|
||||
|
||||
nsCachePref::~nsCachePref()
|
||||
{
|
||||
}
|
||||
|
||||
const PRUint32
|
||||
nsCachePref::BkgSleepTime(void)
|
||||
{
|
||||
return ThePrefs.m_BkgSleepTime;
|
||||
}
|
||||
|
||||
PRUint32 nsCachePref::DiskCacheSize()
|
||||
{
|
||||
return DISK_CACHE_SIZE_DEFAULT;
|
||||
return ThePrefs.m_DiskCacheSize;
|
||||
}
|
||||
|
||||
const char* nsCachePref::DiskCacheDBFilename(void)
|
||||
|
@ -54,7 +71,12 @@ nsCachePref* nsCachePref::GetInstance()
|
|||
|
||||
PRUint32 nsCachePref::MemCacheSize()
|
||||
{
|
||||
return MEM_CACHE_SIZE_DEFAULT;
|
||||
return ThePrefs.m_MemCacheSize;
|
||||
}
|
||||
|
||||
PRBool nsCachePref::RevalidateInBkg(void)
|
||||
{
|
||||
return ThePrefs.m_bRevalidateInBkg;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <prtypes.h>
|
||||
#include <prmem.h>
|
||||
#include <plstr.h>
|
||||
#include <prlog.h>
|
||||
|
||||
#include "nsDiskModule.h"
|
||||
#include "nsCacheObject.h"
|
||||
|
@ -128,6 +129,11 @@ PRBool nsDiskModule::Contains(const char* i_url) const
|
|||
|
||||
}
|
||||
|
||||
void nsDiskModule::GarbageCollect(void)
|
||||
{
|
||||
PR_ASSERT(PR_TRUE);
|
||||
}
|
||||
|
||||
nsCacheObject* nsDiskModule::GetObject(const PRUint32 i_index) const
|
||||
{
|
||||
if (!m_pDB)
|
||||
|
@ -192,5 +198,36 @@ PRBool nsDiskModule::InitDB(void)
|
|||
if (!m_pDB)
|
||||
return PR_FALSE;
|
||||
|
||||
/* Open and read in the number of existing entries */
|
||||
m_Entries = 0;
|
||||
int status;
|
||||
DBT key, data;
|
||||
if(!(status = (*m_pDB->seq)(m_pDB, &key, &data, R_FIRST)))
|
||||
{
|
||||
while(!(status = (*m_pDB->seq) (m_pDB, &key, &data, R_NEXT)))
|
||||
{
|
||||
m_Entries++;
|
||||
}
|
||||
}
|
||||
|
||||
if (status < 0)
|
||||
return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool nsDiskModule::Remove(const char* i_url)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsDiskModule::Remove(const PRUint32 i_index)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsDiskModule::Revalidate(void)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFFEntry.h"
|
||||
#include <prmem.h>
|
||||
#include <prlog.h>
|
||||
|
||||
nsFFEntry::nsFFEntry():
|
||||
m_ID(0),
|
||||
m_pFirstObject(0),
|
||||
m_pNextEntry(0),
|
||||
m_Objects(0)
|
||||
{
|
||||
}
|
||||
|
||||
nsFFEntry::nsFFEntry(const PRUint32 i_ID):
|
||||
m_ID(i_ID),
|
||||
m_pFirstObject(0),
|
||||
m_pNextEntry(0),
|
||||
m_Objects(0)
|
||||
{
|
||||
}
|
||||
|
||||
nsFFEntry::nsFFEntry(const PRUint32 i_ID, const PRUint32 i_offset, const PRUint32 i_size):
|
||||
m_ID(i_ID),
|
||||
m_pFirstObject(new nsFFObject(i_ID, i_offset, i_size)),
|
||||
m_pNextEntry(0),
|
||||
m_Objects(1)
|
||||
{
|
||||
//PR_ASSERT(i_offset > nsFlatFile::HeaderSize());
|
||||
}
|
||||
|
||||
nsFFEntry::~nsFFEntry()
|
||||
{
|
||||
PR_FREEIF(m_pFirstObject);
|
||||
PR_FREEIF(m_pNextEntry);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
nsrefcnt nsFFEntry::AddRef(void)
|
||||
{
|
||||
return ++m_RefCnt;
|
||||
}
|
||||
nsrefcnt nsFFEntry::Release(void)
|
||||
{
|
||||
if (--m_RefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_RefCnt;
|
||||
}
|
||||
|
||||
nsresult nsFFEntry::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsFFEntry::
|
||||
*/
|
||||
|
||||
PRBool nsFFEntry::AddObject(const nsFFObject* i_object)
|
||||
{
|
||||
PR_ASSERT(i_object);
|
||||
if (!i_object)
|
||||
return PR_FALSE;
|
||||
if (!m_pFirstObject)
|
||||
{
|
||||
m_pFirstObject = (nsFFObject*) i_object;
|
||||
m_Objects++;
|
||||
}
|
||||
return m_pFirstObject->Add(i_object);
|
||||
return PR_FALSE;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFFObject.h"
|
||||
#include <prlog.h>
|
||||
|
||||
nsFFObject::nsFFObject(PRUint32 i_ID, PRUint32 i_Offset, PRUint32 i_Size):
|
||||
m_ID(i_ID),
|
||||
m_Offset(i_Offset),
|
||||
m_Size(i_Size),
|
||||
m_pNext(0)
|
||||
{
|
||||
}
|
||||
|
||||
nsFFObject::~nsFFObject()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PRBool nsFFObject::Add(const nsFFObject* i_object)
|
||||
{
|
||||
PR_ASSERT(i_object);
|
||||
if (!i_object)
|
||||
return PR_FALSE;
|
||||
if (m_pNext)
|
||||
return m_pNext->Add(i_object);
|
||||
m_pNext = (nsFFObject*) i_object;
|
||||
return PR_TRUE;
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFlatFile.h"
|
||||
#include <plstr.h>
|
||||
#include <prmem.h>
|
||||
#include <memory.h>
|
||||
|
||||
static const PRUint32 kFLAT_FILE_VERSION = 1;
|
||||
static const PRUint32 kMAGIC_NUMBER = 3739142906; // Facede de //TODO
|
||||
static const char kFILL_CHAR = 'G';
|
||||
|
||||
nsFlatFile::nsFlatFile(const char* i_pFilename, const PRUint32 i_Size):
|
||||
m_bIsValid(PR_FALSE),
|
||||
m_pFD(0),
|
||||
m_Size(i_Size),
|
||||
m_HeaderSize(2*sizeof(PRUint32)),
|
||||
m_pFilename(new char[PL_strlen(i_pFilename) + 1])
|
||||
|
||||
{
|
||||
PL_strcpy(m_pFilename, i_pFilename);
|
||||
Init();
|
||||
}
|
||||
|
||||
nsFlatFile::~nsFlatFile()
|
||||
{
|
||||
delete[] m_pFilename;
|
||||
if (m_pFD)
|
||||
{
|
||||
PR_Close(m_pFD);
|
||||
m_pFD = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void nsFlatFile::Init(void)
|
||||
{
|
||||
if (m_pFilename)
|
||||
{
|
||||
m_pFD = PR_Open(m_pFilename, PR_CREATE_FILE | PR_RDWR, 0600);
|
||||
if (!m_pFD)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PRFileInfo info;
|
||||
// if the file is just being created then write magic number
|
||||
// and flat file version, else verify
|
||||
if (PR_SUCCESS == PR_GetOpenFileInfo(m_pFD, &info))
|
||||
{
|
||||
PRInt32 status;
|
||||
if (info.size > 0)
|
||||
{
|
||||
char* buf = new char[m_HeaderSize];
|
||||
//verify
|
||||
status = PR_Read(m_pFD, buf, m_HeaderSize);
|
||||
if (status > 0)
|
||||
{
|
||||
char* cur_ptr = buf;
|
||||
PRUint32 test;
|
||||
COPY_INT32(&test, cur_ptr);
|
||||
if (test != kMAGIC_NUMBER)
|
||||
{
|
||||
PR_Close(m_pFD);
|
||||
m_pFD = 0;
|
||||
//PR_ASSERT(!"Bad flat file!");
|
||||
return;
|
||||
}
|
||||
cur_ptr += sizeof(PRUint32);
|
||||
COPY_INT32(&test, cur_ptr);
|
||||
if (test != kFLAT_FILE_VERSION)
|
||||
{
|
||||
PR_Close(m_pFD);
|
||||
m_pFD = 0;
|
||||
//PR_ASSERT(!"Bad version of flat file format!");
|
||||
return;
|
||||
}
|
||||
//Everything was as expected so
|
||||
m_bIsValid = PR_TRUE;
|
||||
}
|
||||
delete[] buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
//write out
|
||||
char* buf = new char[m_HeaderSize];
|
||||
PRUint32 test = m_HeaderSize;
|
||||
char* cur_ptr = buf;
|
||||
COPY_INT32((void*) cur_ptr, &kMAGIC_NUMBER);
|
||||
cur_ptr += sizeof(PRUint32);
|
||||
COPY_INT32((void*) cur_ptr, &kFLAT_FILE_VERSION);
|
||||
status = PR_Write(m_pFD, buf, m_HeaderSize);
|
||||
delete[] buf;
|
||||
|
||||
PRBool bFillChar = PR_FALSE;
|
||||
|
||||
if (bFillChar)
|
||||
{
|
||||
buf = new char[kPAGE_SIZE];
|
||||
for (int i = 0; i< kPAGE_SIZE; ++i)
|
||||
buf[i] = kFILL_CHAR;
|
||||
int j = (int)((m_Size - m_HeaderSize) / kPAGE_SIZE);
|
||||
int k;
|
||||
for (k = j; k > 0; --k)
|
||||
{
|
||||
status = PR_Write(m_pFD, (void*) buf, kPAGE_SIZE);
|
||||
}
|
||||
delete[] buf;
|
||||
int remaining = (m_Size-m_HeaderSize) % kPAGE_SIZE;
|
||||
for (k = remaining; k>0; --k)
|
||||
{
|
||||
status = PR_Write(m_pFD, (void*) &kFILL_CHAR, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
nsrefcnt nsFlatFile::AddRef(void)
|
||||
{
|
||||
return ++m_RefCnt;
|
||||
}
|
||||
nsrefcnt nsFlatFile::Release(void)
|
||||
{
|
||||
if (--m_RefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_RefCnt;
|
||||
}
|
||||
|
||||
nsresult nsFlatFile::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,142 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <prmem.h>
|
||||
#include "nsHash.h"
|
||||
|
||||
//
|
||||
// Key operations
|
||||
//
|
||||
|
||||
static PR_CALLBACK PLHashNumber _hashValue(const void *key)
|
||||
{
|
||||
return ((const nsHashKey *) key)->HashValue();
|
||||
}
|
||||
|
||||
static PR_CALLBACK PRIntn _hashKeyCompare(const void *key1, const void *key2) {
|
||||
return ((const nsHashKey *) key1)->Equals((const nsHashKey *) key2);
|
||||
}
|
||||
|
||||
static PR_CALLBACK PRIntn _hashValueCompare(const void *value1,
|
||||
const void *value2) {
|
||||
// We're not going to make any assumptions about value equality
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Memory callbacks
|
||||
//
|
||||
|
||||
static PR_CALLBACK void *_hashAllocTable(void *pool, PRSize size) {
|
||||
return PR_MALLOC(size);
|
||||
}
|
||||
|
||||
static PR_CALLBACK void _hashFreeTable(void *pool, void *item) {
|
||||
PR_DELETE(item);
|
||||
}
|
||||
|
||||
static PR_CALLBACK PLHashEntry *_hashAllocEntry(void *pool, const void *key) {
|
||||
return PR_NEW(PLHashEntry);
|
||||
}
|
||||
|
||||
static PR_CALLBACK void _hashFreeEntry(void *pool, PLHashEntry *entry,
|
||||
PRUintn flag) {
|
||||
if (flag == HT_FREE_ENTRY) {
|
||||
delete (nsHashKey *) (entry->key);
|
||||
PR_DELETE(entry);
|
||||
}
|
||||
}
|
||||
|
||||
static PLHashAllocOps _hashAllocOps = {
|
||||
_hashAllocTable, _hashFreeTable,
|
||||
_hashAllocEntry, _hashFreeEntry
|
||||
};
|
||||
|
||||
//
|
||||
// Enumerator callback
|
||||
//
|
||||
|
||||
static PR_CALLBACK PRIntn _hashEnumerate(PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
return ((nsHashEnumFunc) arg)((nsHashKey *) he->key, he->value) ?
|
||||
HT_ENUMERATE_NEXT :
|
||||
HT_ENUMERATE_STOP;
|
||||
}
|
||||
|
||||
//
|
||||
// HashKey
|
||||
//
|
||||
nsHashKey::nsHashKey(void)
|
||||
{
|
||||
}
|
||||
|
||||
nsHashKey::~nsHashKey(void)
|
||||
{
|
||||
}
|
||||
|
||||
nsHash::nsHash(PRUint32 aInitSize) {
|
||||
hashtable = PL_NewHashTable(aInitSize,
|
||||
_hashValue,
|
||||
_hashKeyCompare,
|
||||
_hashValueCompare,
|
||||
&_hashAllocOps,
|
||||
NULL);
|
||||
}
|
||||
|
||||
nsHash::~nsHash() {
|
||||
PL_HashTableDestroy(hashtable);
|
||||
}
|
||||
|
||||
void *nsHash::Put(nsHashKey *aKey, void *aData) {
|
||||
void *res = NULL;
|
||||
PLHashNumber hash = aKey->HashValue();
|
||||
PLHashEntry *he;
|
||||
PLHashEntry **hep = PL_HashTableRawLookup(hashtable, hash, (void *) aKey);
|
||||
|
||||
if ((he = *hep) != NULL) {
|
||||
res = he->value;
|
||||
he->value = aData;
|
||||
} else {
|
||||
PL_HashTableRawAdd(hashtable, hep, hash,
|
||||
(void *) aKey->Clone(), aData);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void *nsHash::Get(nsHashKey *aKey) {
|
||||
return PL_HashTableLookup(hashtable, (void *) aKey);
|
||||
}
|
||||
|
||||
void *nsHash::Remove(nsHashKey *aKey) {
|
||||
PLHashNumber hash = aKey->HashValue();
|
||||
PLHashEntry *he;
|
||||
PLHashEntry **hep = PL_HashTableRawLookup(hashtable, hash, (void *) aKey);
|
||||
void *res = NULL;
|
||||
|
||||
if ((he = *hep) != NULL) {
|
||||
res = he->value;
|
||||
PL_HashTableRawRemove(hashtable, hep, he);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void nsHash::Enumerate(nsHashEnumFunc aEnumFunc) {
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerate, aEnumFunc);
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <prtypes.h>
|
||||
#include <plstr.h>
|
||||
#include <prlog.h>
|
||||
|
||||
#include "nsMemModule.h"
|
||||
#include "nsMemCacheObject.h"
|
||||
|
@ -147,6 +148,35 @@ nsMemCacheObject* nsMemModule::LastObject(void) const
|
|||
return pLast;
|
||||
}
|
||||
|
||||
PRBool nsMemModule::Remove(const char* i_url)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsMemModule::Remove(const PRUint32 i_index)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void nsMemModule::GarbageCollect(void)
|
||||
{
|
||||
if (m_Entries > 0)
|
||||
{
|
||||
PRUint32 index = 0;
|
||||
while (index < m_Entries)
|
||||
{
|
||||
//TODO change the iteration
|
||||
nsCacheObject* pObj = GetObject(index);
|
||||
if (pObj->IsExpired())
|
||||
{
|
||||
PRBool status = Remove(index);
|
||||
PR_ASSERT(status == PR_TRUE);
|
||||
}
|
||||
--index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHOD nsMemModule::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsTOC.h"
|
||||
#include <plstr.h>
|
||||
#include <memory.h>
|
||||
#include <prlog.h>
|
||||
|
||||
static const PRUint32 kTOC_FLAT_FILE_VERSION = 1;
|
||||
static const PRUint32 kTOC_MAGIC_NUMBER = 19712809;
|
||||
static const PRUint32 kTOC_HEADER_SIZE = 2* sizeof(PRUint32);
|
||||
|
||||
//TODO change this to a memory mapped file!
|
||||
nsTOC::nsTOC(const char* i_pFilename, nsFlatFile* i_pFlatFile):
|
||||
m_pFilename( new char[PL_strlen(i_pFilename) + 1]),
|
||||
m_pFD(0),
|
||||
m_bIsValid(PR_FALSE),
|
||||
m_pFlatFile(i_pFlatFile),
|
||||
m_Entries(1)
|
||||
{
|
||||
PL_strcpy(m_pFilename, i_pFilename);
|
||||
Init();
|
||||
}
|
||||
|
||||
nsTOC::~nsTOC()
|
||||
{
|
||||
delete[] m_pFilename;
|
||||
if (m_pFD)
|
||||
{
|
||||
PR_Close(m_pFD);
|
||||
m_pFD = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
nsrefcnt nsTOC::AddRef(void)
|
||||
{
|
||||
return ++m_RefCnt;
|
||||
}
|
||||
nsrefcnt nsTOC::Release(void)
|
||||
{
|
||||
if (--m_RefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_RefCnt;
|
||||
}
|
||||
|
||||
nsresult nsTOC::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void nsTOC::Init(void)
|
||||
{
|
||||
if (m_pFilename)
|
||||
{
|
||||
m_pFD = PR_Open(m_pFilename, PR_CREATE_FILE | PR_RDWR, 0600);
|
||||
if (!m_pFD)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PRFileInfo info;
|
||||
// if the file is just being created then write magic number
|
||||
// and flat file version, else verify
|
||||
if (PR_SUCCESS == PR_GetOpenFileInfo(m_pFD, &info))
|
||||
{
|
||||
PRInt32 status;
|
||||
if (info.size > 0)
|
||||
{
|
||||
char buf[kTOC_HEADER_SIZE];
|
||||
//verify
|
||||
status = PR_Read(m_pFD, &buf, kTOC_HEADER_SIZE);
|
||||
if (status > 0)
|
||||
{
|
||||
char* cur_ptr = &buf[0];
|
||||
PRUint32 test;
|
||||
COPY_INT32(&test, cur_ptr);
|
||||
if (test != kTOC_MAGIC_NUMBER)
|
||||
{
|
||||
PR_Close(m_pFD);
|
||||
m_pFD = 0;
|
||||
//PR_ASSERT(!"Bad TOC file!");
|
||||
return;
|
||||
}
|
||||
cur_ptr += sizeof(PRUint32);
|
||||
COPY_INT32(&test, cur_ptr);
|
||||
if (test != kTOC_FLAT_FILE_VERSION)
|
||||
{
|
||||
PR_Close(m_pFD);
|
||||
m_pFD = 0;
|
||||
//PR_ASSERT(!"Bad version of TOC file!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Number of entries in the TOC
|
||||
status = PR_Read(m_pFD, &buf, sizeof(PRUint32));
|
||||
if (status > 0)
|
||||
{
|
||||
cur_ptr = &buf[0];
|
||||
COPY_INT32(&m_Entries, cur_ptr);
|
||||
}
|
||||
//Read in the list of entries
|
||||
nsFFEntry* pCurrent;
|
||||
Serialize(pCurrent, PR_TRUE);
|
||||
//There has got to be a free entry.
|
||||
PR_ASSERT(pCurrent /*&& pCurrent->IsValid() TODO*/);
|
||||
m_pContents = pCurrent;
|
||||
PRUint32 count = 1; //Definitely one!
|
||||
Serialize(pCurrent, PR_TRUE);
|
||||
while (pCurrent)
|
||||
{
|
||||
count++;
|
||||
m_pContents->AddEntry(pCurrent);
|
||||
Serialize(pCurrent, PR_TRUE);
|
||||
}
|
||||
|
||||
PR_ASSERT(count == m_Entries);
|
||||
|
||||
//Everything was as expected so
|
||||
m_bIsValid = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//write out
|
||||
char* buf = new char[kTOC_HEADER_SIZE];
|
||||
char* cur_ptr = buf;
|
||||
COPY_INT32((void*) cur_ptr, &kTOC_MAGIC_NUMBER);
|
||||
cur_ptr += sizeof(PRUint32);
|
||||
COPY_INT32((void*) cur_ptr, &kTOC_FLAT_FILE_VERSION);
|
||||
status = PR_Write(m_pFD, buf, kTOC_HEADER_SIZE);
|
||||
|
||||
// Number of entries in the TOC
|
||||
COPY_INT32((void*)buf, &m_Entries);
|
||||
status = PR_Write(m_pFD, buf, sizeof(PRUint32));
|
||||
|
||||
delete[] buf;
|
||||
|
||||
//Since the TOC is being created afresh, reset the flat file with everything marked as
|
||||
//free.
|
||||
m_pContents = new nsFFEntry(
|
||||
0,
|
||||
m_pFlatFile->HeaderSize(),
|
||||
m_pFlatFile->Size()-m_pFlatFile->HeaderSize());
|
||||
//Serialize the only entry-
|
||||
Serialize(m_pContents);
|
||||
|
||||
m_bIsValid = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsFFEntry* nsTOC::AddEntry(PRUint32 i_Size)
|
||||
{
|
||||
if (i_Size > FreeEntry()->Size())
|
||||
{
|
||||
//Garbage collect
|
||||
}
|
||||
nsFFEntry* pEntry = new nsFFEntry(
|
||||
NextID(),
|
||||
FreeEntry()->FirstObject()->Offset(),
|
||||
i_Size);
|
||||
|
||||
return pEntry;
|
||||
}
|
||||
|
||||
PRBool nsTOC::Serialize(nsFFEntry* io_Entry, PRBool bRead )
|
||||
{
|
||||
PR_ASSERT(m_pFD);
|
||||
if (bRead)
|
||||
{
|
||||
io_Entry = new nsFFEntry();
|
||||
if (!io_Entry)
|
||||
return PR_FALSE;
|
||||
char* buf = new char[sizeof(PRUint32)];
|
||||
PRUint32 temp, objects, size;
|
||||
//Read ID
|
||||
PR_Read(m_pFD, buf, sizeof(PRUint32));
|
||||
COPY_INT32(&temp, buf);
|
||||
io_Entry->ID(temp);
|
||||
//Read number of objects
|
||||
PR_Read(m_pFD, buf, sizeof(PRUint32));
|
||||
COPY_INT32(&objects, buf);
|
||||
//Read objects
|
||||
for (int i= objects; i>0; --i)
|
||||
{
|
||||
PR_Read(m_pFD, buf, sizeof(PRUint32));
|
||||
COPY_INT32(&temp, buf);
|
||||
PR_Read(m_pFD, buf, sizeof(PRUint32));
|
||||
COPY_INT32(&size, buf);
|
||||
io_Entry->AddObject(new nsFFObject(io_Entry->ID(), temp, size));
|
||||
}
|
||||
delete[] buf;
|
||||
PR_ASSERT(io_Entry->Objects() == objects);
|
||||
if (io_Entry->Objects() != objects)
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PR_ASSERT(io_Entry);
|
||||
if (!io_Entry)
|
||||
return PR_FALSE;
|
||||
|
||||
//TODO speed this up by increasing the buffer size to write out
|
||||
//more than one int at a time!
|
||||
|
||||
char* buf = new char[sizeof(PRUint32)];
|
||||
PRUint32 temp;
|
||||
//Write ID
|
||||
temp = io_Entry->ID();
|
||||
COPY_INT32((void*) buf, &temp);
|
||||
PR_Write(m_pFD, buf, sizeof(PRUint32));
|
||||
//Write number of Objects
|
||||
temp = io_Entry->Objects();
|
||||
COPY_INT32((void*) buf, &temp);
|
||||
PR_Write(m_pFD, buf, sizeof(PRUint32));
|
||||
//Write Objects
|
||||
if (temp > 0)
|
||||
{
|
||||
nsFFObject* current = io_Entry->FirstObject();
|
||||
while (current)
|
||||
{
|
||||
PR_ASSERT(current->ID() == io_Entry->ID());
|
||||
//Offset
|
||||
temp = current->Offset();
|
||||
COPY_INT32((void*) buf, &temp);
|
||||
PR_Write(m_pFD, buf, sizeof(PRUint32));
|
||||
//size
|
||||
temp = current->Size();
|
||||
COPY_INT32((void*) buf, &temp);
|
||||
PR_Write(m_pFD, buf, sizeof(PRUint32));
|
||||
|
||||
current = current->Next();
|
||||
}
|
||||
}
|
||||
delete[] buf;
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
|
@ -148,11 +148,12 @@ CLEAN :
|
|||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache" /I "..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /V"ERBOSE:lib" /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache" /I "..\..\..\..\..\dist\win32_d.obj\include" /I "..\..\..\..\..\dist\public\dbm" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /V"ERBOSE:lib" /c
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache"\
|
||||
/I "..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "_DEBUG" /D\
|
||||
"_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/cb.pch"\
|
||||
/Yu"stdafx.h" /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /V"ERBOSE:lib" /c
|
||||
/I "..\..\..\..\..\dist\win32_d.obj\include" /I\
|
||||
"..\..\..\..\..\dist\public\dbm" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
|
||||
"_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/cb.pch" /Yu"stdafx.h"\
|
||||
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /V"ERBOSE:lib" /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.\Debug/
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
|
@ -180,12 +181,14 @@ BSC32_SBRS= \
|
|||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 ..\..\..\..\..\dist\win32_d.obj\lib\cachelib.lib;..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 ..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib ..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib ..\..\..\..\..\dist\win32_d.obj\lib\dbm32.lib ..\..\..\..\..\dist\win32_d.obj\lib\cachelib.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
LINK32_FLAGS=\
|
||||
..\..\..\..\..\dist\win32_d.obj\lib\cachelib.lib;..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib\
|
||||
/nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)/cb.pdb" /debug\
|
||||
/machine:I386 /out:"$(OUTDIR)/cb.exe"
|
||||
LINK32_FLAGS=..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib\
|
||||
..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib\
|
||||
..\..\..\..\..\dist\win32_d.obj\lib\dbm32.lib\
|
||||
..\..\..\..\..\dist\win32_d.obj\lib\cachelib.lib /nologo /subsystem:windows\
|
||||
/incremental:yes /pdb:"$(OUTDIR)/cb.pdb" /debug /machine:I386\
|
||||
/out:"$(OUTDIR)/cb.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\CacheTreeView.obj" \
|
||||
"$(INTDIR)\cb.obj" \
|
||||
|
@ -293,9 +296,10 @@ BuildCmds= \
|
|||
|
||||
BuildCmds= \
|
||||
$(CPP) /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache"\
|
||||
/I "..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "_DEBUG" /D\
|
||||
"_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/cb.pch"\
|
||||
/Yc"stdafx.h" /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /V"ERBOSE:lib" /c $(SOURCE) \
|
||||
/I "..\..\..\..\..\dist\win32_d.obj\include" /I\
|
||||
"..\..\..\..\..\dist\public\dbm" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
|
||||
"_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/cb.pch" /Yc"stdafx.h"\
|
||||
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /V"ERBOSE:lib" /c $(SOURCE) \
|
||||
|
||||
|
||||
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
|
@ -380,24 +384,29 @@ SOURCE=.\cbView.cpp
|
|||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
DEP_CPP_CBVIE=\
|
||||
"..\..\..\..\..\dist\public\cache\nsBkgThread.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheBkgThd.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheManager.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheModule.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheObject.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCachePref.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsDiskModule.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsMemCacheObject.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsMemModule.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prthread.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
".\cb.h"\
|
||||
".\cbDoc.h"\
|
||||
".\cbView.h"\
|
||||
".\MainFrm.h"\
|
||||
".\nsTimeIt.h"\
|
||||
".\StdAfx.h"\
|
||||
|
||||
NODEP_CPP_CBVIE=\
|
||||
"..\..\..\..\..\dist\public\cache\nsISupports.h"\
|
||||
"..\..\..\..\..\dist\public\cache\mcom_db.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
|
@ -408,24 +417,35 @@ NODEP_CPP_CBVIE=\
|
|||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
DEP_CPP_CBVIE=\
|
||||
"..\..\..\..\..\dist\public\cache\nsBkgThread.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheBkgThd.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheManager.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheModule.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheObject.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCachePref.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsDiskModule.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsMemCacheObject.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsMemModule.h"\
|
||||
"..\..\..\..\..\dist\public\dbm\cdefs.h"\
|
||||
"..\..\..\..\..\dist\public\dbm\mcom_db.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prthread.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
".\cb.h"\
|
||||
".\cbDoc.h"\
|
||||
".\cbView.h"\
|
||||
".\MainFrm.h"\
|
||||
".\nsTimeIt.h"\
|
||||
".\StdAfx.h"\
|
||||
{$(INCLUDE)}"\sys\STAT.H"\
|
||||
{$(INCLUDE)}"\sys\TYPES.H"\
|
||||
|
||||
NODEP_CPP_CBVIE=\
|
||||
"..\..\..\..\..\dist\public\cache\nsISupports.h"\
|
||||
"..\..\..\..\..\dist\public\dbm\prmacos.h"\
|
||||
"..\..\..\..\..\dist\public\dbm\xp_mcom.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
|
|
Двоичный файл не отображается.
|
@ -14,6 +14,7 @@
|
|||
#include "nsDiskModule.h"
|
||||
#include "nsCacheObject.h"
|
||||
#include "nsTimeIt.h"
|
||||
#include "nsCacheBkgThd.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
|
@ -28,12 +29,12 @@ static char THIS_FILE[] = __FILE__;
|
|||
IMPLEMENT_DYNCREATE(CCbView, CView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCbView, CView)
|
||||
//{{AFX_MSG_MAP(CCbView)
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard printing commands
|
||||
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
|
||||
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
|
||||
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
|
||||
//{{AFX_MSG_MAP(CCbView)
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard printing commands
|
||||
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
|
||||
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
|
||||
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -57,14 +58,14 @@ BOOL CCbView::PreCreateWindow(CREATESTRUCT& cs)
|
|||
|
||||
void CCbView::OnDraw(CDC* pDC)
|
||||
{
|
||||
CRect rect;
|
||||
GetClientRect(&rect);
|
||||
|
||||
CRect rect;
|
||||
GetClientRect(&rect);
|
||||
|
||||
pDC->SetBkColor(RGB(192,192,192));
|
||||
pDC->FillSolidRect(rect, RGB(192,192,192));
|
||||
|
||||
pDC->FillSolidRect(rect, RGB(192,192,192));
|
||||
|
||||
rect.DeflateRect(10,10);
|
||||
pDC->DrawText(m_Mesg.GetBuffer(m_Mesg.GetLength()), -1, rect, DT_WORDBREAK | DT_EXPANDTABS);
|
||||
pDC->DrawText(m_Mesg.GetBuffer(m_Mesg.GetLength()), -1, rect, DT_WORDBREAK | DT_EXPANDTABS);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -72,8 +73,8 @@ void CCbView::OnDraw(CDC* pDC)
|
|||
|
||||
BOOL CCbView::OnPreparePrinting(CPrintInfo* pInfo)
|
||||
{
|
||||
// default preparation
|
||||
return DoPreparePrinting(pInfo);
|
||||
// default preparation
|
||||
return DoPreparePrinting(pInfo);
|
||||
}
|
||||
|
||||
void CCbView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
||||
|
@ -110,59 +111,68 @@ CCbDoc* CCbView::GetDocument() // non-debug version is inline
|
|||
|
||||
void CCbView::OnInitialUpdate()
|
||||
{
|
||||
STATUS("Loading lib...");
|
||||
//STATUS("Loading lib...");
|
||||
|
||||
nsCacheManager* pCM = nsCacheManager::GetInstance();
|
||||
nsMemModule* pMM = new nsMemModule();
|
||||
pCM->AddModule(pMM);
|
||||
nsCacheManager* pCM = nsCacheManager::GetInstance();
|
||||
nsMemModule* pMM = pCM->GetMemModule();
|
||||
nsDiskModule* pDM = new nsDiskModule();
|
||||
pCM->AddModule(pDM);
|
||||
|
||||
nsCacheObject* pCO = new nsCacheObject("http://www.netscape.com/");
|
||||
pCO->Etag("Etag-testing");
|
||||
pCO->Size(2250);
|
||||
pCO->LastModified(time(0));
|
||||
pDM->AddObject(pCO);
|
||||
|
||||
nsCacheObject* pCO = new nsCacheObject("http://www.netscape.com/");
|
||||
pCO->Etag("Etag-testing");
|
||||
pCO->Size(2250);
|
||||
pCO->LastModified(time(0));
|
||||
pMM->AddObject(pCO);
|
||||
|
||||
int j = 10000;
|
||||
// if (!pDM->Contains("http://www.netscape.com/"))
|
||||
// pDM->AddObject(pCO);
|
||||
// else
|
||||
{
|
||||
nsCacheObject* pTemp = new nsCacheObject("http://www.netscape.com/");
|
||||
if (pDM->Contains(pTemp))
|
||||
{
|
||||
m_Mesg += pTemp->Trace();
|
||||
}
|
||||
}
|
||||
int j = 1000;
|
||||
char tmpBuff[10];
|
||||
while (j--)
|
||||
{
|
||||
pCO = new nsCacheObject(itoa(j,tmpBuff,10));
|
||||
pMM->AddObject(pCO);
|
||||
VERIFY(pDM->AddObject(pCO));
|
||||
}
|
||||
m_Mesg += itoa(pMM->Entries(), tmpBuff, 10);
|
||||
m_Mesg += " nsCacheObject(s) added.\n";
|
||||
|
||||
char* traceBuff = (char*) pCM->Trace();
|
||||
m_Mesg += "-----------------\n";
|
||||
m_Mesg += traceBuff;
|
||||
m_Mesg += itoa(pDM->Entries(), tmpBuff, 10);
|
||||
m_Mesg += " nsCacheObject(s) added.\n";
|
||||
|
||||
char* traceBuff =(char*) pCM->Trace();
|
||||
m_Mesg += "-----------------\n";
|
||||
m_Mesg += traceBuff;
|
||||
delete[] traceBuff;
|
||||
traceBuff = (char*) pMM->Trace();
|
||||
m_Mesg += traceBuff;
|
||||
delete[] traceBuff;
|
||||
|
||||
m_Mesg += "-----------------\n";
|
||||
m_Mesg += "-----------------\n";
|
||||
|
||||
|
||||
char buffer[10];
|
||||
m_Mesg += "Worst case time= ";
|
||||
m_Mesg += itoa(pCM->WorstCaseTime(), buffer, 10);
|
||||
m_Mesg += itoa(pCM->WorstCaseTime(), buffer, 10);
|
||||
m_Mesg += " microsec.\n";
|
||||
|
||||
PRUint32 t;
|
||||
{
|
||||
nsTimeIt tmp(t);
|
||||
if (pMM->Contains("999"))
|
||||
if (pCM->Contains("999"))
|
||||
m_Mesg += "!";
|
||||
}
|
||||
m_Mesg += "-----------------\n";
|
||||
m_Mesg += "Found in ";
|
||||
m_Mesg += "An item found in ";
|
||||
m_Mesg += itoa(t, buffer, 10);
|
||||
m_Mesg += " microsec.\n";
|
||||
|
||||
// delete pMM;
|
||||
// pMM = 0;
|
||||
|
||||
CView::OnInitialUpdate();
|
||||
CView::OnInitialUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <prtypes.h>
|
||||
#include <prio.h>
|
||||
#include <plstr.h>
|
||||
#include "nsFlatFile.h"
|
||||
#include "nsTOC.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
PRFileDesc* pfd = PR_GetSpecialFD(PR_StandardOutput);
|
||||
|
||||
nsFlatFile tf("CACHE.DAT");
|
||||
nsTOC toc("Cache.TOC", &tf);
|
||||
|
||||
if (tf.IsValid() && toc.IsValid())
|
||||
{
|
||||
PR_Write(pfd, tf.Filename(), PL_strlen(tf.Filename()));
|
||||
PR_Write(pfd, " ", 2);
|
||||
PR_Write(pfd, toc.Filename(), PL_strlen(toc.Filename()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,329 @@
|
|||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=fftest - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to fftest - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "fftest - Win32 Release" && "$(CFG)" != "fftest - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "fftest.mak" CFG="fftest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "fftest - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "fftest - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "fftest - Win32 Debug"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "fftest - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\fftest.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\FlatFileTest.obj"
|
||||
-@erase "$(INTDIR)\nsFFEntry.obj"
|
||||
-@erase "$(INTDIR)\nsFFObject.obj"
|
||||
-@erase "$(INTDIR)\nsFlatFile.obj"
|
||||
-@erase "$(INTDIR)\nsTOC.obj"
|
||||
-@erase "$(OUTDIR)\fftest.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /W4 /GX /O2 /I "..\..\..\..\..\dist\win32_d.obj\include" /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
CPP_PROJ=/nologo /ML /W4 /GX /O2 /I "..\..\..\..\..\dist\win32_d.obj\include"\
|
||||
/I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
|
||||
/Fp"$(INTDIR)/fftest.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/fftest.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 ..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib ..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib /nologo /subsystem:console /machine:I386
|
||||
LINK32_FLAGS=..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib\
|
||||
..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib /nologo /subsystem:console\
|
||||
/incremental:no /pdb:"$(OUTDIR)/fftest.pdb" /machine:I386\
|
||||
/out:"$(OUTDIR)/fftest.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\FlatFileTest.obj" \
|
||||
"$(INTDIR)\nsFFEntry.obj" \
|
||||
"$(INTDIR)\nsFFObject.obj" \
|
||||
"$(INTDIR)\nsFlatFile.obj" \
|
||||
"$(INTDIR)\nsTOC.obj"
|
||||
|
||||
"$(OUTDIR)\fftest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "fftest - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
|
||||
ALL : "$(OUTDIR)\fftest.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\FlatFileTest.obj"
|
||||
-@erase "$(INTDIR)\nsFFEntry.obj"
|
||||
-@erase "$(INTDIR)\nsFFObject.obj"
|
||||
-@erase "$(INTDIR)\nsFlatFile.obj"
|
||||
-@erase "$(INTDIR)\nsTOC.obj"
|
||||
-@erase "$(INTDIR)\vc40.idb"
|
||||
-@erase "$(INTDIR)\vc40.pdb"
|
||||
-@erase "$(OUTDIR)\fftest.exe"
|
||||
-@erase "$(OUTDIR)\fftest.ilk"
|
||||
-@erase "$(OUTDIR)\fftest.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /W4 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\win32_d.obj\include" /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
|
||||
CPP_PROJ=/nologo /MLd /W4 /Gm /GX /Zi /Od /I\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include" /I "..\..\include" /D "WIN32" /D\
|
||||
"_DEBUG" /D "_CONSOLE" /Fp"$(INTDIR)/fftest.pch" /YX /Fo"$(INTDIR)/"\
|
||||
/Fd"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.\.
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/fftest.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
# ADD LINK32 ..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib ..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib /nologo /subsystem:console /debug /machine:I386
|
||||
LINK32_FLAGS=..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib\
|
||||
..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib /nologo /subsystem:console\
|
||||
/incremental:yes /pdb:"$(OUTDIR)/fftest.pdb" /debug /machine:I386\
|
||||
/out:"$(OUTDIR)/fftest.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\FlatFileTest.obj" \
|
||||
"$(INTDIR)\nsFFEntry.obj" \
|
||||
"$(INTDIR)\nsFFObject.obj" \
|
||||
"$(INTDIR)\nsFlatFile.obj" \
|
||||
"$(INTDIR)\nsTOC.obj"
|
||||
|
||||
"$(OUTDIR)\fftest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "fftest - Win32 Release"
|
||||
# Name "fftest - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "fftest - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "fftest - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FlatFileTest.cpp
|
||||
DEP_CPP_FLATF=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\plstr.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinet.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prio.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prlong.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtime.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
"..\..\include\nsFFEntry.h"\
|
||||
"..\..\include\nsFFObject.h"\
|
||||
"..\..\include\nsFlatFile.h"\
|
||||
"..\..\include\nsTOC.h"\
|
||||
{$(INCLUDE)}"\sys\types.h"\
|
||||
|
||||
NODEP_CPP_FLATF=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\macsocket.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\FlatFileTest.obj" : $(SOURCE) $(DEP_CPP_FLATF) "$(INTDIR)"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\work\mozilla\network\cache\nu\src\nsFlatFile.cpp
|
||||
DEP_CPP_NSFLA=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\plstr.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinet.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prio.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prlong.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prmem.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtime.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
"..\..\include\nsFlatFile.h"\
|
||||
{$(INCLUDE)}"\sys\types.h"\
|
||||
|
||||
NODEP_CPP_NSFLA=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\macsocket.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\nsFlatFile.obj" : $(SOURCE) $(DEP_CPP_NSFLA) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\work\mozilla\network\cache\nu\src\nsFFObject.cpp
|
||||
DEP_CPP_NSFFO=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
"..\..\include\nsFFObject.h"\
|
||||
|
||||
NODEP_CPP_NSFFO=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\nsFFObject.obj" : $(SOURCE) $(DEP_CPP_NSFFO) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\work\mozilla\network\cache\nu\src\nsTOC.cpp
|
||||
DEP_CPP_NSTOC=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\plstr.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinet.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prio.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prlog.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prlong.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtime.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
"..\..\include\nsFFEntry.h"\
|
||||
"..\..\include\nsFFObject.h"\
|
||||
"..\..\include\nsFlatFile.h"\
|
||||
"..\..\include\nsTOC.h"\
|
||||
{$(INCLUDE)}"\sys\types.h"\
|
||||
|
||||
NODEP_CPP_NSTOC=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\macsocket.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\nsTOC.obj" : $(SOURCE) $(DEP_CPP_NSTOC) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\work\mozilla\network\cache\nu\src\nsFFEntry.cpp
|
||||
DEP_CPP_NSFFE=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prlog.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prmem.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
"..\..\include\nsFFEntry.h"\
|
||||
"..\..\include\nsFFObject.h"\
|
||||
|
||||
NODEP_CPP_NSFFE=\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\nsFFEntry.obj" : $(SOURCE) $(DEP_CPP_NSFFE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче