зеркало из https://github.com/mozilla/gecko-dev.git
Mac changes for NuCache (approved gagan and not part of Mozilla/Gromit builds yet)
This commit is contained in:
Родитель
89bf330387
Коммит
9ff0a65088
Двоичный файл не отображается.
|
@ -15,7 +15,13 @@
|
||||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||||
* Reserved.
|
* Reserved.
|
||||||
*/
|
*/
|
||||||
#include <memory.h>
|
|
||||||
|
#ifndef XP_MAC
|
||||||
|
#include "memory.h"
|
||||||
|
#else
|
||||||
|
#include "cstring"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "prmem.h"
|
#include "prmem.h"
|
||||||
#include "prprf.h"
|
#include "prprf.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
#include "nsCacheManager.h"
|
#include "nsCacheManager.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
#include "uprefd.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const PRUint32 MEM_CACHE_SIZE_DEFAULT = 1024*1024;
|
static const PRUint32 MEM_CACHE_SIZE_DEFAULT = 1024*1024;
|
||||||
static const PRUint32 DISK_CACHE_SIZE_DEFAULT = 5*MEM_CACHE_SIZE_DEFAULT;
|
static const PRUint32 DISK_CACHE_SIZE_DEFAULT = 5*MEM_CACHE_SIZE_DEFAULT;
|
||||||
static const PRUint32 BKG_THREAD_SLEEP = 60;//TODO- Testing 15*60; /*in seconds, 15 minutes */
|
static const PRUint32 BKG_THREAD_SLEEP = 60;//TODO- Testing 15*60; /*in seconds, 15 minutes */
|
||||||
|
@ -105,7 +110,36 @@ nsCachePref::SetupPrefs(const char* i_Pref)
|
||||||
|
|
||||||
if (bSetupAll || !PL_strcmp(i_Pref,CACHE_DIR_PREF))
|
if (bSetupAll || !PL_strcmp(i_Pref,CACHE_DIR_PREF))
|
||||||
{
|
{
|
||||||
if (PREF_OK == PREF_CopyCharPref(CACHE_DIR_PREF,&tempPref))
|
#ifdef XP_MAC
|
||||||
|
tempPref = CPrefs::GetCachePath();
|
||||||
|
if (tempPref)
|
||||||
|
{
|
||||||
|
if (m_DiskCacheFolder)
|
||||||
|
delete m_DiskCacheFolder;
|
||||||
|
m_DiskCacheFolder = new char[PL_strlen(tempPref)+2];
|
||||||
|
|
||||||
|
if (!m_DiskCacheFolder)
|
||||||
|
{
|
||||||
|
if (tempPref)
|
||||||
|
PR_Free(tempPref);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* Changing the mac path to unix because nspr converts
|
||||||
|
it the other way round and cant deal with it being a mac path */
|
||||||
|
m_DiskCacheFolder[0]='/';
|
||||||
|
m_DiskCacheFolder[1]='\0';
|
||||||
|
PL_strcat(m_DiskCacheFolder, tempPref);
|
||||||
|
char *tempPref2 = m_DiskCacheFolder+1;
|
||||||
|
while (*tempPref2)
|
||||||
|
{
|
||||||
|
if (*tempPref2 == ':')
|
||||||
|
*tempPref2 = '/';
|
||||||
|
tempPref2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (PREF_OK == PREF_CopyCharPref(CACHE_DIR_PREF,&tempPref))
|
||||||
{
|
{
|
||||||
PR_ASSERT(tempPref);
|
PR_ASSERT(tempPref);
|
||||||
if (m_DiskCacheFolder)
|
if (m_DiskCacheFolder)
|
||||||
|
@ -119,6 +153,7 @@ nsCachePref::SetupPrefs(const char* i_Pref)
|
||||||
}
|
}
|
||||||
PL_strcpy(m_DiskCacheFolder, tempPref);
|
PL_strcpy(m_DiskCacheFolder, tempPref);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else //TODO set to temp folder
|
else //TODO set to temp folder
|
||||||
{
|
{
|
||||||
m_DiskCacheFolder = new char [1];
|
m_DiskCacheFolder = new char [1];
|
||||||
|
@ -172,3 +207,4 @@ nsresult nsCachePref::QueryInterface(const nsIID& aIID,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,8 @@ PRBool nsDiskModule::AddObject(nsCacheObject* io_pObject)
|
||||||
|
|
||||||
//Close the corresponding file
|
//Close the corresponding file
|
||||||
PR_ASSERT(io_pObject->Stream());
|
PR_ASSERT(io_pObject->Stream());
|
||||||
PR_Close(((nsFileStream*)io_pObject->Stream())->FileDesc());
|
if (io_pObject->Stream())
|
||||||
|
PR_Close(((nsFileStream*)io_pObject->Stream())->FileDesc());
|
||||||
|
|
||||||
key->data = (void*)io_pObject->Address();
|
key->data = (void*)io_pObject->Address();
|
||||||
/* Later on change this to include post data- io_pObject->KeyData() */
|
/* Later on change this to include post data- io_pObject->KeyData() */
|
||||||
|
@ -514,8 +515,10 @@ char* FullFilename(const char* i_Filename)
|
||||||
PL_strcpy(g_FullFilename, nsCachePref::GetInstance()->DiskCacheFolder());
|
PL_strcpy(g_FullFilename, nsCachePref::GetInstance()->DiskCacheFolder());
|
||||||
if (0==cacheFolderLength)
|
if (0==cacheFolderLength)
|
||||||
cacheFolderLength = PL_strlen(nsCachePref::GetInstance()->DiskCacheFolder());
|
cacheFolderLength = PL_strlen(nsCachePref::GetInstance()->DiskCacheFolder());
|
||||||
|
#ifndef XP_MAC
|
||||||
g_FullFilename[cacheFolderLength] = PR_GetDirectorySepartor(); //spelling check later as nspr fixes it.
|
g_FullFilename[cacheFolderLength] = PR_GetDirectorySepartor(); //spelling check later as nspr fixes it.
|
||||||
g_FullFilename[cacheFolderLength+1] = '\0';
|
g_FullFilename[cacheFolderLength+1] = '\0';
|
||||||
|
#endif
|
||||||
PL_strcat(g_FullFilename, i_Filename);
|
PL_strcat(g_FullFilename, i_Filename);
|
||||||
return g_FullFilename;
|
return g_FullFilename;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ PRInt32 nsFileStream::Read(void* o_Buffer, PRUint32 i_Len)
|
||||||
|
|
||||||
void nsFileStream::Reset()
|
void nsFileStream::Reset()
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
if (m_pFile)
|
if (m_pFile)
|
||||||
PR_Close(m_pFile);
|
PR_Close(m_pFile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,12 @@
|
||||||
#include "nsMemStream.h"
|
#include "nsMemStream.h"
|
||||||
#include "prmem.h"
|
#include "prmem.h"
|
||||||
#include "prlog.h" /* Assert */
|
#include "prlog.h" /* Assert */
|
||||||
|
|
||||||
|
#ifndef XP_MAC
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#else
|
||||||
|
#include "cstring"
|
||||||
|
#endif
|
||||||
|
|
||||||
static const PRUint32 kPageSize = 1024;//4096;
|
static const PRUint32 kPageSize = 1024;//4096;
|
||||||
nsMemStream::nsMemStream():m_AllocSize(0),m_Size(0),m_pStart(0),m_ReadOffset(0),m_WriteOffset(0)
|
nsMemStream::nsMemStream():m_AllocSize(0),m_Size(0),m_pStart(0),m_ReadOffset(0),m_WriteOffset(0)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче