зеркало из https://github.com/mozilla/gecko-dev.git
Bug 330701 - NS_NewPipe with default segment size ignores max size. r=darin
This commit is contained in:
Родитель
5a87b29c79
Коммит
ce29bd091b
|
@ -118,6 +118,7 @@ void XXXNeverCalled()
|
|||
nsValueArray(0);
|
||||
nsSupportsArray();
|
||||
NS_GetNumberOfAtoms();
|
||||
NS_NewPipe(nsnull, nsnull, 0, 0, PR_FALSE, PR_FALSE, nsnull);
|
||||
NS_NewPipe2(nsnull, nsnull, PR_FALSE, PR_FALSE, 0, 0, nsnull);
|
||||
NS_NewInputStreamReadyEvent(nsnull, nsnull, nsnull);
|
||||
NS_NewOutputStreamReadyEvent(nsnull, nsnull, nsnull);
|
||||
|
|
|
@ -182,30 +182,13 @@ NS_NewPipe2(nsIAsyncInputStream **pipeIn,
|
|||
* pass reference to nsIMemory to have all pipe allocations use this
|
||||
* allocator (pass null to use the default allocator)
|
||||
*/
|
||||
inline nsresult
|
||||
extern NS_COM nsresult
|
||||
NS_NewPipe(nsIInputStream **pipeIn,
|
||||
nsIOutputStream **pipeOut,
|
||||
PRUint32 segmentSize = 0,
|
||||
PRUint32 maxSize = 0,
|
||||
PRBool nonBlockingInput = PR_FALSE,
|
||||
PRBool nonBlockingOutput = PR_FALSE,
|
||||
nsIMemory *segmentAlloc = nsnull)
|
||||
{
|
||||
PRUint32 segmentCount;
|
||||
if (segmentSize == 0)
|
||||
segmentCount = 0; // use default
|
||||
else
|
||||
segmentCount = maxSize / segmentSize;
|
||||
|
||||
nsIAsyncInputStream *in;
|
||||
nsIAsyncOutputStream *out;
|
||||
nsresult rv = NS_NewPipe2(&in, &out, nonBlockingInput, nonBlockingOutput,
|
||||
segmentSize, segmentCount, segmentAlloc);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*pipeIn = in;
|
||||
*pipeOut = out;
|
||||
return NS_OK;
|
||||
}
|
||||
nsIMemory *segmentAlloc = nsnull);
|
||||
|
||||
%}
|
||||
|
|
|
@ -1240,6 +1240,36 @@ nsPipeOutputStream::SetEOF()
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewPipe(nsIInputStream **pipeIn,
|
||||
nsIOutputStream **pipeOut,
|
||||
PRUint32 segmentSize,
|
||||
PRUint32 maxSize,
|
||||
PRBool nonBlockingInput,
|
||||
PRBool nonBlockingOutput,
|
||||
nsIMemory *segmentAlloc)
|
||||
{
|
||||
if (segmentSize == 0)
|
||||
segmentSize = DEFAULT_SEGMENT_SIZE;
|
||||
|
||||
// Handle maxSize of PR_UINT32_MAX as a special case
|
||||
PRUint32 segmentCount;
|
||||
if (maxSize == PR_UINT32_MAX)
|
||||
segmentCount = PR_UINT32_MAX;
|
||||
else
|
||||
segmentCount = maxSize / segmentSize;
|
||||
|
||||
nsIAsyncInputStream *in;
|
||||
nsIAsyncOutputStream *out;
|
||||
nsresult rv = NS_NewPipe2(&in, &out, nonBlockingInput, nonBlockingOutput,
|
||||
segmentSize, segmentCount, segmentAlloc);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*pipeIn = in;
|
||||
*pipeOut = out;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewPipe2(nsIAsyncInputStream **pipeIn,
|
||||
nsIAsyncOutputStream **pipeOut,
|
||||
|
|
Загрузка…
Ссылка в новой задаче