зеркало из https://github.com/mozilla/pjs.git
Bug 715770 - Remove necko buffer cache. r=biesi.
This commit is contained in:
Родитель
b1eb1c80e0
Коммит
d336e56185
|
@ -63,7 +63,6 @@
|
|||
#include "nsIProxyInfo.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIRecyclingAllocator.h"
|
||||
#include "nsISocketTransport.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsSimpleNestedURI.h"
|
||||
|
@ -86,6 +85,9 @@
|
|||
#define AUTODIAL_PREF "network.autodial-helper.enabled"
|
||||
#define MANAGE_OFFLINE_STATUS_PREF "network.manage-offline-status"
|
||||
|
||||
// Nb: these have been misnomers since bug 715770 removed the buffer cache.
|
||||
// "network.segment.count" and "network.segment.size" would be better names,
|
||||
// but the old names are still used to preserve backward compatibility.
|
||||
#define NECKO_BUFFER_CACHE_COUNT_PREF "network.buffer.cache.count"
|
||||
#define NECKO_BUFFER_CACHE_SIZE_PREF "network.buffer.cache.size"
|
||||
|
||||
|
@ -166,8 +168,7 @@ static const char kProfileChangeNetTeardownTopic[] = "profile-change-net-teardow
|
|||
static const char kProfileChangeNetRestoreTopic[] = "profile-change-net-restore";
|
||||
static const char kProfileDoChange[] = "profile-do-change";
|
||||
|
||||
// Necko buffer cache
|
||||
nsIMemory* nsIOService::gBufferCache = nsnull;
|
||||
// Necko buffer defaults
|
||||
PRUint32 nsIOService::gDefaultSegmentSize = 4096;
|
||||
PRUint32 nsIOService::gDefaultSegmentCount = 24;
|
||||
|
||||
|
@ -245,24 +246,6 @@ nsIOService::Init()
|
|||
|
||||
NS_TIME_FUNCTION_MARK("Registered observers");
|
||||
|
||||
// Get the allocator ready
|
||||
if (!gBufferCache) {
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRecyclingAllocator> recyclingAllocator =
|
||||
do_CreateInstance(NS_RECYCLINGALLOCATOR_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = recyclingAllocator->Init(gDefaultSegmentCount,
|
||||
(15 * 60), // 15 minutes
|
||||
"necko");
|
||||
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Was unable to allocate. No gBufferCache.");
|
||||
CallQueryInterface(recyclingAllocator, &gBufferCache);
|
||||
}
|
||||
|
||||
NS_TIME_FUNCTION_MARK("Set up the recycling allocator");
|
||||
|
||||
gIOService = this;
|
||||
|
||||
InitializeNetworkLinkService();
|
||||
|
@ -924,7 +907,7 @@ nsIOService::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
|||
*/
|
||||
if (size > 0 && size < 1024*1024)
|
||||
gDefaultSegmentSize = size;
|
||||
NS_WARN_IF_FALSE( (!(size & (size - 1))) , "network buffer cache size is not a power of 2!");
|
||||
NS_WARN_IF_FALSE( (!(size & (size - 1))) , "network segment size is not a power of 2!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,9 +165,7 @@ private:
|
|||
|
||||
bool mAutoDialEnabled;
|
||||
public:
|
||||
// Necko buffer cache. Used for all default buffer sizes that necko
|
||||
// allocates.
|
||||
static nsIMemory *gBufferCache;
|
||||
// Used for all default buffer sizes that necko allocates.
|
||||
static PRUint32 gDefaultSegmentSize;
|
||||
static PRUint32 gDefaultSegmentCount;
|
||||
};
|
||||
|
|
|
@ -40,18 +40,6 @@
|
|||
|
||||
#include "nsIOService.h"
|
||||
|
||||
/**
|
||||
* returns preferred allocator for given segment size. NULL implies
|
||||
* system allocator. this result can be used when allocating a pipe.
|
||||
*/
|
||||
|
||||
static inline nsIMemory *
|
||||
net_GetSegmentAlloc(PRUint32 segsize)
|
||||
{
|
||||
return (segsize == nsIOService::gDefaultSegmentSize)
|
||||
? nsIOService::gBufferCache : nsnull;
|
||||
}
|
||||
|
||||
/**
|
||||
* applies defaults to segment params in a consistent way.
|
||||
*/
|
||||
|
|
|
@ -1725,12 +1725,11 @@ nsSocketTransport::OpenInputStream(PRUint32 flags,
|
|||
bool openBlocking = (flags & OPEN_BLOCKING);
|
||||
|
||||
net_ResolveSegmentParams(segsize, segcount);
|
||||
nsIMemory *segalloc = net_GetSegmentAlloc(segsize);
|
||||
|
||||
// create a pipe
|
||||
nsCOMPtr<nsIAsyncOutputStream> pipeOut;
|
||||
rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(pipeOut),
|
||||
!openBlocking, true, segsize, segcount, segalloc);
|
||||
!openBlocking, true, segsize, segcount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// async copy from socket to pipe
|
||||
|
@ -1772,12 +1771,11 @@ nsSocketTransport::OpenOutputStream(PRUint32 flags,
|
|||
bool openBlocking = (flags & OPEN_BLOCKING);
|
||||
|
||||
net_ResolveSegmentParams(segsize, segcount);
|
||||
nsIMemory *segalloc = net_GetSegmentAlloc(segsize);
|
||||
|
||||
// create a pipe
|
||||
nsCOMPtr<nsIAsyncInputStream> pipeIn;
|
||||
rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(pipeOut),
|
||||
true, !openBlocking, segsize, segcount, segalloc);
|
||||
true, !openBlocking, segsize, segcount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// async copy from socket to pipe
|
||||
|
|
|
@ -129,13 +129,12 @@ nsInputStreamTransport::OpenInputStream(PRUint32 flags,
|
|||
bool nonblocking = !(flags & OPEN_BLOCKING);
|
||||
|
||||
net_ResolveSegmentParams(segsize, segcount);
|
||||
nsIMemory *segalloc = net_GetSegmentAlloc(segsize);
|
||||
|
||||
nsCOMPtr<nsIAsyncOutputStream> pipeOut;
|
||||
rv = NS_NewPipe2(getter_AddRefs(mPipeIn),
|
||||
getter_AddRefs(pipeOut),
|
||||
nonblocking, true,
|
||||
segsize, segcount, segalloc);
|
||||
segsize, segcount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mInProgress = true;
|
||||
|
@ -340,13 +339,12 @@ nsOutputStreamTransport::OpenOutputStream(PRUint32 flags,
|
|||
bool nonblocking = !(flags & OPEN_BLOCKING);
|
||||
|
||||
net_ResolveSegmentParams(segsize, segcount);
|
||||
nsIMemory *segalloc = net_GetSegmentAlloc(segsize);
|
||||
|
||||
nsCOMPtr<nsIAsyncInputStream> pipeIn;
|
||||
rv = NS_NewPipe2(getter_AddRefs(pipeIn),
|
||||
getter_AddRefs(mPipeOut),
|
||||
true, nonblocking,
|
||||
segsize, segcount, segalloc);
|
||||
segsize, segcount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mInProgress = true;
|
||||
|
|
|
@ -655,9 +655,6 @@ static void nsNetShutdown()
|
|||
// Release the url parser that the stdurl is holding.
|
||||
nsStandardURL::ShutdownGlobalObjects();
|
||||
|
||||
// Release buffer cache
|
||||
NS_IF_RELEASE(nsIOService::gBufferCache);
|
||||
|
||||
// Release global state used by the URL helper module.
|
||||
net_ShutdownURLHelper();
|
||||
#ifdef XP_MACOSX
|
||||
|
|
|
@ -726,8 +726,7 @@ nsHttpPipeline::FillSendBuf()
|
|||
getter_AddRefs(mSendBufOut),
|
||||
nsIOService::gDefaultSegmentSize, /* segment size */
|
||||
nsIOService::gDefaultSegmentSize, /* max size */
|
||||
true, true,
|
||||
nsIOService::gBufferCache);
|
||||
true, true);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -297,8 +297,7 @@ nsHttpTransaction::Init(PRUint8 caps,
|
|||
getter_AddRefs(mPipeOut),
|
||||
true, true,
|
||||
nsIOService::gDefaultSegmentSize,
|
||||
nsIOService::gDefaultSegmentCount,
|
||||
nsIOService::gBufferCache);
|
||||
nsIOService::gDefaultSegmentCount);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ADDREF(*responseBody = mPipeIn);
|
||||
|
|
Загрузка…
Ссылка в новой задаче