Added buffer size parameters to NewChannel. Allows for optimization of amount of image data consumed. Bug #20408

This commit is contained in:
warren%netscape.com 1999-12-04 10:01:32 +00:00
Родитель 41f815d11d
Коммит 6af4802e75
82 изменённых файлов: 485 добавлений и 153 удалений

Просмотреть файл

@ -336,6 +336,8 @@ nsChromeProtocolHandler::NewChannel(const char* aVerb, nsIURI* aURI,
nsIInterfaceRequestor* aNotificationCallbacks,
nsLoadFlags aLoadAttributes,
nsIURI* aOriginalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *aResult)
{
nsresult rv;
@ -378,6 +380,7 @@ nsChromeProtocolHandler::NewChannel(const char* aVerb, nsIURI* aURI,
aNotificationCallbacks,
aLoadAttributes,
aOriginalURI ? aOriginalURI : aURI,
bufferSegmentSize, bufferMaxSize,
getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -196,6 +196,8 @@ nsJSProtocolHandler::NewChannel(const char* verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
NS_ENSURE_ARG_POINTER(uri);
@ -342,7 +344,8 @@ nsJSProtocolHandler::NewChannel(const char* verb,
rv = NS_NewInputStreamChannel(uri, "text/html", length,
in, aLoadGroup,
notificationCallbacks, loadAttributes,
originalURI, &channel);
originalURI, bufferSegmentSize,
bufferMaxSize, &channel);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -237,7 +237,8 @@ NS_NewURItoFile(const char *in, nsFileSpec dirSpec, const char *out)
// Async reading thru the calls of the event sink interface
rv = serv->NewChannelFromURI("load", pURL, nsnull, nsnull,
nsIChannel::LOAD_NORMAL, nsnull, getter_AddRefs(pChannel));
nsIChannel::LOAD_NORMAL, nsnull, 0, 0,
getter_AddRefs(pChannel));
if (NS_FAILED(rv)) {
printf("ERROR: NewChannelFromURI failed for %s\n", in);
return rv;

Просмотреть файл

@ -197,7 +197,8 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL,
// XXX NECKO what verb? what event sink getter
nsIChannel *channel = nsnull;
rv = service->NewChannelFromURI("load", uri, nsnull, nsnull,
nsIChannel::LOAD_NORMAL, nsnull, &channel);
nsIChannel::LOAD_NORMAL, nsnull, 0, 0,
&channel);
NS_RELEASE(uri);
if (NS_FAILED(rv))
return -1;

Просмотреть файл

@ -483,6 +483,7 @@ nsMessenger::OpenAttachment(const char * url, const char * displayName,
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(aListener->m_channel));
if (NS_FAILED(rv))
{
@ -616,6 +617,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity)
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(aListener->m_channel));
if (NS_FAILED(rv))
{

Просмотреть файл

@ -68,7 +68,8 @@ nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL) // open a connection on
aURL->GetPort(&port);
aURL->GetHost(getter_Copies(hostName));
rv = socketService->CreateTransport(hostName, port, nsnull, getter_AddRefs(m_channel));
rv = socketService->CreateTransport(hostName, port, nsnull, 0, 0,
getter_AddRefs(m_channel));
if (NS_SUCCEEDED(rv) && m_channel)
{
m_socketIsOpen = PR_FALSE;
@ -102,6 +103,7 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSp
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(m_channel));
PR_FREEIF(urlSpec);

Просмотреть файл

@ -201,6 +201,7 @@ nsresult rv;
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(dummyChannel));
if (NS_FAILED(mimeParser->AsyncConvertData(nsnull, nsnull, nsnull, dummyChannel)))
{

Просмотреть файл

@ -193,6 +193,7 @@ nsMsgQuote::QuoteMessage(const PRUnichar *msgURI, PRBool quoteHeaders, nsIStream
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(mQuoteChannel));
if (NS_FAILED(rv)) return rv;
@ -219,6 +220,7 @@ nsMsgQuote::QuoteMessage(const PRUnichar *msgURI, PRBool quoteHeaders, nsIStream
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(aChannel));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(aURL);

Просмотреть файл

@ -390,6 +390,8 @@ NS_IMETHODIMP nsSmtpService::NewChannel(const char *verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **_retval)
{
nsresult rv = NS_OK;

Просмотреть файл

@ -209,6 +209,7 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -199,6 +199,7 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -600,7 +600,7 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
aURL->GetHost(getter_Copies(hostName));
ClearFlag(IMAP_CONNECTION_IS_OPEN);
rv = socketService->CreateTransport(hostName, port, nsnull, getter_AddRefs(m_channel));
rv = socketService->CreateTransport(hostName, port, nsnull, 0, 0, getter_AddRefs(m_channel));
if (NS_SUCCEEDED(rv))
rv = m_channel->OpenOutputStream(0 /* start position */, getter_AddRefs(m_outputStream));

Просмотреть файл

@ -460,7 +460,7 @@ nsImapService::FetchMessage(nsIImapUrl * aImapUrl,
mailnewsUrl->GetLoadGroup(getter_AddRefs(aLoadGroup));
rv = NewChannel(nsnull, url, aLoadGroup, nsnull, nsIChannel::LOAD_NORMAL,
nsnull, getter_AddRefs(aChannel));
nsnull, 0, 0, getter_AddRefs(aChannel));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(url);
@ -2236,6 +2236,8 @@ NS_IMETHODIMP nsImapService::NewChannel(const char *verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **_retval)
{
// imap can't open and return a channel right away...the url needs to go in the imap url queue

Просмотреть файл

@ -302,6 +302,8 @@ NS_IMETHODIMP nsMailboxService::NewChannel(const char *verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **_retval)
{
nsresult rv = NS_OK;

Просмотреть файл

@ -265,6 +265,8 @@ NS_IMETHODIMP nsPop3Service::NewChannel(const char *verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **_retval)
{
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us

Просмотреть файл

@ -429,6 +429,7 @@ NS_IMETHODIMP nsStreamConverter::Init(nsIURI *aURI, nsIStreamListener * aOutList
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(mOutgoingChannel));
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -945,6 +945,8 @@ NS_IMETHODIMP nsNntpService::NewChannel(const char *verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **_retval)
{
nsresult rv = NS_OK;

Просмотреть файл

@ -58,6 +58,12 @@ public:
nsCOMPtr<nsIFileChannel> jarCacheFile;
rv = serv->NewChannelFromNativePath(mJarCacheFile.GetNativePathCString(),
mJARChannel->mLoadGroup,
mJARChannel->mCallbacks,
mJARChannel->mLoadAttributes,
nsnull,
mJARChannel->mBufferSegmentSize,
mJARChannel->mBufferMaxSize,
getter_AddRefs(jarCacheFile));
if (NS_FAILED(rv)) return rv;
@ -137,7 +143,9 @@ nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI)
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
nsresult rv;
mURI = do_QueryInterface(uri, &rv);
@ -146,6 +154,8 @@ nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
if (mCommand == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
mOriginalURI = originalURI;
mBufferSegmentSize = bufferSegmentSize;
mBufferMaxSize = bufferMaxSize;
rv = SetLoadAttributes(loadAttributes);
if (NS_FAILED(rv)) return rv;
@ -267,6 +277,7 @@ nsJARChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
// on some other thread)
nsCOMPtr<nsIChannel> jarCacheTransport;
rv = fts->CreateTransport(jarCacheFile, mCommand,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(jarCacheTransport));
if (NS_FAILED(rv)) return rv;
@ -323,6 +334,7 @@ nsJARChannel::ExtractJARElement(nsIFileChannel* jarBaseFile)
nsCOMPtr<nsIChannel> jarTransport;
rv = fts->CreateTransportFromFileSystem(this, mCommand,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(jarTransport));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -73,11 +73,15 @@ public:
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI);
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
nsresult ExtractJARElement(nsIFileChannel* jarFileChannel);
nsresult GetCacheFile(nsFileSpec& cacheFile);
friend class nsJARDownloadObserver;
protected:
char* mCommand;
nsCOMPtr<nsIJARURI> mURI;
@ -98,6 +102,8 @@ protected:
nsCOMPtr<nsIFileChannel> mJARBaseFile;
char* mJAREntry;
nsCOMPtr<nsIZipReader> mJAR;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#endif // nsJARChannel_h__

Просмотреть файл

@ -122,6 +122,8 @@ nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
nsresult rv;
@ -131,7 +133,7 @@ nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
if (NS_FAILED(rv)) return rv;
rv = channel->Init(this, verb, uri, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI);
loadAttributes, originalURI, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

Просмотреть файл

@ -180,7 +180,9 @@ interface nsIInputStreamChannel : nsIChannel
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI);
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
};
%{C++

Просмотреть файл

@ -36,17 +36,23 @@ native nsFileSpec(nsFileSpec&);
interface nsIFileTransportService : nsISupports
{
[noscript] nsIChannel createTransport(in nsFileSpec spec, // XXX change to nsIFile later
in string command);
in string command,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
// This version can be used with an existing input stream to serve
// as a data pump:
nsIChannel createTransportFromStream(in nsIInputStream fromStream,
in string contentType,
in long contentLength,
in string command);
in string command,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
nsIChannel createTransportFromFileSystem(in nsIFileSystem fsObj,
in string command);
in string command,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
void dispatchRequest(in nsIRunnable runnable);
void suspend(in nsIRunnable trans);

Просмотреть файл

@ -69,7 +69,9 @@ interface nsIIOService : nsISupports
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI);
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
/**
* Convenience routine that first creates a URI by calling NewURI, and
@ -81,7 +83,9 @@ interface nsIIOService : nsISupports
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI);
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
/**
* Get the application name string that will be used as part
@ -121,7 +125,13 @@ interface nsIIOService : nsISupports
* This convenience routine first looks up the file protocol handler, and
* then uses it to construct a file channel from a native path string.
*/
nsIFileChannel newChannelFromNativePath(in string nativePath);
nsIFileChannel newChannelFromNativePath(in string nativePath,
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
/**
* Utility for protocol implementors -- extracts the scheme from a URL

Просмотреть файл

@ -57,7 +57,9 @@ interface nsIProtocolHandler : nsISupports
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI);
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
};
%{C++

Просмотреть файл

@ -38,11 +38,15 @@ interface nsISocketTransportService : nsISupports
*/
nsIChannel createTransport(in string host,
in long port,
in string printHost);
in string printHost,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
nsIChannel createTransportOfType(in string socketType,
in string host,
in long port,
in string printHost);
in string host,
in long port,
in string printHost,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
/**
* Returns true if the specified transport is good enough for

Просмотреть файл

@ -45,7 +45,9 @@ interface nsIUnicharStreamLoader : nsISupports
in nsIUnicharStreamLoaderObserver completionObserver,
in nsILoadGroup loadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes);
in nsLoadFlags loadAttributes,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
/**
* Gets the number of bytes read so far.

Просмотреть файл

@ -68,7 +68,9 @@ NS_NewURI(nsIURI* *result, const nsString& spec, nsIURI* baseURI = nsnull)
inline nsresult
NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup *aGroup,
nsIInterfaceRequestor *capabilities = nsnull,
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL)
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL,
PRUint32 bufferSegmentSize = 0,
PRUint32 bufferMaxSize = 0)
{
nsresult rv;
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
@ -77,7 +79,8 @@ NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup *aGroup,
nsIChannel* channel;
rv = serv->NewChannelFromURI("load", uri, aGroup, capabilities,
loadAttributes, nsnull, &channel);
loadAttributes, nsnull,
bufferSegmentSize, bufferMaxSize, &channel);
if (NS_FAILED(rv)) return rv;
*result = channel;
@ -185,6 +188,8 @@ NS_NewInputStreamChannel(nsIURI* uri,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **result)
{
nsresult rv;
@ -196,7 +201,8 @@ NS_NewInputStreamChannel(nsIURI* uri,
getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
rv = channel->Init(uri, contentType, contentLength, inStr, group,
notificationCallbacks, loadAttributes, originalURI);
notificationCallbacks, loadAttributes, originalURI,
bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) return rv;
*result = channel;
@ -229,7 +235,9 @@ NS_NewUnicharStreamLoader(nsIUnicharStreamLoader* *result,
nsIUnicharStreamLoaderObserver* observer,
nsILoadGroup* loadGroup = nsnull,
nsIInterfaceRequestor* notificationCallbacks = nsnull,
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL)
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL,
PRUint32 bufferSegmentSize = 0,
PRUint32 bufferMaxSize = 0)
{
nsresult rv;
nsCOMPtr<nsIUnicharStreamLoader> loader;
@ -239,7 +247,8 @@ NS_NewUnicharStreamLoader(nsIUnicharStreamLoader* *result,
NS_GET_IID(nsIUnicharStreamLoader),
getter_AddRefs(loader));
if (NS_FAILED(rv)) return rv;
rv = loader->Init(uri, observer, loadGroup, notificationCallbacks, loadAttributes);
rv = loader->Init(uri, observer, loadGroup, notificationCallbacks, loadAttributes,
bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) return rv;
*result = loader;
NS_ADDREF(*result);

Просмотреть файл

@ -295,31 +295,33 @@ nsFileTransport::nsFileTransport()
}
nsresult
nsFileTransport::Init(nsFileSpec& spec, const char* command)
nsFileTransport::Init(nsFileSpec& spec, const char* command,
PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize)
{
nsresult rv;
mSpec = spec;
nsCOMPtr<nsIFileSystem> fsObj;
rv = nsLocalFileSystem::Create(spec, getter_AddRefs(fsObj));
if (NS_FAILED(rv)) return rv;
return Init(fsObj, command);
return Init(fsObj, command, bufferSegmentSize, bufferMaxSize);
}
nsresult
nsFileTransport::Init(nsIInputStream* fromStream, const char* contentType,
PRInt32 contentLength, const char* command)
PRInt32 contentLength, const char* command,
PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize)
{
nsresult rv;
nsCOMPtr<nsIFileSystem> fsObj;
rv = nsInputStreamFileSystem::Create(fromStream, contentType, contentLength,
getter_AddRefs(fsObj));
if (NS_FAILED(rv)) return rv;
return Init(fsObj, command);
return Init(fsObj, command, bufferSegmentSize, bufferMaxSize);
}
nsresult
nsFileTransport::Init(nsIFileSystem* fsObj,
const char* command)
nsFileTransport::Init(nsIFileSystem* fsObj, const char* command,
PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize)
{
nsresult rv = NS_OK;
if (mMonitor == nsnull) {
@ -328,6 +330,10 @@ nsFileTransport::Init(nsIFileSystem* fsObj,
return NS_ERROR_OUT_OF_MEMORY;
}
mFileObject = fsObj;
mBufferSegmentSize = bufferSegmentSize != 0
? bufferSegmentSize : NS_FILE_TRANSPORT_DEFAULT_SEGMENT_SIZE;
mBufferMaxSize = bufferMaxSize != 0
? bufferMaxSize : NS_FILE_TRANSPORT_DEFAULT_BUFFER_SIZE;
return rv;
}
@ -480,8 +486,7 @@ nsFileTransport::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
rv = NS_NewPipe(getter_AddRefs(mBufferInputStream),
getter_AddRefs(mBufferOutputStream),
this, // nsIPipeObserver
NS_FILE_TRANSPORT_SEGMENT_SIZE,
NS_FILE_TRANSPORT_BUFFER_SIZE);
mBufferSegmentSize, mBufferMaxSize);
if (NS_FAILED(rv)) return rv;
rv = mBufferOutputStream->SetNonBlocking(PR_TRUE);
@ -595,8 +600,7 @@ nsFileTransport::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
rv = NS_NewPipe(getter_AddRefs(mBufferInputStream),
getter_AddRefs(mBufferOutputStream),
this, // nsIPipeObserver
NS_FILE_TRANSPORT_SEGMENT_SIZE,
NS_FILE_TRANSPORT_BUFFER_SIZE);
mBufferSegmentSize, mBufferMaxSize);
if (NS_FAILED(rv)) return rv;
rv = mBufferInputStream->SetNonBlocking(PR_TRUE);
@ -889,7 +893,7 @@ nsFileTransport::Process(void)
// transfer
mStatus = NS_OK;
mBuffer = new char[NS_FILE_TRANSPORT_SEGMENT_SIZE];
mBuffer = new char[mBufferSegmentSize];
if (mBuffer == nsnull) {
mStatus = NS_ERROR_OUT_OF_MEMORY;
mState = END_WRITE;
@ -910,9 +914,9 @@ nsFileTransport::Process(void)
}
case WRITING: {
PRUint32 transferAmt = NS_FILE_TRANSPORT_SEGMENT_SIZE;
PRUint32 transferAmt = mBufferSegmentSize;
if (mTransferAmount >= 0)
transferAmt = PR_MIN(NS_FILE_TRANSPORT_SEGMENT_SIZE, mTransferAmount);
transferAmt = PR_MIN(mBufferSegmentSize, (PRUint32)mTransferAmount);
PRUint32 writeAmt;
if (mBufferInputStream) {
mStatus = mBufferInputStream->ReadSegments(nsWriteToFile, mSink,

Просмотреть файл

@ -60,13 +60,19 @@ public:
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
nsresult Init(nsFileSpec& spec,
const char* command);
const char* command,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
nsresult Init(nsIInputStream* fromStream,
const char* contentType,
PRInt32 contentLength,
const char* command);
const char* command,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
nsresult Init(nsIFileSystem* fsObj,
const char* command);
const char* command,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
void Process(void);
@ -95,6 +101,8 @@ protected:
nsFileSpec mSpec; // eliminate?
nsCOMPtr<nsIFileSystem> mFileObject;
char* mContentType;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
nsCOMPtr<nsIStreamObserver> mOpenObserver;
nsCOMPtr<nsISupports> mOpenContext;
@ -123,7 +131,7 @@ protected:
char* mBuffer;
};
#define NS_FILE_TRANSPORT_SEGMENT_SIZE (2*1024)
#define NS_FILE_TRANSPORT_BUFFER_SIZE (8*1024)
#define NS_FILE_TRANSPORT_DEFAULT_SEGMENT_SIZE (2*1024)
#define NS_FILE_TRANSPORT_DEFAULT_BUFFER_SIZE (8*1024)
#endif // nsFileTransport_h__

Просмотреть файл

@ -83,6 +83,8 @@ nsFileTransportService::Create(nsISupports *aOuter, REFNSIID aIID, void **aResul
NS_IMETHODIMP
nsFileTransportService::CreateTransport(nsFileSpec& spec,
const char* command,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** result)
{
nsresult rv;
@ -90,7 +92,7 @@ nsFileTransportService::CreateTransport(nsFileSpec& spec,
if (trans == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(trans);
rv = trans->Init(spec, command);
rv = trans->Init(spec, command, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
NS_RELEASE(trans);
return rv;
@ -104,6 +106,8 @@ nsFileTransportService::CreateTransportFromStream(nsIInputStream *fromStream,
const char* contentType,
PRInt32 contentLength,
const char *command,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** result)
{
nsresult rv;
@ -111,7 +115,8 @@ nsFileTransportService::CreateTransportFromStream(nsIInputStream *fromStream,
if (trans == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(trans);
rv = trans->Init(fromStream, contentType, contentLength, command);
rv = trans->Init(fromStream, contentType, contentLength, command,
bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
NS_RELEASE(trans);
return rv;
@ -123,6 +128,8 @@ nsFileTransportService::CreateTransportFromStream(nsIInputStream *fromStream,
NS_IMETHODIMP
nsFileTransportService::CreateTransportFromFileSystem(nsIFileSystem *fsObj,
const char *command,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **result)
{
nsresult rv;
@ -130,7 +137,7 @@ nsFileTransportService::CreateTransportFromFileSystem(nsIFileSystem *fsObj,
if (trans == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(trans);
rv = trans->Init(fsObj, command);
rv = trans->Init(fsObj, command, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
NS_RELEASE(trans);
return rv;

Просмотреть файл

@ -231,6 +231,8 @@ nsIOService::NewChannelFromURI(const char* verb, nsIURI *aURI,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **result)
{
nsresult rv;
@ -244,7 +246,8 @@ nsIOService::NewChannelFromURI(const char* verb, nsIURI *aURI,
if (NS_FAILED(rv)) return rv;
rv = handler->NewChannel(verb, aURI, aGroup, notificationCallbacks,
loadAttributes, originalURI, result);
loadAttributes, originalURI,
bufferSegmentSize, bufferMaxSize, result);
return rv;
}
@ -255,6 +258,8 @@ nsIOService::NewChannel(const char* verb, const char *aSpec,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **result)
{
nsresult rv;
@ -264,7 +269,8 @@ nsIOService::NewChannel(const char* verb, const char *aSpec,
if (NS_FAILED(rv)) return rv;
rv = handler->NewChannel(verb, uri, aGroup, notificationCallbacks,
loadAttributes, originalURI, result);
loadAttributes, originalURI,
bufferSegmentSize, bufferMaxSize, result);
return rv;
}
@ -337,7 +343,14 @@ nsIOService::GetUserAgent(PRUnichar* *aUserAgent)
////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsIOService::NewChannelFromNativePath(const char *nativePath, nsIFileChannel **result)
nsIOService::NewChannelFromNativePath(const char *nativePath,
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIFileChannel **result)
{
nsresult rv;
nsCOMPtr<nsIProtocolHandler> handler;
@ -348,11 +361,18 @@ nsIOService::NewChannelFromNativePath(const char *nativePath, nsIFileChannel **r
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIFileChannel> channel;
rv = fileHandler->NewChannelFromNativePath(nativePath, getter_AddRefs(channel));
rv = fileHandler->NewChannelFromNativePath(nativePath,
aLoadGroup,
notificationCallbacks,
loadAttributes,
originalURI,
bufferSegmentSize,
bufferMaxSize,
getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
*result = channel;
NS_ADDREF(*result);
NS_ADDREF(*result);
return NS_OK;
}

Просмотреть файл

@ -67,12 +67,16 @@ nsInputStreamChannel::Init(nsIURI* uri,
nsILoadGroup *aGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI)
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
nsresult rv;
mOriginalURI = originalURI ? originalURI : uri;
mURI = uri;
mContentLength = contentLength;
mBufferSegmentSize = bufferSegmentSize;
mBufferMaxSize = bufferMaxSize;
rv = SetLoadAttributes(loadAttributes);
if (NS_FAILED(rv)) return rv;
@ -171,7 +175,8 @@ nsInputStreamChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransportFromStream(mInputStream, mContentType, mContentLength,
"load", getter_AddRefs(mFileTransport));
"load", mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) return rv;
return mFileTransport->AsyncOpen(observer, ctxt);
@ -227,7 +232,8 @@ nsInputStreamChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransportFromStream(mInputStream, mContentType, mContentLength,
"load", getter_AddRefs(mFileTransport));
"load", mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) return rv;
}

Просмотреть файл

@ -60,6 +60,8 @@ protected:
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsIChannel> mFileTransport;
nsCOMPtr<nsIStreamListener> mRealListener;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#endif // nsInputStreamChannel_h__

Просмотреть файл

@ -230,10 +230,17 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
const char* aHost,
PRInt32 aPort,
const char* aSocketType,
const char* aPrintHost)
const char* aPrintHost,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
nsresult rv = NS_OK;
mBufferSegmentSize = bufferSegmentSize != 0
? bufferSegmentSize : NS_SOCKET_TRANSPORT_SEGMENT_SIZE;
mBufferMaxSize = bufferMaxSize != 0
? bufferMaxSize : NS_SOCKET_TRANSPORT_BUFFER_SIZE;
mService = aService;
NS_ADDREF(mService);
@ -1568,8 +1575,7 @@ nsSocketTransport::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
rv = NS_NewPipe(getter_AddRefs(mReadPipeIn),
getter_AddRefs(mReadPipeOut),
this, // nsIPipeObserver
NS_SOCKET_TRANSPORT_SEGMENT_SIZE,
NS_SOCKET_TRANSPORT_BUFFER_SIZE);
mBufferSegmentSize, mBufferMaxSize);
if (NS_SUCCEEDED(rv)) {
rv = mReadPipeIn->SetNonBlocking(PR_TRUE);
}
@ -1683,8 +1689,7 @@ nsSocketTransport::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
rv = NS_NewPipe(getter_AddRefs(mReadPipeIn),
getter_AddRefs(mReadPipeOut),
this, // nsIPipeObserver
NS_SOCKET_TRANSPORT_SEGMENT_SIZE,
NS_SOCKET_TRANSPORT_BUFFER_SIZE);
mBufferSegmentSize, mBufferMaxSize);
if (NS_SUCCEEDED(rv)) {
rv = mReadPipeOut->SetNonBlocking(PR_TRUE);
*result = mReadPipeIn;
@ -1742,8 +1747,7 @@ nsSocketTransport::OpenOutputStream(PRUint32 startPosition, nsIOutputStream* *re
// XXXbe calling out of module with a lock held...
rv = NS_NewPipe(getter_AddRefs(in), getter_AddRefs(out),
this, // nsIPipeObserver
NS_SOCKET_TRANSPORT_SEGMENT_SIZE,
NS_SOCKET_TRANSPORT_BUFFER_SIZE);
mBufferSegmentSize, mBufferMaxSize);
if (NS_SUCCEEDED(rv)) {
rv = in->SetNonBlocking(PR_TRUE);
}

Просмотреть файл

@ -129,7 +129,9 @@ public:
const char* aHost,
PRInt32 aPort,
const char* aSocketType,
const char* aPrintHost); // This host is used for status mesg
const char* aPrintHost, // This host is used for status mesg
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
nsresult Process(PRInt16 aSelectFlags);
@ -226,7 +228,8 @@ protected:
nsCOMPtr<nsIStreamObserver> mWriteObserver;
nsCOMPtr<nsIBufferInputStream> mWritePipeIn;
nsCOMPtr<nsIBufferOutputStream> mWritePipeOut;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};

Просмотреть файл

@ -525,18 +525,23 @@ nsSocketTransportService::Run(void)
NS_IMETHODIMP
nsSocketTransportService::CreateTransport(const char* aHost,
PRInt32 aPort,
const char* aPrintHost,
const char* aPrintHost,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** aResult)
{
return CreateTransportOfType(nsnull, aHost, aPort, aPrintHost, aResult);
return CreateTransportOfType(nsnull, aHost, aPort, aPrintHost,
bufferSegmentSize, bufferMaxSize, aResult);
}
NS_IMETHODIMP
nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
const char* aHost,
PRInt32 aPort,
const char* aPrintHost,
nsIChannel** aResult)
const char* aHost,
PRInt32 aPort,
const char* aPrintHost,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** aResult)
{
nsresult rv = NS_OK;
nsSocketTransport* transport = nsnull;
@ -550,7 +555,8 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
// Create and initialize a new connection object...
NS_NEWXPCOM(transport, nsSocketTransport);
if (transport) {
rv = transport->Init(this, aHost, aPort, aSocketType, aPrintHost);
rv = transport->Init(this, aHost, aPort, aSocketType, aPrintHost,
bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
delete transport;
transport = nsnull;

Просмотреть файл

@ -44,7 +44,9 @@ nsUnicharStreamLoader::Init(nsIURI* aURL,
nsIUnicharStreamLoaderObserver* observer,
nsILoadGroup* aGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes)
nsLoadFlags loadAttributes,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
nsresult rv = NS_OK;
mObserver = observer;
@ -59,7 +61,8 @@ nsUnicharStreamLoader::Init(nsIURI* aURL,
nsIChannel* channel;
rv = serv->NewChannelFromURI("load", aURL, aGroup, notificationCallbacks,
loadAttributes, nsnull, &channel);
loadAttributes, nsnull,
bufferSegmentSize, bufferMaxSize, &channel);
if (NS_FAILED(rv)) return rv;
rv = channel->AsyncRead(0, -1, nsnull, this);

Просмотреть файл

@ -31,12 +31,14 @@ interface nsIEventQueue;
[scriptable, uuid(692303c0-2f83-11d3-8cd0-0060b0fc14a3)]
interface nsIAboutModule : nsISupports
{
nsIChannel NewChannel(in string verb,
nsIChannel newChannel(in string verb,
in nsIURI aURI,
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI);
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
};
%{C++

Просмотреть файл

@ -39,6 +39,8 @@ nsAboutBlank::NewChannel(const char *verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **result)
{
nsresult rv;
@ -55,7 +57,8 @@ nsAboutBlank::NewChannel(const char *verb,
rv = NS_NewInputStreamChannel(aURI, "text/html",
nsCRT::strlen(kBlankPage),
in, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI, &channel);
loadAttributes, originalURI,
bufferSegmentSize, bufferMaxSize, &channel);
NS_RELEASE(in);
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -49,6 +49,8 @@ nsAboutBloat::NewChannel(const char *verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **result)
{
nsresult rv;
@ -141,7 +143,8 @@ nsAboutBloat::NewChannel(const char *verb,
nsIChannel* channel;
rv = NS_NewInputStreamChannel(aURI, "text/plain",
size, inStr, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI, &channel);
loadAttributes, originalURI,
bufferSegmentSize, bufferMaxSize, &channel);
if (NS_FAILED(rv)) return rv;
*result = channel;

Просмотреть файл

@ -124,6 +124,8 @@ nsAboutProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
// about:what you ask?
@ -149,7 +151,8 @@ nsAboutProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
if (NS_SUCCEEDED(rv)) {
// The standard return case:
return aboutMod->NewChannel(verb, uri, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI, result);
loadAttributes, originalURI, bufferSegmentSize,
bufferMaxSize, result);
}
// mumble...

Просмотреть файл

@ -58,7 +58,9 @@ nsDataChannel::Init(const char* verb,
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI)
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
// we don't care about event sinks in data
nsresult rv;
@ -75,6 +77,8 @@ nsDataChannel::Init(const char* verb,
// Data urls contain all the data within the url string itself.
mOriginalURI = originalURI ? originalURI : uri;
mUrl = uri;
mBufferSegmentSize = bufferSegmentSize;
mBufferMaxSize = bufferMaxSize;
rv = ParseData();
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -55,7 +55,9 @@ public:
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI);
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
nsresult ParseData();
protected:
@ -68,7 +70,8 @@ protected:
nsCString mContentType;
PRInt32 mContentLength;
nsCOMPtr<nsISupports> mOwner;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#endif /* nsFTPChannel_h___ */

Просмотреть файл

@ -101,6 +101,8 @@ nsDataHandler::NewChannel(const char* verb, nsIURI* url,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
nsresult rv;
@ -110,7 +112,7 @@ nsDataHandler::NewChannel(const char* verb, nsIURI* url,
if (NS_FAILED(rv)) return rv;
rv = channel->Init(verb, url, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI);
loadAttributes, originalURI, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

Просмотреть файл

@ -27,5 +27,11 @@ interface nsIFileChannel;
[scriptable, uuid(fa1941f2-3102-11d3-8cd0-0060b0fc14a3)]
interface nsIFileProtocolHandler : nsIProtocolHandler
{
nsIFileChannel NewChannelFromNativePath(in string nativePath);
nsIFileChannel NewChannelFromNativePath(in string nativePath,
in nsILoadGroup aLoadGroup,
in nsIInterfaceRequestor notificationCallbacks,
in nsLoadFlags loadAttributes,
in nsIURI originalURI,
in unsigned long bufferSegmentSize,
in unsigned long bufferMaxSize);
};

Просмотреть файл

@ -68,7 +68,9 @@ nsFileChannel::Init(nsIFileProtocolHandler* handler,
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI)
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
nsresult rv;
@ -76,6 +78,8 @@ nsFileChannel::Init(nsIFileProtocolHandler* handler,
mOriginalURI = originalURI ? originalURI : uri;
mURI = uri;
mCommand = nsCRT::strdup(command);
mBufferSegmentSize = bufferSegmentSize;
mBufferMaxSize = bufferMaxSize;
if (mCommand == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
@ -222,7 +226,7 @@ nsFileChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(mSpec, mCommand, getter_AddRefs(mFileTransport));
rv = fts->CreateTransport(mSpec, mCommand, 0, 0, getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) goto done;
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
@ -248,7 +252,8 @@ nsFileChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **result
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(mSpec, mCommand, getter_AddRefs(mFileTransport));
rv = fts->CreateTransport(mSpec, mCommand, mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) goto done;
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
@ -304,7 +309,8 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(mSpec, mCommand, getter_AddRefs(mFileTransport));
rv = fts->CreateTransport(mSpec, mCommand, mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) goto done;
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
@ -333,7 +339,8 @@ nsFileChannel::AsyncWrite(nsIInputStream *fromStream,
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(mSpec, mCommand, getter_AddRefs(mFileTransport));
rv = fts->CreateTransport(mSpec, mCommand, mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mFileTransport));
if (NS_FAILED(rv)) goto done;
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
@ -553,12 +560,15 @@ public:
NS_INIT_REFCNT();
}
nsresult Init(nsIFileProtocolHandler* handler, nsFileSpec& spec) {
nsresult Init(nsFileChannel* parent, nsIFileProtocolHandler* handler,
nsFileSpec& spec) {
const char* path = spec.GetNativePathCString();
mDir = PR_OpenDir(path);
if (mDir == nsnull) // not a directory?
return NS_ERROR_FAILURE;
mHandler = handler;
mParent = parent;
NS_ADDREF(mParent);
return NS_OK;
}
@ -579,7 +589,14 @@ public:
}
const char* path = entry->name;
rv = mHandler->NewChannelFromNativePath(path, getter_AddRefs(mNext));
rv = mHandler->NewChannelFromNativePath(path,
mParent->mLoadGroup,
mParent->mCallbacks,
mParent->mLoadAttributes,
nsnull,
mParent->mBufferSegmentSize,
mParent->mBufferMaxSize,
getter_AddRefs(mNext));
if (NS_FAILED(rv)) return rv;
NS_ASSERTION(mNext, "NewChannel failed");
@ -604,9 +621,11 @@ public:
PRStatus status = PR_CloseDir(mDir);
NS_ASSERTION(status == PR_SUCCESS, "close failed");
}
NS_RELEASE(mParent);
}
protected:
nsFileChannel* mParent;
nsCOMPtr<nsIFileProtocolHandler> mHandler;
PRDir* mDir;
nsCOMPtr<nsIFileChannel> mNext;
@ -629,7 +648,7 @@ nsFileChannel::GetChildren(nsISimpleEnumerator * *aChildren)
if (dirEnum == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(dirEnum);
rv = dirEnum->Init(mHandler, mSpec);
rv = dirEnum->Init(this, mHandler, mSpec);
if (NS_FAILED(rv)) {
NS_RELEASE(dirEnum);
return rv;
@ -816,8 +835,10 @@ nsFileChannel::CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel **
nsnull,
mLoadGroup,
mCallbacks,
nsIChannel::LOAD_NORMAL,
mLoadAttributes,
nsnull,
mBufferSegmentSize,
mBufferMaxSize,
&channel);
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -69,7 +69,11 @@ public:
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI);
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
friend class nsDirEnumerator;
protected:
nsresult CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel** result);
@ -86,6 +90,8 @@ protected:
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsIStreamListener> mRealListener;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#endif // nsFileChannel_h__

Просмотреть файл

@ -132,6 +132,8 @@ nsFileProtocolHandler::NewChannel(const char* command, nsIURI* url,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
nsresult rv;
@ -141,7 +143,7 @@ nsFileProtocolHandler::NewChannel(const char* command, nsIURI* url,
if (NS_FAILED(rv)) return rv;
rv = channel->Init(this, command, url, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI);
loadAttributes, originalURI, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;
@ -153,6 +155,12 @@ nsFileProtocolHandler::NewChannel(const char* command, nsIURI* url,
NS_IMETHODIMP
nsFileProtocolHandler::NewChannelFromNativePath(const char* nativePath,
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIFileChannel* *result)
{
nsresult rv;
@ -166,10 +174,12 @@ nsFileProtocolHandler::NewChannelFromNativePath(const char* nativePath,
rv = NewChannel("load", // XXX what should this be?
uri,
nsnull, // loadGroup
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI same as uri
aLoadGroup,
notificationCallbacks,
loadAttributes,
originalURI,
bufferSegmentSize,
bufferMaxSize,
(nsIChannel**)result);
NS_RELEASE(uri);
return rv;

Просмотреть файл

@ -77,6 +77,8 @@ nsFTPChannel::Init(const char* verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIProtocolHandler* aHandler,
nsIThreadPool* aPool)
{
@ -105,6 +107,9 @@ nsFTPChannel::Init(const char* verb,
rv = SetNotificationCallbacks(notificationCallbacks);
if (NS_FAILED(rv)) return rv;
mBufferSegmentSize = bufferSegmentSize;
mBufferMaxSize = bufferMaxSize;
return rv;
}
@ -200,7 +205,8 @@ nsFTPChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
// when data become available to it.
nsCOMPtr<nsIBufferOutputStream> bufOutStream;
nsCOMPtr<nsIBufferInputStream> bufInStream;
rv = NS_NewPipe(getter_AddRefs(bufInStream), getter_AddRefs(bufOutStream));
rv = NS_NewPipe(getter_AddRefs(bufInStream), getter_AddRefs(bufOutStream),
nsnull, mBufferSegmentSize, mBufferMaxSize);
if (NS_FAILED(rv)) return rv;
*_retval = NS_STATIC_CAST(nsIInputStream*, bufInStream.get());
@ -218,7 +224,8 @@ nsFTPChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
NS_ADDREF(mConnThread); // keep our own ref to the thread obj (we'll
// release it later in this same call.
rv = mConnThread->Init(mHandler, this, nsnull);
rv = mConnThread->Init(mHandler, this, nsnull,
mBufferSegmentSize, mBufferMaxSize);
mHandler = 0;
if (NS_FAILED(rv)) {
NS_RELEASE(mConnThread);
@ -270,7 +277,8 @@ nsFTPChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
mThreadRequest = do_QueryInterface((nsISupports*)(nsIRequest*)mConnThread);
rv = mConnThread->Init(mHandler, this, ctxt);
rv = mConnThread->Init(mHandler, this, ctxt,
mBufferSegmentSize, mBufferMaxSize);
mHandler = 0;
if (NS_FAILED(rv)) {
NS_RELEASE(mConnThread);
@ -335,7 +343,8 @@ nsFTPChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
mThreadRequest = do_QueryInterface((nsISupports*)(nsIRequest*)mConnThread);
rv = mConnThread->Init(mHandler, this, ctxt);
rv = mConnThread->Init(mHandler, this, ctxt,
mBufferSegmentSize, mBufferMaxSize);
mHandler = 0;
if (NS_FAILED(rv)) {
NS_RELEASE(mConnThread);

Просмотреть файл

@ -71,6 +71,8 @@ public:
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIProtocolHandler* aHandler,
nsIThreadPool* aPool);
@ -96,6 +98,8 @@ protected:
nsCOMPtr<nsIProtocolHandler> mHandler;
nsCOMPtr<nsIThreadPool> mPool; // the thread pool we want to use to fire off connections.
nsFtpConnectionThread *mConnThread; // the raw pointer to the thread object.
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#endif /* nsFTPChannel_h___ */

Просмотреть файл

@ -1470,7 +1470,8 @@ nsFtpConnectionThread::R_retr() {
mSentStart = PR_TRUE;
}
rv = NS_NewPipe(getter_AddRefs(mBufInStream), getter_AddRefs(mBufOutStream));
rv = NS_NewPipe(getter_AddRefs(mBufInStream), getter_AddRefs(mBufOutStream),
nsnull, mBufferSegmentSize, mBufferMaxSize);
if (NS_FAILED(rv)) return FTP_ERROR;
return FTP_READ_DATA_BUF;
@ -1563,7 +1564,9 @@ nsFtpConnectionThread::R_pasv() {
nsAllocator::Free(response);
// now we know where to connect our data channel
rv = mSTS->CreateTransport(host.GetBuffer(), port, nsnull, getter_AddRefs(mDPipe)); // the data channel
rv = mSTS->CreateTransport(host.GetBuffer(), port, nsnull,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mDPipe)); // the data channel
if (NS_FAILED(rv)) return FTP_ERROR;
// hook ourself up as a proxy for progress notifications
@ -1750,7 +1753,9 @@ nsFtpConnectionThread::Run() {
if (NS_FAILED(rv)) return rv;
// build our own
rv = mSTS->CreateTransport(host, mPort, host, getter_AddRefs(mCPipe)); // the command channel
rv = mSTS->CreateTransport(host, mPort, host,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mCPipe)); // the command channel
if (NS_FAILED(rv)) return rv;
// get the output stream so we can write to the server
@ -1925,9 +1930,14 @@ nsFtpConnectionThread::Resume(void)
nsresult
nsFtpConnectionThread::Init(nsIProtocolHandler* aHandler,
nsIChannel* aChannel,
nsISupports* aContext) {
nsISupports* aContext,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize) {
nsresult rv;
mBufferSegmentSize = bufferSegmentSize;
mBufferMaxSize = bufferMaxSize;
// parameter validation
NS_ASSERTION(aChannel, "FTP: thread needs a channel");

Просмотреть файл

@ -131,7 +131,9 @@ public:
nsresult Init(nsIProtocolHandler *aHandler,
nsIChannel *aChannel,
nsISupports *aContext);
nsISupports *aContext,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
nsresult Process();
@ -267,6 +269,8 @@ private:
nsCOMPtr<nsIStreamObserver> mObserver;
nsCOMPtr<nsISupports> mObserverContext;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#define NS_FTP_BUFFER_READ_SIZE (8*1024)

Просмотреть файл

@ -159,6 +159,8 @@ nsFtpProtocolHandler::NewChannel(const char* verb, nsIURI* url,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
nsresult rv;
@ -168,7 +170,7 @@ nsFtpProtocolHandler::NewChannel(const char* verb, nsIURI* url,
if (NS_FAILED(rv)) return rv;
rv = channel->Init(verb, url, aLoadGroup, notificationCallbacks, loadAttributes,
originalURI, this, mPool);
originalURI, bufferSegmentSize, bufferMaxSize, this, mPool);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFtpProtocolHandler::NewChannel() FAILED\n"));

Просмотреть файл

@ -71,7 +71,9 @@ static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL,
const char *i_Verb,
nsIURI* originalURI,
nsHTTPHandler* i_Handler):
nsHTTPHandler* i_Handler,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize):
mAuthTriedWithPrehost(PR_FALSE),
mConnected(PR_FALSE),
mHandler(dont_QueryInterface(i_Handler)),
@ -83,7 +85,9 @@ nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL,
mState(HS_IDLE),
mURI(dont_QueryInterface(i_URL)),
mUsingProxy(PR_FALSE),
mRawResponseListener(nsnull)
mRawResponseListener(nsnull),
mBufferSegmentSize(bufferSegmentSize),
mBufferMaxSize(bufferMaxSize)
{
NS_INIT_REFCNT();
@ -640,8 +644,8 @@ nsHTTPChannel::Open(void)
}
}
rv = mHandler->RequestTransport(mURI,
this,
rv = mHandler->RequestTransport(mURI, this,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(transport));
if (NS_ERROR_BUSY == rv) {
@ -765,7 +769,8 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation,
#endif /* PR_LOGGING */
rv = serv->NewChannelFromURI(mVerb.GetBuffer(), newURI, mLoadGroup, mCallbacks,
mLoadAttributes, mOriginalURI, getter_AddRefs(channel));
mLoadAttributes, mOriginalURI,
mBufferSegmentSize, mBufferMaxSize, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
// Start the redirect...
@ -1007,7 +1012,8 @@ nsHTTPChannel::Authenticate(const char *iChallenge,
// This smells like a clone function... maybe there is a
// benefit in doing that, think. TODO.
rv = serv->NewChannelFromURI(mVerb.GetBuffer(), mURI, mLoadGroup, mCallbacks,
mLoadAttributes, mOriginalURI, getter_AddRefs(channel));
mLoadAttributes, mOriginalURI,
mBufferSegmentSize, mBufferMaxSize, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);

Просмотреть файл

@ -64,7 +64,9 @@ public:
nsHTTPChannel(nsIURI* i_URL,
const char* verb,
nsIURI* originalURI,
nsHTTPHandler* i_Handler);
nsHTTPHandler* i_Handler,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
virtual ~nsHTTPChannel();
@ -77,7 +79,7 @@ public:
// nsHTTPChannel methods:
nsresult Authenticate(const char *iChallenge,
nsIChannel **oChannel);
nsIChannel **oChannel);
nsresult Init(nsILoadGroup *aGroup);
nsresult Open();
nsresult Redirect(const char *aURL,
@ -129,6 +131,9 @@ protected:
*/
PRBool mAuthTriedWithPrehost;
PRBool mUsingProxy;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#endif /* _nsHTTPChannel_h_ */

Просмотреть файл

@ -191,6 +191,8 @@ nsHTTPHandler::NewChannel(const char* verb, nsIURI* i_URL,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **o_Instance)
{
nsresult rv;
@ -235,7 +237,9 @@ nsHTTPHandler::NewChannel(const char* verb, nsIURI* i_URL,
pChannel = new nsHTTPChannel(i_URL,
verb,
originalURI,
this);
this,
bufferSegmentSize,
bufferMaxSize);
if (pChannel) {
NS_ADDREF(pChannel);
rv = pChannel->SetLoadAttributes(loadAttributes);
@ -354,8 +358,10 @@ nsHTTPHandler::NewPostDataStream(PRBool isFile,
nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
nsHTTPChannel* i_Channel,
nsIChannel** o_pTrans)
nsHTTPChannel* i_Channel,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** o_pTrans)
{
nsresult rv;
PRUint32 count;
@ -448,11 +454,13 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
// Create a new one...
if (!mProxy || !mUseProxy)
{
rv = CreateTransport(host, port, host, &trans);
rv = CreateTransport(host, port, host,
bufferSegmentSize, bufferMaxSize, &trans);
}
else
{
rv = CreateTransport(mProxy, mProxyPort, host, &trans);
rv = CreateTransport(mProxy, mProxyPort, host,
bufferSegmentSize, bufferMaxSize, &trans);
}
if (NS_FAILED(rv)) return rv;
}
@ -474,17 +482,21 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
}
nsresult nsHTTPHandler::CreateTransport(const char* host,
PRInt32 port,
const char* aPrintHost,
nsIChannel** o_pTrans)
PRInt32 port,
const char* aPrintHost,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** o_pTrans)
{
nsresult rv;
NS_WITH_SERVICE(nsISocketTransportService, sts,
kSocketTransportServiceCID, &rv);
kSocketTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
return sts->CreateTransport(host, port, aPrintHost, o_pTrans);
return sts->CreateTransport(host, port, aPrintHost,
bufferSegmentSize, bufferMaxSize,
o_pTrans);
}
nsHTTPHandler * nsHTTPHandler::GetInstance(void)

Просмотреть файл

@ -87,6 +87,8 @@ public:
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **_retval);
NS_IMETHOD NewURI(const char *aSpec, nsIURI *aBaseURI,
@ -132,6 +134,8 @@ public:
*/
virtual nsresult RequestTransport(nsIURI *i_Uri,
nsHTTPChannel* i_Channel,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** o_pTrans);
/**
@ -141,6 +145,8 @@ public:
virtual nsresult CreateTransport(const char* host, PRInt32 port,
const char* aPrintHost,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel** o_pTrans);
/*

Просмотреть файл

@ -58,6 +58,12 @@ public:
nsCOMPtr<nsIFileChannel> jarCacheFile;
rv = serv->NewChannelFromNativePath(mJarCacheFile.GetNativePathCString(),
mJARChannel->mLoadGroup,
mJARChannel->mCallbacks,
mJARChannel->mLoadAttributes,
nsnull,
mJARChannel->mBufferSegmentSize,
mJARChannel->mBufferMaxSize,
getter_AddRefs(jarCacheFile));
if (NS_FAILED(rv)) return rv;
@ -137,7 +143,9 @@ nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI)
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
nsresult rv;
mURI = do_QueryInterface(uri, &rv);
@ -146,6 +154,8 @@ nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
if (mCommand == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
mOriginalURI = originalURI;
mBufferSegmentSize = bufferSegmentSize;
mBufferMaxSize = bufferMaxSize;
rv = SetLoadAttributes(loadAttributes);
if (NS_FAILED(rv)) return rv;
@ -267,6 +277,7 @@ nsJARChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
// on some other thread)
nsCOMPtr<nsIChannel> jarCacheTransport;
rv = fts->CreateTransport(jarCacheFile, mCommand,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(jarCacheTransport));
if (NS_FAILED(rv)) return rv;
@ -323,6 +334,7 @@ nsJARChannel::ExtractJARElement(nsIFileChannel* jarBaseFile)
nsCOMPtr<nsIChannel> jarTransport;
rv = fts->CreateTransportFromFileSystem(this, mCommand,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(jarTransport));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -73,11 +73,15 @@ public:
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI);
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
nsresult ExtractJARElement(nsIFileChannel* jarFileChannel);
nsresult GetCacheFile(nsFileSpec& cacheFile);
friend class nsJARDownloadObserver;
protected:
char* mCommand;
nsCOMPtr<nsIJARURI> mURI;
@ -98,6 +102,8 @@ protected:
nsCOMPtr<nsIFileChannel> mJARBaseFile;
char* mJAREntry;
nsCOMPtr<nsIZipReader> mJAR;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#endif // nsJARChannel_h__

Просмотреть файл

@ -122,6 +122,8 @@ nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
nsresult rv;
@ -131,7 +133,7 @@ nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
if (NS_FAILED(rv)) return rv;
rv = channel->Init(this, verb, uri, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI);
loadAttributes, originalURI, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

Просмотреть файл

@ -157,6 +157,8 @@ nsKeywordProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* aOriginalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
nsresult rv;
@ -175,7 +177,8 @@ nsKeywordProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
// now we have an HTTP url, give the user an HTTP channel
rv = serv->NewChannel(verb, httpSpec, nsnull, aLoadGroup, notificationCallbacks,
loadAttributes, aOriginalURI, result);
loadAttributes, aOriginalURI,
bufferSegmentSize, bufferMaxSize, result);
nsAllocator::Free(httpSpec);
return rv;

Просмотреть файл

@ -52,7 +52,9 @@ nsResChannel::Init(nsIResProtocolHandler* handler,
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI)
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize)
{
nsresult rv;
@ -60,6 +62,8 @@ nsResChannel::Init(nsIResProtocolHandler* handler,
if (mLock == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
mBufferSegmentSize = bufferSegmentSize;
mBufferMaxSize = bufferMaxSize;
mResolvedURI = uri;
mHandler = handler;
mOriginalURI = originalURI ? originalURI : uri;
@ -253,6 +257,7 @@ nsResChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
rv = serv->NewChannelFromURI(mCommand, mResolvedURI, mLoadGroup, mCallbacks,
mLoadAttributes, mOriginalURI,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mResolvedChannel));
if (NS_FAILED(rv)) continue;
@ -284,6 +289,7 @@ nsResChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **result)
rv = serv->NewChannelFromURI(mCommand, mResolvedURI, mLoadGroup, mCallbacks,
mLoadAttributes, mOriginalURI,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mResolvedChannel));
if (NS_FAILED(rv)) continue;
@ -330,6 +336,7 @@ nsResChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
rv = serv->NewChannelFromURI(mCommand, mResolvedURI, mLoadGroup, mCallbacks,
mLoadAttributes, mOriginalURI,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mResolvedChannel));
if (NS_FAILED(rv)) continue;
@ -390,6 +397,7 @@ nsResChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
rv = serv->NewChannelFromURI(mCommand, mResolvedURI, mLoadGroup, mCallbacks,
mLoadAttributes, mOriginalURI,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mResolvedChannel));
if (NS_FAILED(rv)) continue;
@ -452,6 +460,7 @@ nsResChannel::AsyncWrite(nsIInputStream *fromStream,
rv = serv->NewChannelFromURI(mCommand, mResolvedURI, mLoadGroup, mCallbacks,
mLoadAttributes, mOriginalURI,
mBufferSegmentSize, mBufferMaxSize,
getter_AddRefs(mResolvedChannel));
if (NS_FAILED(rv)) continue;

Просмотреть файл

@ -57,7 +57,9 @@ public:
nsILoadGroup* aLoadGroup,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI);
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize);
protected:
class Substitutions {
@ -117,6 +119,8 @@ protected:
nsCOMPtr<nsIInputStream> mFromStream;
PRUint32 mStartPosition;
PRInt32 mCount;
PRUint32 mBufferSegmentSize;
PRUint32 mBufferMaxSize;
};
#endif // nsResChannel_h__

Просмотреть файл

@ -176,6 +176,8 @@ nsResProtocolHandler::NewChannel(const char* command, nsIURI* uri,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
nsresult rv;
@ -185,7 +187,7 @@ nsResProtocolHandler::NewChannel(const char* command, nsIURI* uri,
if (NS_FAILED(rv)) return rv;
rv = channel->Init(this, command, uri, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI);
loadAttributes, originalURI, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv)) {
NS_RELEASE(channel);
return rv;

Просмотреть файл

@ -287,6 +287,8 @@ nsResourceProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *result)
{
nsresult rv;
@ -310,7 +312,8 @@ nsResourceProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
nsIChannel* channel;
rv = serv->NewChannel(verb, filePath, uri, aLoadGroup, notificationCallbacks,
loadAttributes, originalURI ? originalURI : uri, &channel);
loadAttributes, originalURI ? originalURI : uri,
bufferSegmentSize, bufferMaxSize, &channel);
nsCRT::free(filePath);
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -238,6 +238,7 @@ nsFTPDirListingConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnicha
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
&mPartChannel);
NS_RELEASE(uri);
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -258,6 +258,7 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *context,
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(mPartChannel));
if (NS_FAILED(rv)) {
nsAllocator::Free(buffer);

Просмотреть файл

@ -284,6 +284,7 @@ main(int argc, char* argv[])
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(dummyChannel));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -369,7 +369,7 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts)
NS_ASSERTION(listener, "QI failed");
nsIChannel* trans;
rv = fts->CreateTransport(spec, "load", &trans);
rv = fts->CreateTransport(spec, "load", 0, 0, &trans);
NS_ASSERTION(NS_SUCCEEDED(rv), "create failed");
rv = trans->AsyncRead(0, -1, nsnull, listener);

Просмотреть файл

@ -266,13 +266,27 @@ public:
nsIFileChannel* inCh = nsnull;
nsIFileChannel* outCh = nsnull;
rv = ioserv->NewChannelFromNativePath(mInPath, &inCh);
rv = ioserv->NewChannelFromNativePath(mInPath,
nsnull, // aLoadGroup
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, // bufferSegmentSize
0, // bufferMaxSize
&inCh);
if (NS_FAILED(rv)) goto done;
rv = inCh->OpenInputStream(0, -1, &inStr);
if (NS_FAILED(rv)) goto done;
rv = ioserv->NewChannelFromNativePath(mOutPath, &outCh);
rv = ioserv->NewChannelFromNativePath(mOutPath,
nsnull, // aLoadGroup
nsnull, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, // bufferSegmentSize
0, // bufferMaxSize
&outCh);
if (NS_FAILED(rv)) goto done;
rv = outCh->OpenOutputStream(0, &outStr);

Просмотреть файл

@ -126,7 +126,7 @@ TestAsyncRead(const char* fileName, PRUint32 offset, PRInt32 length)
nsFileSpec fs(fileName);
nsIChannel* fileTrans;
rv = fts->CreateTransport(fs, "load", &fileTrans);
rv = fts->CreateTransport(fs, "load", 0, 0, &fileTrans);
if (NS_FAILED(rv)) return rv;
MyListener* listener = new MyListener();
@ -167,7 +167,7 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length)
outFile += ".out";
nsFileSpec fs(outFile);
nsIChannel* fileTrans;
rv = fts->CreateTransport(fs, "load", &fileTrans);
rv = fts->CreateTransport(fs, "load", 0, 0, &fileTrans);
if (NS_FAILED(rv)) return rv;
MyListener* listener = new MyListener();
@ -243,7 +243,7 @@ TestAsyncOpen(const char* fileName, PRUint32 offset, PRInt32 length)
nsFileSpec fs(fileName);
nsIChannel* fileTrans;
rv = fts->CreateTransport(fs, "load", &fileTrans);
rv = fts->CreateTransport(fs, "load", 0, 0, &fileTrans);
if (NS_FAILED(rv)) return rv;
MyListener* listener = new MyListener(1);

Просмотреть файл

@ -521,6 +521,7 @@ nsresult StartLoadingURL(const char* aUrlString)
callbacks, // notificationCallbacks
nsIChannel::LOAD_NORMAL,
nsnull, // originalURI
0, 0,
getter_AddRefs(pChannel));
NS_RELEASE(callbacks);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -70,7 +70,7 @@ TestOpenInputStream(const char* url)
nsCOMPtr<nsIChannel> channel;
rv = serv->NewChannel("load", url, nsnull, nsnull, nsnull, 0, nsnull,
getter_AddRefs(channel));
0, 0, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIInputStream> in;
@ -196,7 +196,7 @@ TestAsyncRead(const char* url)
nsCOMPtr<nsIChannel> channel;
rv = serv->NewChannel("load", url, nsnull, nsnull, nsnull, 0, nsnull,
getter_AddRefs(channel));
0, 0, getter_AddRefs(channel));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStreamListener> listener = new Listener();

Просмотреть файл

@ -242,7 +242,7 @@ main(int argc, char* argv[])
// Create the socket transport...
nsIChannel* transport;
rv = sts->CreateTransport(hostName, port, hostName, &transport);
rv = sts->CreateTransport(hostName, port, hostName, 0, 0, &transport);
// This stuff is used to test the output stream
#if 0

Просмотреть файл

@ -161,7 +161,7 @@ main(int argc, char* argv[])
nsIChannel* transport;
rv = sts->CreateTransport(hostName, port, hostName, &transport);
rv = sts->CreateTransport(hostName, port, hostName, 0, 0, &transport);
if (NS_SUCCEEDED(rv)) {
transport->AsyncRead(0, -1, nsnull, new InputTestConsumer);

Просмотреть файл

@ -281,7 +281,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort,
// Create a socket transport...
NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = sts->CreateTransport(aHostName, aPort, aHostName, &mTransport);
rv = sts->CreateTransport(aHostName, aPort, aHostName, 0, 0, &mTransport);
}

Просмотреть файл

@ -356,7 +356,7 @@ int nsAccount::GetNCIValues(nsString MiddleValue)
nsIChannel *channel = nsnull;
// XXX NECKO verb? loadgroup? getter?
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull,
nsIChannel::LOAD_NORMAL, nsnull, &channel);
nsIChannel::LOAD_NORMAL, nsnull, 0, 0, &channel);
if (NS_FAILED(ret)) return ret;
@ -446,7 +446,7 @@ int nsAccount::GetConfigValues(nsString fileName)
nsIChannel *channel = nsnull;
// XXX NECKO verb? loadgroup? getter?
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull,
nsIChannel::LOAD_NORMAL, nsnull, &channel);
nsIChannel::LOAD_NORMAL, nsnull, 0, 0, &channel);
if (NS_FAILED(ret)) return ret;

Просмотреть файл

@ -336,6 +336,8 @@ nsChromeProtocolHandler::NewChannel(const char* aVerb, nsIURI* aURI,
nsIInterfaceRequestor* aNotificationCallbacks,
nsLoadFlags aLoadAttributes,
nsIURI* aOriginalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel* *aResult)
{
nsresult rv;
@ -378,6 +380,7 @@ nsChromeProtocolHandler::NewChannel(const char* aVerb, nsIURI* aURI,
aNotificationCallbacks,
aLoadAttributes,
aOriginalURI ? aOriginalURI : aURI,
bufferSegmentSize, bufferMaxSize,
getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -160,7 +160,8 @@ nsresult nsDocumentOpenInfo::Open(nsIURI *aURI,
{
nsCOMPtr<nsIChannel> aChannel;
rv = pNetService->NewChannelFromURI("", aURI, aLoadGroup, requestor,
nsIChannel::LOAD_NORMAL, aReferringURI, getter_AddRefs(aChannel));
nsIChannel::LOAD_NORMAL, aReferringURI, 0, 0,
getter_AddRefs(aChannel));
if (NS_FAILED(rv)) return rv; // uhoh we were unable to get a channel to handle the url!!!
// figure out if we need to set the post data stream on the channel...right now,
// this is only done for http channels.....

Просмотреть файл

@ -111,7 +111,7 @@ main(int argc, char* argv[])
nsIChannel *channel = nsnull;
// XXX NECKO verb? loadgroup? getter?
ret = service->NewChannel("load", TEST_URL, nsnull, nsnull, nsnull,
nsIChannel::LOAD_NORMAL, nsnull, &channel);
nsIChannel::LOAD_NORMAL, nsnull, 0, 0, &channel);
if (NS_FAILED(ret)) return ret;
nsIEventQueue *eventQ = nsnull;

Просмотреть файл

@ -39,6 +39,8 @@ nsAbout::NewChannel(const char *verb,
nsIInterfaceRequestor* notificationCallbacks,
nsLoadFlags loadAttributes,
nsIURI* originalURI,
PRUint32 bufferSegmentSize,
PRUint32 bufferMaxSize,
nsIChannel **result)
{
nsresult rv;
@ -47,7 +49,8 @@ nsAbout::NewChannel(const char *verb,
return rv;
rv = ioService->NewChannel(verb, kURI, NULL, aLoadGroup,
notificationCallbacks, loadAttributes,
originalURI, result);
originalURI, bufferSegmentSize, bufferMaxSize,
result);
return rv;
}

Просмотреть файл

@ -160,8 +160,7 @@ nsStreamXferOp::Start( void ) {
// Next, create output file channel.
nsFileSpec target;
mOutputSpec->GetFileSpec( &target );
rv = fts->CreateTransport( target,
"load",
rv = fts->CreateTransport( target, "load", 0, 0,
getter_AddRefs( mOutputChannel ) );
if ( NS_SUCCEEDED( rv ) ) {