зеркало из https://github.com/mozilla/gecko-dev.git
Back out Bug 536324 part 3.
This commit is contained in:
Родитель
3784e67919
Коммит
cf69667c0d
|
@ -460,12 +460,12 @@ nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
|
|||
nsresult rv;
|
||||
nsCOMPtr<nsIInputStream> bufferedStream;
|
||||
if (!NS_InputStreamIsBuffered(aIn)) {
|
||||
PRInt64 chunkSize;
|
||||
PRInt32 chunkSize;
|
||||
rv = aChannel->GetContentLength(&chunkSize);
|
||||
if (NS_FAILED(rv)) {
|
||||
chunkSize = 4096;
|
||||
}
|
||||
chunkSize = NS_MIN(PRInt64(PR_UINT16_MAX), chunkSize);
|
||||
chunkSize = NS_MIN(PRInt32(PR_UINT16_MAX), chunkSize);
|
||||
|
||||
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), aIn,
|
||||
chunkSize);
|
||||
|
|
|
@ -240,7 +240,7 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
|
|||
responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) {
|
||||
// We weren't seeking and got a valid response status,
|
||||
// set the length of the content.
|
||||
PRInt64 cl = -1;
|
||||
PRInt32 cl = -1;
|
||||
hc->GetContentLength(&cl);
|
||||
if (cl >= 0) {
|
||||
mCacheStream.NotifyDataLength(cl);
|
||||
|
|
|
@ -905,7 +905,7 @@ NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(
|
|||
}
|
||||
}
|
||||
|
||||
PRInt64 channelContentLength = -1;
|
||||
PRInt32 channelContentLength = -1;
|
||||
if (!cancel &&
|
||||
NS_SUCCEEDED(channel->GetContentLength(&channelContentLength)))
|
||||
{
|
||||
|
|
|
@ -350,7 +350,7 @@ class nsGnomeVFSInputStream : public nsIInputStream
|
|||
: mSpec(uriSpec)
|
||||
, mChannel(nsnull)
|
||||
, mHandle(nsnull)
|
||||
, mBytesRemaining(LL_MAXUINT)
|
||||
, mBytesRemaining(PR_UINT32_MAX)
|
||||
, mStatus(NS_OK)
|
||||
, mDirList(nsnull)
|
||||
, mDirListPtr(nsnull)
|
||||
|
@ -386,7 +386,7 @@ class nsGnomeVFSInputStream : public nsIInputStream
|
|||
nsCString mSpec;
|
||||
nsIChannel *mChannel; // manually refcounted
|
||||
GnomeVFSHandle *mHandle;
|
||||
PRUint64 mBytesRemaining;
|
||||
PRUint32 mBytesRemaining;
|
||||
nsresult mStatus;
|
||||
GList *mDirList;
|
||||
GList *mDirListPtr;
|
||||
|
@ -460,11 +460,12 @@ nsGnomeVFSInputStream::DoOpen()
|
|||
if (info.mime_type && (strcmp(info.mime_type, APPLICATION_OCTET_STREAM) != 0))
|
||||
SetContentTypeOfChannel(info.mime_type);
|
||||
|
||||
mBytesRemaining = info.size;
|
||||
// XXX truncates size from 64-bit to 32-bit
|
||||
mBytesRemaining = (PRUint32) info.size;
|
||||
|
||||
// Update the content length attribute on the channel. We do this
|
||||
// synchronously without proxying. This hack is not as bad as it looks!
|
||||
if (mBytesRemaining != PRUint64(-1))
|
||||
if (mBytesRemaining != PR_UINT32_MAX)
|
||||
mChannel->SetContentLength(mBytesRemaining);
|
||||
}
|
||||
else
|
||||
|
@ -508,7 +509,6 @@ nsGnomeVFSInputStream::DoRead(char *aBuf, PRUint32 aCount, PRUint32 *aCountRead)
|
|||
rv = gnome_vfs_read(mHandle, aBuf, aCount, &bytesRead);
|
||||
if (rv == GNOME_VFS_OK)
|
||||
{
|
||||
// XXX 64-bit here
|
||||
*aCountRead = (PRUint32) bytesRead;
|
||||
mBytesRemaining -= *aCountRead;
|
||||
}
|
||||
|
@ -704,7 +704,6 @@ nsGnomeVFSInputStream::Available(PRUint32 *aResult)
|
|||
if (NS_FAILED(mStatus))
|
||||
return mStatus;
|
||||
|
||||
// XXX 64-bit here
|
||||
*aResult = mBytesRemaining;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ mozJSSubScriptLoader::LoadSubScript (const PRUnichar * aURL
|
|||
|
||||
/* load up the url. From here on, failures are reflected as ``custom''
|
||||
* js exceptions */
|
||||
PRInt64 len = -1;
|
||||
PRInt32 len = -1;
|
||||
PRUint32 readcount = 0; // Total amount of data read
|
||||
PRUint32 lastReadCount = 0; // Amount of data read in last Read() call
|
||||
nsAutoArrayPtr<char> buf;
|
||||
|
@ -313,9 +313,6 @@ mozJSSubScriptLoader::LoadSubScript (const PRUnichar * aURL
|
|||
goto return_exception;
|
||||
}
|
||||
|
||||
if (len > PR_INT32_MAX)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
buf = new char[len + 1];
|
||||
if (!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -1100,13 +1100,16 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
|
|||
if (imageType == imgIContainer::TYPE_RASTER) {
|
||||
/* Use content-length as a size hint for http channels. */
|
||||
if (httpChannel) {
|
||||
PRInt64 contentLength;
|
||||
rv = httpChannel->GetContentLength(&contentLength);
|
||||
nsCAutoString contentLength;
|
||||
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-length"),
|
||||
contentLength);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 len = contentLength.ToInteger(&rv);
|
||||
|
||||
// Pass anything usable on so that the RasterImage can preallocate
|
||||
// its source buffer
|
||||
if (contentLength > 0) {
|
||||
PRUint32 sizeHint = (PRUint32) contentLength;
|
||||
if (len > 0) {
|
||||
PRUint32 sizeHint = (PRUint32) len;
|
||||
sizeHint = PR_MIN(sizeHint, 20000000); /* Bound by something reasonable */
|
||||
RasterImage* rasterImage = static_cast<RasterImage*>(mImage.get());
|
||||
rasterImage->SetSourceSizeHint(sizeHint);
|
||||
|
|
|
@ -519,7 +519,7 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
|
|||
if (loadGroup)
|
||||
mWeakPtrChannelLoadGroup = do_GetWeakReference(loadGroup);
|
||||
|
||||
PRInt64 length;
|
||||
PRInt32 length;
|
||||
rv = channel->GetContentLength(&length);
|
||||
|
||||
// it's possible for the server to not send a Content-Length.
|
||||
|
|
|
@ -136,7 +136,7 @@ private:
|
|||
PRPackedBool mStartBinding;
|
||||
PRPackedBool mHaveFiredOnStartRequest;
|
||||
// these get passed to the plugin stream listener
|
||||
PRUint64 mLength;
|
||||
PRUint32 mLength;
|
||||
PRInt32 mStreamType;
|
||||
|
||||
// local cached file, we save the content into local cache if browser cache is not available,
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsInt64.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
@ -100,22 +101,22 @@ AppendToFile(nsILocalFile *lf, const char *data, PRUint32 len)
|
|||
|
||||
// maxSize may be -1 if unknown
|
||||
static void
|
||||
MakeRangeSpec(PRInt64 size, PRInt64 maxSize, PRInt32 chunkSize,
|
||||
MakeRangeSpec(const nsInt64 &size, const nsInt64 &maxSize, PRInt32 chunkSize,
|
||||
PRBool fetchRemaining, nsCString &rangeSpec)
|
||||
{
|
||||
rangeSpec.AssignLiteral("bytes=");
|
||||
rangeSpec.AppendInt(size);
|
||||
rangeSpec.AppendInt(PRInt64(size));
|
||||
rangeSpec.Append('-');
|
||||
|
||||
if (fetchRemaining)
|
||||
return;
|
||||
|
||||
PRInt64 end = size + chunkSize;
|
||||
if (maxSize != -1 && end > maxSize)
|
||||
nsInt64 end = size + nsInt64(chunkSize);
|
||||
if (maxSize != nsInt64(-1) && end > maxSize)
|
||||
end = maxSize;
|
||||
end -= 1;
|
||||
|
||||
rangeSpec.AppendInt(end);
|
||||
rangeSpec.AppendInt(PRInt64(end));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -164,8 +165,8 @@ private:
|
|||
PRInt32 mChunkLen;
|
||||
PRInt32 mChunkSize;
|
||||
PRInt32 mInterval;
|
||||
PRInt64 mTotalSize;
|
||||
PRInt64 mCurrentSize;
|
||||
nsInt64 mTotalSize;
|
||||
nsInt64 mCurrentSize;
|
||||
PRUint32 mLoadFlags;
|
||||
PRInt32 mNonPartialCount;
|
||||
nsresult mStatus;
|
||||
|
@ -196,7 +197,7 @@ nsIncrementalDownload::nsIncrementalDownload()
|
|||
nsresult
|
||||
nsIncrementalDownload::FlushChunk()
|
||||
{
|
||||
NS_ASSERTION(mTotalSize != -1, "total size should be known");
|
||||
NS_ASSERTION(mTotalSize != nsInt64(-1), "total size should be known");
|
||||
|
||||
if (mChunkLen == 0)
|
||||
return NS_OK;
|
||||
|
@ -205,7 +206,7 @@ nsIncrementalDownload::FlushChunk()
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mCurrentSize += mChunkLen;
|
||||
mCurrentSize += nsInt64(mChunkLen);
|
||||
mChunkLen = 0;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -218,8 +219,8 @@ nsIncrementalDownload::UpdateProgress()
|
|||
|
||||
if (mProgressSink)
|
||||
mProgressSink->OnProgress(this, mObserverContext,
|
||||
mCurrentSize + mChunkLen,
|
||||
mTotalSize);
|
||||
PRUint64(PRInt64(mCurrentSize) + mChunkLen),
|
||||
PRUint64(PRInt64(mTotalSize)));
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -284,7 +285,7 @@ nsIncrementalDownload::ProcessTimeout()
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_ASSERTION(mCurrentSize != -1,
|
||||
NS_ASSERTION(mCurrentSize != nsInt64(-1),
|
||||
"we should know the current file size by now");
|
||||
|
||||
rv = ClearRequestHeader(http);
|
||||
|
@ -293,7 +294,7 @@ nsIncrementalDownload::ProcessTimeout()
|
|||
|
||||
// Don't bother making a range request if we are just going to fetch the
|
||||
// entire document.
|
||||
if (mInterval || mCurrentSize != 0) {
|
||||
if (mInterval || mCurrentSize != nsInt64(0)) {
|
||||
nsCAutoString range;
|
||||
MakeRangeSpec(mCurrentSize, mTotalSize, mChunkSize, mInterval == 0, range);
|
||||
|
||||
|
@ -318,8 +319,8 @@ nsIncrementalDownload::ProcessTimeout()
|
|||
nsresult
|
||||
nsIncrementalDownload::ReadCurrentSize()
|
||||
{
|
||||
PRInt64 size;
|
||||
nsresult rv = mDest->GetFileSize(&size);
|
||||
nsInt64 size;
|
||||
nsresult rv = mDest->GetFileSize((PRInt64 *) &size);
|
||||
if (rv == NS_ERROR_FILE_NOT_FOUND ||
|
||||
rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
|
||||
mCurrentSize = 0;
|
||||
|
@ -552,7 +553,7 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
|
|||
// We may already have the entire file downloaded, in which case
|
||||
// our request for a range beyond the end of the file would have
|
||||
// been met with an error response code.
|
||||
if (code == 416 && mTotalSize == -1) {
|
||||
if (code == 416 && mTotalSize == nsInt64(-1)) {
|
||||
mTotalSize = mCurrentSize;
|
||||
// Return an error code here to suppress OnDataAvailable.
|
||||
return NS_ERROR_DOWNLOAD_COMPLETE;
|
||||
|
@ -586,7 +587,7 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
|
|||
}
|
||||
|
||||
// Do special processing after the first response.
|
||||
if (mTotalSize == -1) {
|
||||
if (mTotalSize == nsInt64(-1)) {
|
||||
// Update knowledge of mFinalURI
|
||||
rv = http->GetURI(getter_AddRefs(mFinalURI));
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -604,12 +605,18 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
|
|||
NS_WARNING("server returned invalid Content-Range header!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
if (PR_sscanf(buf.get() + slash + 1, "%lld", &mTotalSize) != 1)
|
||||
if (PR_sscanf(buf.get() + slash + 1, "%lld", (PRInt64 *) &mTotalSize) != 1)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
} else {
|
||||
http->GetContentLength(&mTotalSize);
|
||||
// Use nsIPropertyBag2 to fetch the content length as it exposes the
|
||||
// value as a 64-bit number.
|
||||
nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(request, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = props->GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
|
||||
&mTotalSize.mValue);
|
||||
// We need to know the total size of the thing we're trying to download.
|
||||
if (mTotalSize == -1) {
|
||||
if (mTotalSize == nsInt64(-1)) {
|
||||
NS_WARNING("server returned no content-length header!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -626,13 +633,13 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
|
|||
}
|
||||
|
||||
// Adjust mChunkSize accordingly if mCurrentSize is close to mTotalSize.
|
||||
PRInt64 diff = mTotalSize - mCurrentSize;
|
||||
if (diff <= 0) {
|
||||
nsInt64 diff = mTotalSize - mCurrentSize;
|
||||
if (diff <= nsInt64(0)) {
|
||||
NS_WARNING("about to set a bogus chunk size; giving up");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (diff < mChunkSize)
|
||||
if (diff < nsInt64(mChunkSize))
|
||||
mChunkSize = PRUint32(diff);
|
||||
|
||||
mChunk = new char[mChunkSize];
|
||||
|
|
|
@ -49,7 +49,8 @@ nsInputStreamChannel::OpenContentStream(PRBool async, nsIInputStream **result,
|
|||
// If content length is unknown, then we must guess. In this case, we assume
|
||||
// the stream can tell us. If the stream is a pipe, then this will not work.
|
||||
|
||||
if (ContentLength() < 0) {
|
||||
PRInt64 len = ContentLength64();
|
||||
if (len < 0) {
|
||||
PRUint32 avail;
|
||||
nsresult rv = mContentStream->Available(&avail);
|
||||
if (rv == NS_BASE_STREAM_CLOSED) {
|
||||
|
@ -58,7 +59,7 @@ nsInputStreamChannel::OpenContentStream(PRBool async, nsIInputStream **result,
|
|||
} else if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
ContentLength() = avail;
|
||||
SetContentLength64(avail);
|
||||
}
|
||||
|
||||
EnableSynthesizedProgressEvents(PR_TRUE);
|
||||
|
|
|
@ -99,15 +99,9 @@ nsStreamLoader::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
|
|||
{
|
||||
nsCOMPtr<nsIChannel> chan( do_QueryInterface(request) );
|
||||
if (chan) {
|
||||
PRInt64 contentLength = -1;
|
||||
PRInt32 contentLength = -1;
|
||||
chan->GetContentLength(&contentLength);
|
||||
if (contentLength >= 0) {
|
||||
if (contentLength > PR_UINT32_MAX) {
|
||||
// too big to fit in a PRUint32, bail now.
|
||||
// XXX make mAllocated and mLength 64-bit
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// preallocate buffer
|
||||
mData = static_cast<PRUint8*>(NS_Alloc(contentLength));
|
||||
if (!mData) {
|
||||
|
|
|
@ -121,7 +121,7 @@ nsDataChannel::OpenContentStream(PRBool async, nsIInputStream **result,
|
|||
|
||||
SetContentType(contentType);
|
||||
SetContentCharset(contentCharset);
|
||||
ContentLength() = contentLen;
|
||||
SetContentLength64(contentLen);
|
||||
|
||||
NS_ADDREF(*result = bufInStream);
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ nsFileChannel::OpenContentStream(PRBool async, nsIInputStream **result,
|
|||
}
|
||||
stream = uploadStream;
|
||||
|
||||
ContentLength() = 0;
|
||||
SetContentLength64(0);
|
||||
|
||||
// Since there isn't any content to speak of we just set the content-type
|
||||
// to something other than "unknown" to avoid triggering the content-type
|
||||
|
@ -374,12 +374,12 @@ nsFileChannel::OpenContentStream(PRBool async, nsIInputStream **result,
|
|||
EnableSynthesizedProgressEvents(PR_TRUE);
|
||||
|
||||
// fixup content length and type
|
||||
if (ContentLength() < 0) {
|
||||
if (ContentLength64() < 0) {
|
||||
PRInt64 size;
|
||||
rv = file->GetFileSize(&size);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
ContentLength() = size;
|
||||
SetContentLength64(size);
|
||||
}
|
||||
if (!contentType.IsEmpty())
|
||||
SetContentType(contentType);
|
||||
|
|
|
@ -1007,7 +1007,7 @@ FTP_STATE
|
|||
nsFtpState::R_size() {
|
||||
if (mResponseCode/100 == 2) {
|
||||
PR_sscanf(mResponseMsg.get() + 4, "%llu", &mFileSize);
|
||||
mChannel->ContentLength() = mFileSize;
|
||||
mChannel->SetContentLength64(mFileSize);
|
||||
}
|
||||
|
||||
// We may want to be able to resume this
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsURLHelper.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "prprf.h"
|
||||
|
||||
//
|
||||
// Helper function for determining the length of data bytes up to
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsInt64.h"
|
||||
#include "nsIByteRangeRequest.h"
|
||||
#include "nsIMultiPartChannel.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
@ -101,8 +102,8 @@ protected:
|
|||
PRUint64 mContentLength;
|
||||
|
||||
PRBool mIsByteRangeRequest;
|
||||
PRInt64 mByteRangeStart;
|
||||
PRInt64 mByteRangeEnd;
|
||||
nsInt64 mByteRangeStart;
|
||||
nsInt64 mByteRangeEnd;
|
||||
|
||||
PRUint32 mPartID; // unique ID that can be used to identify
|
||||
// this part of the multipart document
|
||||
|
@ -189,8 +190,8 @@ protected:
|
|||
// The following members are for tracking the byte ranges in
|
||||
// multipart/mixed content which specified the 'Content-Range:'
|
||||
// header...
|
||||
PRInt64 mByteRangeStart;
|
||||
PRInt64 mByteRangeEnd;
|
||||
nsInt64 mByteRangeStart;
|
||||
nsInt64 mByteRangeEnd;
|
||||
PRBool mIsByteRangeRequest;
|
||||
|
||||
PRUint32 mCurrentPartID;
|
||||
|
|
|
@ -399,9 +399,9 @@ InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context)
|
|||
channel->GetContentCharset(value);
|
||||
LOG(("\tContent-Charset: %s\n", value.get()));
|
||||
|
||||
PRInt64 length = -1;
|
||||
PRInt32 length = -1;
|
||||
if (NS_SUCCEEDED(channel->GetContentLength(&length)))
|
||||
LOG(("\tContent-Length: %lld\n", length));
|
||||
LOG(("\tContent-Length: %d\n", length));
|
||||
else
|
||||
LOG(("\tContent-Length: Unknown\n"));
|
||||
}
|
||||
|
@ -424,6 +424,15 @@ InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context)
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPropertyBag2> propbag = do_QueryInterface(request);
|
||||
if (propbag) {
|
||||
PRInt64 len;
|
||||
nsresult rv = propbag->GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
|
||||
&len);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
LOG(("\t64-bit length: %lli\n", len));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpChannelInt(do_QueryInterface(request));
|
||||
if (httpChannelInt) {
|
||||
PRUint32 majorVer, minorVer;
|
||||
|
|
|
@ -3151,7 +3151,7 @@ PSMContentDownloader::~PSMContentDownloader()
|
|||
|
||||
NS_IMPL_ISUPPORTS2(PSMContentDownloader, nsIStreamListener, nsIRequestObserver)
|
||||
|
||||
const PRInt64 kDefaultCertAllocLength = 2048;
|
||||
const PRInt32 kDefaultCertAllocLength = 2048;
|
||||
|
||||
NS_IMETHODIMP
|
||||
PSMContentDownloader::OnStartRequest(nsIRequest* request, nsISupports* context)
|
||||
|
@ -3164,14 +3164,11 @@ PSMContentDownloader::OnStartRequest(nsIRequest* request, nsISupports* context)
|
|||
// Get the URI //
|
||||
channel->GetURI(getter_AddRefs(mURI));
|
||||
|
||||
PRInt64 contentLength;
|
||||
PRInt32 contentLength;
|
||||
rv = channel->GetContentLength(&contentLength);
|
||||
if (NS_FAILED(rv) || contentLength <= 0)
|
||||
contentLength = kDefaultCertAllocLength;
|
||||
|
||||
if (contentLength > PR_INT32_MAX)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mBufferOffset = 0;
|
||||
mBufferSize = 0;
|
||||
mByteData = (char*) nsMemory::Alloc(contentLength);
|
||||
|
|
|
@ -82,6 +82,7 @@ ExternalHelperAppParent::Init(TabParent *parent,
|
|||
do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(helperAppService, "No Helper App Service!");
|
||||
|
||||
SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH, mContentLength);
|
||||
helperAppService->DoContent(aMimeContentType, this, ir,
|
||||
aForceSave, getter_AddRefs(mListener));
|
||||
}
|
||||
|
@ -296,14 +297,17 @@ ExternalHelperAppParent::SetContentCharset(const nsACString& aContentCharset)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ExternalHelperAppParent::GetContentLength(PRInt64 *aContentLength)
|
||||
ExternalHelperAppParent::GetContentLength(PRInt32 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
if (mContentLength > PR_INT32_MAX || mContentLength < 0)
|
||||
*aContentLength = -1;
|
||||
else
|
||||
*aContentLength = (PRInt32)mContentLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ExternalHelperAppParent::SetContentLength(PRInt64 aContentLength)
|
||||
ExternalHelperAppParent::SetContentLength(PRInt32 aContentLength)
|
||||
{
|
||||
mContentLength = aContentLength;
|
||||
return NS_OK;
|
||||
|
|
|
@ -643,6 +643,26 @@ nsExternalHelperAppService::~nsExternalHelperAppService()
|
|||
gExtProtSvc = nsnull;
|
||||
}
|
||||
|
||||
static PRInt64 GetContentLengthAsInt64(nsIRequest *request)
|
||||
{
|
||||
PRInt64 contentLength = -1;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(request, &rv));
|
||||
if (props)
|
||||
rv = props->GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH, &contentLength);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
if (channel) {
|
||||
PRInt32 smallLen;
|
||||
channel->GetContentLength(&smallLen);
|
||||
contentLength = smallLen;
|
||||
}
|
||||
}
|
||||
|
||||
return contentLength;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeContentType,
|
||||
nsIRequest *aRequest,
|
||||
nsIInterfaceRequestor *aWindowContext,
|
||||
|
@ -661,6 +681,7 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
|
|||
channel->GetURI(getter_AddRefs(uri));
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
PRInt64 contentLength = GetContentLengthAsInt64(aRequest);
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
// We need to get a hold of a TabChild so that we can begin forwarding
|
||||
// this data to the parent. In the HTTP case, this is unfortunate, since
|
||||
|
@ -677,10 +698,6 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
|
|||
if (!tabchild)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt64 contentLength = -1;
|
||||
if (channel)
|
||||
channel->GetContentLength(&contentLength);
|
||||
|
||||
// Now we build a protocol for forwarding our data to the parent. The
|
||||
// protocol will act as a listener on the child-side and create a "real"
|
||||
// helperAppService listener on the parent-side, via another call to
|
||||
|
@ -1400,7 +1417,7 @@ void nsExternalAppHandler::EnsureSuggestedFileName()
|
|||
}
|
||||
}
|
||||
|
||||
nsresult nsExternalAppHandler::SetUpTempFile()
|
||||
nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
|
||||
{
|
||||
// First we need to try to get the destination directory for the temporary
|
||||
// file.
|
||||
|
@ -1537,6 +1554,9 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
|
|||
nsCOMPtr<nsIFileChannel> fileChan(do_QueryInterface(request));
|
||||
mIsFileChannel = fileChan != nsnull;
|
||||
|
||||
// Get content length
|
||||
mContentLength.mValue = GetContentLengthAsInt64(request);
|
||||
|
||||
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(request, &rv));
|
||||
// Determine whether a new window was opened specifically for this request
|
||||
if (props) {
|
||||
|
@ -1546,15 +1566,13 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
|
|||
mShouldCloseWindow = tmp;
|
||||
}
|
||||
|
||||
// Get content length and URI
|
||||
mContentLength = -1;
|
||||
// Now get the URI
|
||||
if (aChannel)
|
||||
{
|
||||
aChannel->GetURI(getter_AddRefs(mSourceUrl));
|
||||
aChannel->GetContentLength(&mContentLength);
|
||||
}
|
||||
|
||||
rv = SetUpTempFile();
|
||||
rv = SetUpTempFile(aChannel);
|
||||
if (NS_FAILED(rv)) {
|
||||
mCanceled = PR_TRUE;
|
||||
request->Cancel(rv);
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
#include "prlog.h"
|
||||
#include "prtime.h"
|
||||
|
||||
#include "nsInt64.h"
|
||||
|
||||
#include "nsIExternalHelperAppService.h"
|
||||
#include "nsIExternalProtocolService.h"
|
||||
#include "nsIWebProgressListener2.h"
|
||||
|
@ -340,8 +342,8 @@ protected:
|
|||
PRBool mTempFileIsExecutable;
|
||||
|
||||
PRTime mTimeDownloadStarted;
|
||||
PRInt64 mContentLength;
|
||||
PRInt64 mProgress; /**< Number of bytes received (for sending progress notifications). */
|
||||
nsInt64 mContentLength;
|
||||
nsInt64 mProgress; /**< Number of bytes received (for sending progress notifications). */
|
||||
|
||||
/**
|
||||
* When we are told to save the temp file to disk (in a more permament
|
||||
|
@ -357,7 +359,7 @@ protected:
|
|||
* Creates the temporary file for the download and an output stream for it.
|
||||
* Upon successful return, both mTempFile and mOutStream will be valid.
|
||||
*/
|
||||
nsresult SetUpTempFile();
|
||||
nsresult SetUpTempFile(nsIChannel * aChannel);
|
||||
/**
|
||||
* When we download a helper app, we are going to retarget all load
|
||||
* notifications into our own docloader and load group instead of
|
||||
|
|
|
@ -574,11 +574,7 @@ NS_IMETHODIMP
|
|||
nsOfflineCacheUpdateItem::GetTotalSize(PRInt32 *aTotalSize)
|
||||
{
|
||||
if (mChannel) {
|
||||
PRInt64 length;
|
||||
mChannel->GetContentLength(&length);
|
||||
|
||||
*aTotalSize = PRInt32(length);
|
||||
return NS_OK;
|
||||
return mChannel->GetContentLength(aTotalSize);
|
||||
}
|
||||
|
||||
*aTotalSize = -1;
|
||||
|
@ -588,7 +584,7 @@ nsOfflineCacheUpdateItem::GetTotalSize(PRInt32 *aTotalSize)
|
|||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateItem::GetLoadedSize(PRInt32 *aLoadedSize)
|
||||
{
|
||||
*aLoadedSize = PRInt32(mBytesRead);
|
||||
*aLoadedSize = mBytesRead;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ private:
|
|||
PRUint16 mState;
|
||||
|
||||
protected:
|
||||
PRInt64 mBytesRead;
|
||||
PRInt32 mBytesRead;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -816,11 +816,7 @@ NS_IMETHODIMP
|
|||
nsPrefetchNode::GetTotalSize(PRInt32 *aTotalSize)
|
||||
{
|
||||
if (mChannel) {
|
||||
PRInt64 length;
|
||||
mChannel->GetContentLength(&length);
|
||||
|
||||
*aTotalSize = PRInt32(length);
|
||||
return NS_OK;
|
||||
return mChannel->GetContentLength(aTotalSize);
|
||||
}
|
||||
|
||||
*aTotalSize = -1;
|
||||
|
@ -830,7 +826,7 @@ nsPrefetchNode::GetTotalSize(PRInt32 *aTotalSize)
|
|||
NS_IMETHODIMP
|
||||
nsPrefetchNode::GetLoadedSize(PRInt32 *aLoadedSize)
|
||||
{
|
||||
*aLoadedSize = PRInt32(mBytesRead);
|
||||
*aLoadedSize = mBytesRead;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ private:
|
|||
nsRefPtr<nsPrefetchService> mService;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
PRUint16 mState;
|
||||
PRInt64 mBytesRead;
|
||||
PRInt32 mBytesRead;
|
||||
};
|
||||
|
||||
#endif // !nsPrefetchService_h__
|
||||
|
|
|
@ -290,14 +290,14 @@ STDMETHODIMP nsDataObj::CStream::Stat(STATSTG* statstg, DWORD dwFlags)
|
|||
SystemTimeToFileTime((const SYSTEMTIME*)&st, (LPFILETIME)&statstg->mtime);
|
||||
statstg->ctime = statstg->atime = statstg->mtime;
|
||||
|
||||
PRInt64 nLength = 0;
|
||||
PRInt32 nLength = 0;
|
||||
if (mChannel)
|
||||
mChannel->GetContentLength(&nLength);
|
||||
|
||||
if (nLength < 0)
|
||||
nLength = 0;
|
||||
|
||||
statstg->cbSize.QuadPart = nLength;
|
||||
statstg->cbSize.LowPart = (DWORD)nLength;
|
||||
statstg->grfMode = STGM_READ;
|
||||
statstg->grfLocksSupported = LOCK_ONLYONCE;
|
||||
statstg->clsid = CLSID_NULL;
|
||||
|
|
|
@ -1279,7 +1279,8 @@ nsXPInstallManager::OnProgress(nsIRequest* request, nsISupports *ctxt, PRUint64
|
|||
rv = channel->GetContentLength(&mContentLength);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = mDlg->OnProgress( mNextItem-1, aProgress, mContentLength );
|
||||
// XXX once channels support that, use 64-bit contentlength
|
||||
rv = mDlg->OnProgress( mNextItem-1, aProgress, PRUint64(mContentLength) );
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -128,7 +128,7 @@ class nsXPInstallManager : public nsIXPIDialogService,
|
|||
nsXPITriggerItem* mItem;
|
||||
PRUint32 mNextItem;
|
||||
PRUint32 mChromeType;
|
||||
PRInt64 mContentLength;
|
||||
PRInt32 mContentLength;
|
||||
PRInt32 mOutstandingCertLoads;
|
||||
PRBool mDialogOpen;
|
||||
PRBool mCancelled;
|
||||
|
|
Загрузка…
Ссылка в новой задаче