зеркало из https://github.com/mozilla/pjs.git
fix for bug 11232 - helper function for putting the reading of a stream into the background
r=dougt, sr=darin
This commit is contained in:
Родитель
4bd2c56def
Коммит
db5dd7ed0e
|
@ -61,6 +61,7 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsIInputStreamChannel.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIStreamTransportService.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIDownloader.h"
|
||||
#include "nsIResumableEntityID.h"
|
||||
|
@ -752,6 +753,52 @@ NS_NewLocalFileOutputStream(nsIOutputStream** aResult,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_BackgroundInputStream(nsIInputStream** aResult,
|
||||
nsIInputStream* aStream,
|
||||
PRUint32 aSegmentSize = 0,
|
||||
PRUint32 aSegmentCount = 0)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIStreamTransportService> sts =
|
||||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsITransport> inTransport;
|
||||
rv = sts->CreateInputTransport(aStream, -1, -1, PR_TRUE,
|
||||
getter_AddRefs(inTransport));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return inTransport->OpenInputStream(nsITransport::OPEN_BLOCKING,
|
||||
aSegmentSize, aSegmentCount, aResult);
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_BackgroundOutputStream(nsIOutputStream** aResult,
|
||||
nsIOutputStream* aStream,
|
||||
PRUint32 aSegmentSize = 0,
|
||||
PRUint32 aSegmentCount = 0)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIStreamTransportService> sts =
|
||||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsITransport> inTransport;
|
||||
rv = sts->CreateOutputTransport(aStream, -1, -1, PR_TRUE,
|
||||
getter_AddRefs(inTransport));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return inTransport->OpenOutputStream(nsITransport::OPEN_BLOCKING,
|
||||
aSegmentSize, aSegmentCount, aResult);
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_NewBufferedInputStream(nsIInputStream** aResult,
|
||||
nsIInputStream* aStr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче