diff --git a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp index 44c8a500be8..f4cb868e604 100644 --- a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp +++ b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp @@ -99,13 +99,13 @@ static const char kObserverServiceContractID[] = "@mozilla.org/observer-service; /** * Buffer sizes for serialization and deserialization of scripts. - * These should be tuned at some point. + * FIXME: bug #411579 (tune this macro!) Last updated: Jan 2008 */ #define XPC_SERIALIZATION_BUFFER_SIZE (64 * 1024) -#define XPC_DESERIALIZATION_BUFFER_SIZE (8 * 1024) +#define XPC_DESERIALIZATION_BUFFER_SIZE (12 * 8192) // Inactivity delay before closing our fastload file stream. -static const int kFastLoadWriteDelay = 5000; // 5 seconds +static const int kFastLoadWriteDelay = 10000; // 10 seconds #ifdef PR_LOGGING // NSPR_LOG_MODULES=JSComponentLoader:5 diff --git a/mozilla/modules/libpref/src/nsPrefService.cpp b/mozilla/modules/libpref/src/nsPrefService.cpp index fee1de3c45c..27ad9cddf32 100644 --- a/mozilla/modules/libpref/src/nsPrefService.cpp +++ b/mozilla/modules/libpref/src/nsPrefService.cpp @@ -50,6 +50,7 @@ #include "nsCRT.h" #include "nsCOMArray.h" #include "nsXPCOMCID.h" +#include "nsAutoPtr.h" #include "nsQuickSort.h" #include "prmem.h" @@ -68,7 +69,6 @@ // Definitions #define INITIAL_PREF_FILES 10 -#define PREF_READ_BUFFER_SIZE 4096 // Prototypes #ifdef MOZ_PROFILESHARING @@ -586,7 +586,6 @@ static PRBool isSharingEnabled() static nsresult openPrefFile(nsIFile* aFile) { nsCOMPtr inStr; - char readBuf[PREF_READ_BUFFER_SIZE]; #if MOZ_TIMELINE { @@ -600,21 +599,33 @@ static nsresult openPrefFile(nsIFile* aFile) if (NS_FAILED(rv)) return rv; + PRInt64 fileSize; + rv = aFile->GetFileSize(&fileSize); + if (NS_FAILED(rv)) + return rv; + + nsAutoArrayPtr fileBuffer(new char[fileSize]); + if (fileBuffer == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + PrefParseState ps; PREF_InitParseState(&ps, PREF_ReaderCallback, NULL); + + // Read is not guaranteed to return a buf the size of fileSize, + // but usually will. nsresult rv2 = NS_OK; for (;;) { PRUint32 amtRead = 0; - rv = inStr->Read(readBuf, sizeof(readBuf), &amtRead); + rv = inStr->Read((char*)fileBuffer, fileSize, &amtRead); if (NS_FAILED(rv) || amtRead == 0) break; - - if (!PREF_ParseBuf(&ps, readBuf, amtRead)) { + if (!PREF_ParseBuf(&ps, fileBuffer, amtRead)) rv2 = NS_ERROR_FILE_CORRUPTED; - } } + PREF_FinalizeParseState(&ps); - return NS_FAILED(rv) ? rv : rv2; + + return NS_FAILED(rv) ? rv : rv2; } /* diff --git a/mozilla/xpcom/io/nsFastLoadFile.cpp b/mozilla/xpcom/io/nsFastLoadFile.cpp index 323b198ebad..1c62e8f301c 100644 --- a/mozilla/xpcom/io/nsFastLoadFile.cpp +++ b/mozilla/xpcom/io/nsFastLoadFile.cpp @@ -630,9 +630,9 @@ nsFastLoadFileReader::SetInputStream(nsIInputStream *aInputStream) } /** - * XXX tuneme + * FIXME: bug #411579 (tune this macro!) Last updated: Jan 2008 */ -#define MFL_CHECKSUM_BUFSIZE 8192 +#define MFL_CHECKSUM_BUFSIZE (6 * 8192) NS_IMETHODIMP nsFastLoadFileReader::ComputeChecksum(PRUint32 *aResult)