mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 12:13:22 +00:00
Bug 715770 - Remove necko buffer cache. r=biesi.
This commit is contained in:
parent
e7c93a9ba8
commit
ac4987ad67
@ -63,7 +63,6 @@
|
|||||||
#include "nsIProxyInfo.h"
|
#include "nsIProxyInfo.h"
|
||||||
#include "nsEscape.h"
|
#include "nsEscape.h"
|
||||||
#include "nsNetCID.h"
|
#include "nsNetCID.h"
|
||||||
#include "nsIRecyclingAllocator.h"
|
|
||||||
#include "nsISocketTransport.h"
|
#include "nsISocketTransport.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsSimpleNestedURI.h"
|
#include "nsSimpleNestedURI.h"
|
||||||
@ -86,6 +85,9 @@
|
|||||||
#define AUTODIAL_PREF "network.autodial-helper.enabled"
|
#define AUTODIAL_PREF "network.autodial-helper.enabled"
|
||||||
#define MANAGE_OFFLINE_STATUS_PREF "network.manage-offline-status"
|
#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_COUNT_PREF "network.buffer.cache.count"
|
||||||
#define NECKO_BUFFER_CACHE_SIZE_PREF "network.buffer.cache.size"
|
#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 kProfileChangeNetRestoreTopic[] = "profile-change-net-restore";
|
||||||
static const char kProfileDoChange[] = "profile-do-change";
|
static const char kProfileDoChange[] = "profile-do-change";
|
||||||
|
|
||||||
// Necko buffer cache
|
// Necko buffer defaults
|
||||||
nsIMemory* nsIOService::gBufferCache = nsnull;
|
|
||||||
PRUint32 nsIOService::gDefaultSegmentSize = 4096;
|
PRUint32 nsIOService::gDefaultSegmentSize = 4096;
|
||||||
PRUint32 nsIOService::gDefaultSegmentCount = 24;
|
PRUint32 nsIOService::gDefaultSegmentCount = 24;
|
||||||
|
|
||||||
@ -245,24 +246,6 @@ nsIOService::Init()
|
|||||||
|
|
||||||
NS_TIME_FUNCTION_MARK("Registered observers");
|
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;
|
gIOService = this;
|
||||||
|
|
||||||
InitializeNetworkLinkService();
|
InitializeNetworkLinkService();
|
||||||
@ -924,7 +907,7 @@ nsIOService::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
|||||||
*/
|
*/
|
||||||
if (size > 0 && size < 1024*1024)
|
if (size > 0 && size < 1024*1024)
|
||||||
gDefaultSegmentSize = size;
|
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;
|
bool mAutoDialEnabled;
|
||||||
public:
|
public:
|
||||||
// Necko buffer cache. Used for all default buffer sizes that necko
|
// Used for all default buffer sizes that necko allocates.
|
||||||
// allocates.
|
|
||||||
static nsIMemory *gBufferCache;
|
|
||||||
static PRUint32 gDefaultSegmentSize;
|
static PRUint32 gDefaultSegmentSize;
|
||||||
static PRUint32 gDefaultSegmentCount;
|
static PRUint32 gDefaultSegmentCount;
|
||||||
};
|
};
|
||||||
|
@ -40,18 +40,6 @@
|
|||||||
|
|
||||||
#include "nsIOService.h"
|
#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.
|
* applies defaults to segment params in a consistent way.
|
||||||
*/
|
*/
|
||||||
|
@ -1725,12 +1725,11 @@ nsSocketTransport::OpenInputStream(PRUint32 flags,
|
|||||||
bool openBlocking = (flags & OPEN_BLOCKING);
|
bool openBlocking = (flags & OPEN_BLOCKING);
|
||||||
|
|
||||||
net_ResolveSegmentParams(segsize, segcount);
|
net_ResolveSegmentParams(segsize, segcount);
|
||||||
nsIMemory *segalloc = net_GetSegmentAlloc(segsize);
|
|
||||||
|
|
||||||
// create a pipe
|
// create a pipe
|
||||||
nsCOMPtr<nsIAsyncOutputStream> pipeOut;
|
nsCOMPtr<nsIAsyncOutputStream> pipeOut;
|
||||||
rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(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;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// async copy from socket to pipe
|
// async copy from socket to pipe
|
||||||
@ -1772,12 +1771,11 @@ nsSocketTransport::OpenOutputStream(PRUint32 flags,
|
|||||||
bool openBlocking = (flags & OPEN_BLOCKING);
|
bool openBlocking = (flags & OPEN_BLOCKING);
|
||||||
|
|
||||||
net_ResolveSegmentParams(segsize, segcount);
|
net_ResolveSegmentParams(segsize, segcount);
|
||||||
nsIMemory *segalloc = net_GetSegmentAlloc(segsize);
|
|
||||||
|
|
||||||
// create a pipe
|
// create a pipe
|
||||||
nsCOMPtr<nsIAsyncInputStream> pipeIn;
|
nsCOMPtr<nsIAsyncInputStream> pipeIn;
|
||||||
rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(pipeOut),
|
rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(pipeOut),
|
||||||
true, !openBlocking, segsize, segcount, segalloc);
|
true, !openBlocking, segsize, segcount);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// async copy from socket to pipe
|
// async copy from socket to pipe
|
||||||
|
@ -129,13 +129,12 @@ nsInputStreamTransport::OpenInputStream(PRUint32 flags,
|
|||||||
bool nonblocking = !(flags & OPEN_BLOCKING);
|
bool nonblocking = !(flags & OPEN_BLOCKING);
|
||||||
|
|
||||||
net_ResolveSegmentParams(segsize, segcount);
|
net_ResolveSegmentParams(segsize, segcount);
|
||||||
nsIMemory *segalloc = net_GetSegmentAlloc(segsize);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIAsyncOutputStream> pipeOut;
|
nsCOMPtr<nsIAsyncOutputStream> pipeOut;
|
||||||
rv = NS_NewPipe2(getter_AddRefs(mPipeIn),
|
rv = NS_NewPipe2(getter_AddRefs(mPipeIn),
|
||||||
getter_AddRefs(pipeOut),
|
getter_AddRefs(pipeOut),
|
||||||
nonblocking, true,
|
nonblocking, true,
|
||||||
segsize, segcount, segalloc);
|
segsize, segcount);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
mInProgress = true;
|
mInProgress = true;
|
||||||
@ -340,13 +339,12 @@ nsOutputStreamTransport::OpenOutputStream(PRUint32 flags,
|
|||||||
bool nonblocking = !(flags & OPEN_BLOCKING);
|
bool nonblocking = !(flags & OPEN_BLOCKING);
|
||||||
|
|
||||||
net_ResolveSegmentParams(segsize, segcount);
|
net_ResolveSegmentParams(segsize, segcount);
|
||||||
nsIMemory *segalloc = net_GetSegmentAlloc(segsize);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIAsyncInputStream> pipeIn;
|
nsCOMPtr<nsIAsyncInputStream> pipeIn;
|
||||||
rv = NS_NewPipe2(getter_AddRefs(pipeIn),
|
rv = NS_NewPipe2(getter_AddRefs(pipeIn),
|
||||||
getter_AddRefs(mPipeOut),
|
getter_AddRefs(mPipeOut),
|
||||||
true, nonblocking,
|
true, nonblocking,
|
||||||
segsize, segcount, segalloc);
|
segsize, segcount);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
mInProgress = true;
|
mInProgress = true;
|
||||||
|
@ -655,9 +655,6 @@ static void nsNetShutdown()
|
|||||||
// Release the url parser that the stdurl is holding.
|
// Release the url parser that the stdurl is holding.
|
||||||
nsStandardURL::ShutdownGlobalObjects();
|
nsStandardURL::ShutdownGlobalObjects();
|
||||||
|
|
||||||
// Release buffer cache
|
|
||||||
NS_IF_RELEASE(nsIOService::gBufferCache);
|
|
||||||
|
|
||||||
// Release global state used by the URL helper module.
|
// Release global state used by the URL helper module.
|
||||||
net_ShutdownURLHelper();
|
net_ShutdownURLHelper();
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
|
@ -726,8 +726,7 @@ nsHttpPipeline::FillSendBuf()
|
|||||||
getter_AddRefs(mSendBufOut),
|
getter_AddRefs(mSendBufOut),
|
||||||
nsIOService::gDefaultSegmentSize, /* segment size */
|
nsIOService::gDefaultSegmentSize, /* segment size */
|
||||||
nsIOService::gDefaultSegmentSize, /* max size */
|
nsIOService::gDefaultSegmentSize, /* max size */
|
||||||
true, true,
|
true, true);
|
||||||
nsIOService::gBufferCache);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +297,7 @@ nsHttpTransaction::Init(PRUint8 caps,
|
|||||||
getter_AddRefs(mPipeOut),
|
getter_AddRefs(mPipeOut),
|
||||||
true, true,
|
true, true,
|
||||||
nsIOService::gDefaultSegmentSize,
|
nsIOService::gDefaultSegmentSize,
|
||||||
nsIOService::gDefaultSegmentCount,
|
nsIOService::gDefaultSegmentCount);
|
||||||
nsIOService::gBufferCache);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
NS_ADDREF(*responseBody = mPipeIn);
|
NS_ADDREF(*responseBody = mPipeIn);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user