bug 264599 make unfrozen necko interfaces use 64-bit integers.

r=darin sr=bz a=asa
This commit is contained in:
cbiesinger%web.de 2005-01-09 20:43:35 +00:00
Родитель cc840713ca
Коммит 8bf7cd6391
65 изменённых файлов: 376 добавлений и 669 удалений

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

@ -462,8 +462,10 @@ nsWyciwygChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctx,
rv = mListener->OnDataAvailable(this, mListenerContext, input, offset, count);
// XXX handle 64-bit stuff for real
if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND))
mProgressSink->OnProgress(this, nsnull, offset + count, mContentLength);
mProgressSink->OnProgress(this, nsnull, nsUint64(offset + count),
nsUint64(mContentLength));
return rv; // let the pump cancel on failure
}
@ -577,7 +579,7 @@ nsWyciwygChannel::ReadFromCache()
return rv;
NS_ENSURE_TRUE(mCacheInputStream, NS_ERROR_UNEXPECTED);
rv = NS_NewInputStreamPump(getter_AddRefs(mPump), mCacheInputStream, -1);
rv = NS_NewInputStreamPump(getter_AddRefs(mPump), mCacheInputStream);
if (NS_FAILED(rv)) return rv;
// Pump the cache data downstream

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

@ -59,6 +59,7 @@
#include "nsIStringEnumerator.h"
#include "nsCRT.h"
#include "nsSupportsArray.h"
#include "nsInt64.h"
#include "nsCExternalHandlerService.h"
@ -145,8 +146,8 @@ struct OutputData
nsCOMPtr<nsIURI> mFile;
nsCOMPtr<nsIURI> mOriginalLocation;
nsCOMPtr<nsIOutputStream> mStream;
PRInt32 mSelfProgress;
PRInt32 mSelfProgressMax;
nsInt64 mSelfProgress;
nsInt64 mSelfProgressMax;
PRPackedBool mCalcFileExt;
OutputData(nsIURI *aFile, nsIURI *aOriginalLocation, PRBool aCalcFileExt) :
@ -169,8 +170,8 @@ struct OutputData
struct UploadData
{
nsCOMPtr<nsIURI> mFile;
PRInt32 mSelfProgress;
PRInt32 mSelfProgressMax;
nsInt64 mSelfProgress;
nsInt64 mSelfProgressMax;
UploadData(nsIURI *aFile) :
mFile(aFile),
@ -924,8 +925,8 @@ NS_IMETHODIMP nsWebBrowserPersist::OnDataAvailable(
/* void onProgress (in nsIRequest request, in nsISupports ctxt,
in unsigned long aProgress, in unsigned long aProgressMax); */
NS_IMETHODIMP nsWebBrowserPersist::OnProgress(
nsIRequest *request, nsISupports *ctxt, PRUint32 aProgress,
PRUint32 aProgressMax)
nsIRequest *request, nsISupports *ctxt, PRUint64 aProgress,
PRUint64 aProgressMax)
{
if (!mProgressListener)
{
@ -938,23 +939,24 @@ NS_IMETHODIMP nsWebBrowserPersist::OnProgress(
OutputData *data = (OutputData *) mOutputMap.Get(&key);
if (data)
{
data->mSelfProgress = aProgress;
data->mSelfProgressMax = aProgressMax;
data->mSelfProgress = PRInt64(aProgress);
data->mSelfProgressMax = PRInt64(aProgressMax);
}
else
{
UploadData *upData = (UploadData *) mUploadList.Get(&key);
if (upData)
{
upData->mSelfProgress = aProgress;
upData->mSelfProgressMax = aProgressMax;
upData->mSelfProgress = PRInt64(aProgress);
upData->mSelfProgressMax = PRInt64(aProgressMax);
}
}
// Notify listener of total progress
CalcTotalProgress();
mProgressListener->OnProgressChange(nsnull, request, aProgress,
aProgressMax, mTotalCurrentProgress, mTotalMaxProgress);
// XXX this truncates 64-bit to 32bit
mProgressListener->OnProgressChange(nsnull, request, nsUint64(aProgress),
nsUint64(aProgressMax), mTotalCurrentProgress, mTotalMaxProgress);
return NS_OK;
@ -2371,7 +2373,7 @@ nsWebBrowserPersist::CalcTotalProgress()
}
// XXX this code seems pretty bogus and pointless
if (mTotalCurrentProgress == 0 && mTotalMaxProgress == 0)
if (mTotalCurrentProgress == LL_ZERO && mTotalMaxProgress == LL_ZERO)
{
// No output streams so we must be complete
mTotalCurrentProgress = 10000;

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

@ -58,6 +58,7 @@
#include "nsHashtable.h"
#include "nsVoidArray.h"
#include "nsInt64.h"
#include "nsCWebBrowserPersist.h"
@ -211,8 +212,8 @@ private:
PRPackedBool mSerializingOutput;
PRUint32 mPersistFlags;
PRUint32 mPersistResult;
PRInt32 mTotalCurrentProgress;
PRInt32 mTotalMaxProgress;
nsInt64 mTotalCurrentProgress;
nsInt64 mTotalMaxProgress;
PRInt16 mWrapColumn;
PRUint32 mEncodingFlags;
nsString mContentType;

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

@ -376,8 +376,10 @@ GeckoProtocolChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aCont
mListenerContext = aContext;
mListener = aListener;
// XXX should this use 64-bit content lengths?
nsresult rv = NS_NewInputStreamPump(
getter_AddRefs(mPump), mContentStream, -1, mContentLength, 0, 0, PR_TRUE);
getter_AddRefs(mPump), mContentStream, nsInt64(-1),
nsInt64(mContentLength), 0, 0, PR_TRUE);
if (NS_FAILED(rv)) return rv;
if (mLoadGroup)
@ -542,8 +544,10 @@ GeckoProtocolChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
rv = mListener->OnDataAvailable(this, mListenerContext, stream, offset, count);
// XXX can this use real 64-bit ints?
if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND))
mProgressSink->OnProgress(this, nsnull, offset + count, mContentLength);
mProgressSink->OnProgress(this, nsnull, nsUint64(offset + count),
nsUint64(mContentLength));
return rv; // let the pump cancel on failure
}

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

@ -412,11 +412,11 @@ nsDateTimeChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
NS_IMETHODIMP
nsDateTimeChannel::OnTransportStatus(nsITransport *trans, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
// suppress status notification if channel is no longer pending!
if (mProgressSink && NS_SUCCEEDED(mStatus) && mPump && !(mLoadFlags & LOAD_BACKGROUND)) {
NS_ConvertUTF8toUCS2 host(mHost);
NS_ConvertUTF8toUTF16 host(mHost);
mProgressSink->OnStatus(this, nsnull, status, host.get());
if (status == nsISocketTransport::STATUS_RECEIVING_FROM ||

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

@ -434,12 +434,12 @@ nsFingerChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
NS_IMETHODIMP
nsFingerChannel::OnTransportStatus(nsITransport *trans, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
// suppress status notification if channel is no longer pending!
if (mProgressSink && NS_SUCCEEDED(mStatus) && mPump && !(mLoadFlags & LOAD_BACKGROUND)) {
mProgressSink->OnStatus(this, nsnull, status,
NS_ConvertUTF8toUCS2(mHost).get());
NS_ConvertUTF8toUTF16(mHost).get());
if (status == nsISocketTransport::STATUS_RECEIVING_FROM ||
status == nsISocketTransport::STATUS_SENDING_TO) {

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

@ -1824,7 +1824,7 @@ nsXMLHttpRequest::OnRedirect(nsIHttpChannel *aHttpChannel,
//
NS_IMETHODIMP
nsXMLHttpRequest::OnProgress(nsIRequest *aRequest, nsISupports *aContext, PRUint32 aProgress, PRUint32 aProgressMax)
nsXMLHttpRequest::OnProgress(nsIRequest *aRequest, nsISupports *aContext, PRUint64 aProgress, PRUint64 aProgressMax)
{
if (mOnProgressListener)
{
@ -1893,7 +1893,7 @@ nsHeaderVisitor::VisitHeader(const nsACString &header, const nsACString &value)
}
// DOM event class to handle progress notifications
nsXMLHttpProgressEvent::nsXMLHttpProgressEvent(nsIDOMEvent * aInner, PRUint32 aCurrentProgress, PRUint32 aMaxProgress)
nsXMLHttpProgressEvent::nsXMLHttpProgressEvent(nsIDOMEvent * aInner, PRUint64 aCurrentProgress, PRUint64 aMaxProgress)
{
mInner = aInner;
mCurProgress = aCurrentProgress;
@ -1922,13 +1922,15 @@ NS_IMETHODIMP nsXMLHttpProgressEvent::GetInput(nsIDOMLSInput * *aInput)
NS_IMETHODIMP nsXMLHttpProgressEvent::GetPosition(PRUint32 *aPosition)
{
*aPosition = mCurProgress;
// XXX can we change the iface?
LL_L2UI(*aPosition, mCurProgress);
return NS_OK;
}
NS_IMETHODIMP nsXMLHttpProgressEvent::GetTotalSize(PRUint32 *aTotalSize)
{
*aTotalSize = mMaxProgress;
// XXX can we change the iface?
LL_L2UI(*aTotalSize, mMaxProgress);
return NS_OK;
}

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

@ -184,7 +184,7 @@ protected:
class nsXMLHttpProgressEvent : public nsIDOMLSProgressEvent
{
public:
nsXMLHttpProgressEvent(nsIDOMEvent * aInner, PRUint32 aCurrentProgress, PRUint32 aMaxProgress);
nsXMLHttpProgressEvent(nsIDOMEvent * aInner, PRUint64 aCurrentProgress, PRUint64 aMaxProgress);
virtual ~nsXMLHttpProgressEvent();
NS_DECL_ISUPPORTS
@ -193,8 +193,8 @@ public:
protected:
nsCOMPtr<nsIDOMEvent> mInner;
PRUint32 mCurProgress;
PRUint32 mMaxProgress;
PRUint64 mCurProgress;
PRUint64 mMaxProgress;
};
#endif

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

@ -44,6 +44,7 @@
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsNetError.h"
#include "nsInt64.h"
NS_IMPL_THREADSAFE_ADDREF(nsMsgProgress)
NS_IMPL_THREADSAFE_RELEASE(nsMsgProgress)
@ -361,11 +362,12 @@ NS_IMETHODIMP nsMsgProgress::GetMsgWindow(nsIMsgWindow **aMsgWindow)
NS_IMETHODIMP nsMsgProgress::OnProgress(nsIRequest *request, nsISupports* ctxt,
PRUint32 aProgress, PRUint32 aProgressMax)
PRUint64 aProgress, PRUint64 aProgressMax)
{
// XXX: What should the nsIWebProgress be?
return OnProgressChange(nsnull, request, aProgress, aProgressMax,
aProgress /* current total progress */, aProgressMax /* max total progress */);
// XXX: This truncates 64-bit to 32-bit
return OnProgressChange(nsnull, request, nsUint64(aProgress), nsUint64(aProgressMax),
nsUint64(aProgress) /* current total progress */, nsUint64(aProgressMax) /* max total progress */);
}
NS_IMETHODIMP nsMsgProgress::OnStatus(nsIRequest *request, nsISupports* ctxt,

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

@ -52,6 +52,7 @@
#include "nsIDocShellTreeItem.h"
#include "nsIChannel.h"
#include "prinrval.h"
#include "nsInt64.h"
#include "nsITimelineService.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsIMimeMiscStatus.h"
@ -318,11 +319,12 @@ NS_IMETHODIMP nsMsgStatusFeedback::SetDocShell(nsIDocShell *shell, nsIDOMWindow
}
NS_IMETHODIMP nsMsgStatusFeedback::OnProgress(nsIRequest *request, nsISupports* ctxt,
PRUint32 aProgress, PRUint32 aProgressMax)
PRUint64 aProgress, PRUint64 aProgressMax)
{
// XXX: What should the nsIWebProgress be?
return OnProgressChange(nsnull, request, aProgress, aProgressMax,
aProgress /* current total progress */, aProgressMax /* max total progress */);
// XXX: this truncates 64-bit to 32-bit
return OnProgressChange(nsnull, request, nsUint64(aProgress), nsUint64(aProgressMax),
nsUint64(aProgress) /* current total progress */, nsUint64(aProgressMax) /* max total progress */);
}
NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIRequest *request, nsISupports* ctxt,

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

@ -246,7 +246,9 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, PRUint32 aStartPosition, P
do_GetService(kStreamTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = sts->CreateInputTransport(stream, aStartPosition, aReadCount, PR_TRUE, getter_AddRefs(m_transport));
rv = sts->CreateInputTransport(stream, nsInt64(aStartPosition),
nsInt64(aReadCount), PR_TRUE,
getter_AddRefs(m_transport));
m_socketIsOpen = PR_FALSE;
return rv;
@ -468,7 +470,7 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
nsCOMPtr<nsIInputStreamPump> pump;
rv = NS_NewInputStreamPump(getter_AddRefs(pump),
m_inputStream, -1, m_readCount);
m_inputStream, nsInt64(-1), m_readCount);
if (NS_FAILED(rv)) return rv;
m_request = pump; // keep a reference to the pump so we can cancel it
@ -656,7 +658,7 @@ nsMsgProtocol::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCall
NS_IMETHODIMP
nsMsgProtocol::OnTransportStatus(nsITransport *transport, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
if ((mLoadFlags & LOAD_BACKGROUND) || !m_url)
return NS_OK;

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

@ -5927,7 +5927,10 @@ nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol,
nsCOMPtr<nsIRequest> request = do_QueryInterface(mockChannel);
if (!request) return NS_ERROR_FAILURE;
progressSink->OnProgress(request, nsnull, aInfo->currentProgress, aInfo->maxProgress);
// XXX handle 64-bit ints for real
progressSink->OnProgress(request, nsnull,
nsUint64(aInfo->currentProgress),
nsUint64(aInfo->maxProgress));
if (aInfo->message)
progressSink->OnStatus(request, nsnull, NS_OK, aInfo->message); // XXX i18n message

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

@ -8179,8 +8179,10 @@ PRBool nsImapMockChannel::ReadFromLocalCache()
cacheListener->Init(m_channelListener, this);
// create a stream pump that will async read the specified amount of data.
// XXX make offset/size 64-bit ints
nsCOMPtr<nsIInputStreamPump> pump;
rv = NS_NewInputStreamPump(getter_AddRefs(pump), fileStream, offset, size);
rv = NS_NewInputStreamPump(getter_AddRefs(pump), fileStream,
nsInt64(offset), nsInt64(size));
if (NS_SUCCEEDED(rv))
rv = pump->AsyncRead(cacheListener, m_channelContext);
@ -8448,7 +8450,7 @@ nsImapMockChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotification
NS_IMETHODIMP
nsImapMockChannel::OnTransportStatus(nsITransport *transport, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
if (NS_FAILED(m_cancelStatus) || (mLoadFlags & LOAD_BACKGROUND) || !m_url)
return NS_OK;

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

@ -133,7 +133,10 @@ nsresult nsMailboxProtocol::OpenMultipleMsgTransport(PRUint32 offset, PRInt32 si
do_GetService(kStreamTransportServiceCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = serv->CreateInputTransport(m_multipleMsgMoveCopyStream, offset, size, PR_FALSE, getter_AddRefs(m_transport));
// XXX 64-bit
rv = serv->CreateInputTransport(m_multipleMsgMoveCopyStream, nsInt64(offset),
nsInt64(size), PR_FALSE,
getter_AddRefs(m_transport));
return rv;
}
@ -656,7 +659,10 @@ PRInt32 nsMailboxProtocol::ReadMessageResponse(nsIInputStream * inputStream, PRU
{
PRInt32 contentLength = 0;
GetContentLength(&contentLength);
mProgressEventSink->OnProgress(this, m_channelContext, mCurrentProgress, contentLength);
// XXX 64-bit
mProgressEventSink->OnProgress(this, m_channelContext,
nsUint64(mCurrentProgress),
nsUint64(contentLength));
}
if (NS_FAILED(rv)) return -1;

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

@ -673,8 +673,9 @@ void nsPop3Protocol::UpdateStatusWithString(const PRUnichar * aStatusString)
void nsPop3Protocol::UpdateProgressPercent (PRUint32 totalDone, PRUint32 total)
{
// XXX 64-bit
if (mProgressEventSink)
mProgressEventSink->OnProgress(this, m_channelContext, (PRInt32) totalDone, (PRInt32) total);
mProgressEventSink->OnProgress(this, m_channelContext, nsUint64(totalDone), nsUint64(total));
}
// note: SetUsername() expects an unescaped string

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

@ -839,9 +839,10 @@ PRBool nsNNTPProtocol::ReadFromLocalCache()
cacheListener->Init(m_channelListener, NS_STATIC_CAST(nsIChannel *, this), mailnewsUrl);
// create a stream pump that will async read the specified amount of data.
// XXX make offset and size 64-bit ints
nsCOMPtr<nsIInputStreamPump> pump;
rv = NS_NewInputStreamPump(getter_AddRefs(pump),
fileStream, offset, size);
fileStream, nsInt64(offset), nsInt64(size));
if (NS_SUCCEEDED(rv))
rv = pump->AsyncRead(cacheListener, m_channelContext);
@ -5344,8 +5345,10 @@ nsresult nsNNTPProtocol::CloseSocket()
void nsNNTPProtocol::SetProgressBarPercent(PRUint32 aProgress, PRUint32 aProgressMax)
{
// XXX 64-bit
if (mProgressEventSink)
mProgressEventSink->OnProgress(this, m_channelContext, aProgress, aProgressMax);
mProgressEventSink->OnProgress(this, m_channelContext, nsUint64(aProgress),
nsUint64(aProgressMax));
}
nsresult

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

@ -40,6 +40,7 @@
#include "nsJARProtocolHandler.h"
#include "nsMimeTypes.h"
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
@ -715,8 +716,10 @@ nsJARChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
// simply report progress here instead of hooking ourselves up as a
// nsITransportEventSink implementation.
// XXX do the 64-bit stuff for real
if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND))
mProgressSink->OnProgress(this, nsnull, offset + count, mContentLength);
mProgressSink->OnProgress(this, nsnull, nsUint64(offset + count),
nsUint64(mContentLength));
return rv; // let the pump cancel on failure
}

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

@ -52,6 +52,7 @@
#include "nsIStringStream.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsIFile.h"
#include "nsIFileURL.h"
#include "nsIMIMEService.h"
@ -413,7 +414,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
return rv;
// Init our streampump
rv = mPump->Init(inStream, -1, -1, 0, 0, PR_FALSE);
rv = mPump->Init(inStream, nsInt64(-1), nsInt64(-1), 0, 0, PR_FALSE);
if (NS_FAILED(rv))
return rv;

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

@ -52,6 +52,7 @@
#include "nsIStringStream.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsIFile.h"
#include "nsIFileURL.h"
#include "nsIMIMEService.h"
@ -222,7 +223,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
return rv;
// Init our streampump
rv = mPump->Init(inStream, -1, -1, 0, 0, PR_FALSE);
rv = mPump->Init(inStream, nsInt64(-1), nsInt64(-1), 0, 0, PR_FALSE);
if (NS_FAILED(rv))
return rv;

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

@ -2103,8 +2103,8 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest *request,
nsISupports* aContext,
PRUint32 aProgress,
PRUint32 aProgressMax)
PRUint64 aProgress,
PRUint64 aProgressMax)
{
nsresult rv = NS_OK;
return rv;
@ -2187,12 +2187,15 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request,
{
// get the absolute offset of the request, if one exists.
nsCOMPtr<nsIByteRangeRequest> brr = do_QueryInterface(request);
PRInt32 absoluteOffset = 0;
if (brr) {
if (!mDataForwardToRequest)
return NS_ERROR_FAILURE;
brr->GetStartRange(&absoluteOffset);
PRInt64 absoluteOffset64 = LL_ZERO;
brr->GetStartRange(&absoluteOffset64);
// XXX handle 64-bit for real
PRInt32 absoluteOffset = (PRInt32)nsInt64(absoluteOffset64);
// we need to track how much data we have forwarded to the
// plugin.
@ -2263,8 +2266,10 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request,
// for ByteRangeRequest we're just updating the mDataForwardToRequest hash and return.
nsCOMPtr<nsIByteRangeRequest> brr = do_QueryInterface(request);
if (brr) {
PRInt32 absoluteOffset = 0;
brr->GetStartRange(&absoluteOffset);
PRInt64 absoluteOffset64 = LL_ZERO;
brr->GetStartRange(&absoluteOffset64);
// XXX support 64-bit offsets
PRInt32 absoluteOffset = (PRInt32)nsInt64(absoluteOffset64);
nsPRUintKey key(absoluteOffset);

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

@ -38,7 +38,7 @@
#include "nsISupports.idl"
[scriptable, uuid(39befdb9-fa76-469b-85dc-a617b81f26eb)]
[scriptable, uuid(C1B1F426-7E83-4759-9F88-0E1B17F49366)]
interface nsIByteRangeRequest : nsISupports
{
/**
@ -51,10 +51,10 @@ interface nsIByteRangeRequest : nsISupports
/**
* Absolute start position in remote file for this request.
*/
readonly attribute long startRange;
readonly attribute long long startRange;
/**
* Absolute end postion in remote file for this request
*/
readonly attribute long endRange;
readonly attribute long long endRange;
};

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

@ -42,7 +42,7 @@ interface nsIFile;
/**
* A channel may optionally implement this interface to allow clients
* to effect its behavior with respect to how it uses the cache service.
* to affect its behavior with respect to how it uses the cache service.
*
* This interface provides:
* 1) Support for "stream as file" semantics (for JAR and plugins).

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

@ -49,7 +49,7 @@ interface nsIContentSniffer : nsISupports
* @param aData Data to check
* @param aLength Length of the data
*
* @throw NS_ERROR_NOT_AVAILABLE if no MIME type could be determinted.
* @throw NS_ERROR_NOT_AVAILABLE if no MIME type could be determined.
*/
ACString getMIMETypeFromContent([const,array,size_is(aLength)] in octet aData,
in unsigned long aLength);

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

@ -20,6 +20,7 @@
*
* Contributor(s):
* Darin Fisher <darin@netscape.com>
* Christian Biesinger <cbiesinger@web.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -54,7 +55,7 @@ interface nsIStreamListener;
* the stream will be read on a background thread utilizing the stream
* transport service. More details are provided below.
*/
[scriptable, uuid(f7dd8d87-efa7-48cc-9d94-df488df0b3f9)]
[scriptable, uuid(400F5468-97E7-4d2b-9C65-A82AECC7AE82)]
interface nsIInputStreamPump : nsIRequest
{
/**
@ -85,8 +86,8 @@ interface nsIInputStreamPump : nsIRequest
* if true, the input stream will be closed after it has been read.
*/
void init(in nsIInputStream aStream,
in long aStreamPos,
in long aStreamLen,
in long long aStreamPos,
in long long aStreamLen,
in unsigned long aSegmentSize,
in unsigned long aSegmentCount,
in boolean aCloseWhenDone);

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

@ -61,7 +61,7 @@ interface nsIMIMEInputStream : nsIInputStream
* @param name name of the header
* @param value value of the header
*/
void addHeader([const] in string name, [const] in string value);
void addHeader(in string name, in string value);
/**
* Sets data-stream. May not be called once the stream has been started

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

@ -61,7 +61,7 @@ interface nsIRequest;
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(dd47ee00-18c2-11d3-9337-00104ba0fd40)]
[scriptable, uuid(D974C99E-4148-4df9-8D98-DE834A2F6462)]
interface nsIProgressEventSink : nsISupports
{
/**
@ -78,12 +78,12 @@ interface nsIProgressEventSink : nsISupports
* number of bytes transfered thus far.
* @param aProgressMax
* numeric value indicating maximum number of bytes that will be
* transfered (or 0xFFFFFFFF if total is unknown).
* transfered (or 0xFFFFFFFFFFFFFFFF if total is unknown).
*/
void onProgress(in nsIRequest aRequest,
in nsISupports aContext,
in unsigned long aProgress,
in unsigned long aProgressMax);
in unsigned long long aProgress,
in unsigned long long aProgressMax);
/**
* Called to notify the event sink with a status message for the given

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

@ -46,7 +46,7 @@ interface nsISecurityEventSink : nsISupports
* Fired when a security change occurs due to page transitions,
* or end document load. This interface should be called by
* a security package (eg Netscape Personal Security Manager)
* to notify nwIWebProgressListeners that security state has
* to notify nsIWebProgressListeners that security state has
* changed. State flags are in nsIWebProgressListener.idl
*/

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

@ -56,6 +56,8 @@ interface nsIStreamLoaderObserver : nsISupports
/**
* Asynchronously loads a channel into a memory buffer.
*
* XXX define behaviour for sizes >4 GB
*/
[scriptable, uuid(31d37360-8e5a-11d3-93ad-00104ba0fd40)]
interface nsIStreamLoader : nsISupports

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

@ -48,7 +48,7 @@ interface nsIOutputStream;
* into a fully asynchronous stream that can be read/written without
* blocking the main thread.
*/
[scriptable, uuid(3e0f7a3b-65fd-4e10-92f3-56a8f4622f55)]
[scriptable, uuid(8268D474-EFBF-494f-A152-E8A8616F4E52)]
interface nsIStreamTransportService : nsISupports
{
/**
@ -71,8 +71,8 @@ interface nsIStreamTransportService : nsISupports
* @return nsITransport instance.
*/
nsITransport createInputTransport(in nsIInputStream aStream,
in long aStartOffset,
in long aReadLimit,
in long long aStartOffset,
in long long aReadLimit,
in boolean aCloseWhenDone);
/**
@ -95,7 +95,7 @@ interface nsIStreamTransportService : nsISupports
* @return nsITransport instance.
*/
nsITransport createOutputTransport(in nsIOutputStream aStream,
in long aStartOffset,
in long aWriteLimit,
in long long aStartOffset,
in long long aWriteLimit,
in boolean aCloseWhenDone);
};

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

@ -166,7 +166,7 @@ interface nsITransport : nsISupports
const unsigned long STATUS_WRITING = 0x804b0009;
};
[scriptable, uuid(561de8af-1b74-4cd4-8479-89447d48185c)]
[scriptable, uuid(EDA4F520-67F7-484b-A691-8C3226A5B0A6)]
interface nsITransportEventSink : nsISupports
{
/**
@ -187,6 +187,6 @@ interface nsITransportEventSink : nsISupports
*/
void onTransportStatus(in nsITransport aTransport,
in nsresult aStatus,
in unsigned long aProgress,
in unsigned long aProgressMax);
in unsigned long long aProgress,
in unsigned long long aProgressMax);
};

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

@ -85,6 +85,7 @@
#include "nsIPersistentProperties2.h"
#include "nsISyncStreamListener.h"
#include "nsInterfaceRequestorAgg.h"
#include "nsInt64.h"
// Helper, to simplify getting the I/O service.
inline const nsGetServiceByCIDWithError
@ -333,8 +334,8 @@ NS_NewInputStreamChannel(nsIChannel **result,
inline nsresult
NS_NewInputStreamPump(nsIInputStreamPump **result,
nsIInputStream *stream,
PRInt32 streamPos = -1,
PRInt32 streamLen = -1,
PRInt64 streamPos = nsInt64(-1),
PRInt64 streamLen = nsInt64(-1),
PRUint32 segsize = 0,
PRUint32 segcount = 0,
PRBool closeWhenDone = PR_FALSE)
@ -772,7 +773,7 @@ NS_BackgroundInputStream(nsIInputStream **aResult,
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsITransport> inTransport;
rv = sts->CreateInputTransport(aStream, -1, -1, PR_TRUE,
rv = sts->CreateInputTransport(aStream, nsInt64(-1), nsInt64(-1), PR_TRUE,
getter_AddRefs(inTransport));
if (NS_SUCCEEDED(rv))
rv = inTransport->OpenInputStream(nsITransport::OPEN_BLOCKING,
@ -796,7 +797,7 @@ NS_BackgroundOutputStream(nsIOutputStream **aResult,
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsITransport> inTransport;
rv = sts->CreateOutputTransport(aStream, -1, -1, PR_TRUE,
rv = sts->CreateOutputTransport(aStream, nsInt64(-1), nsInt64(-1), PR_TRUE,
getter_AddRefs(inTransport));
if (NS_SUCCEEDED(rv))
rv = inTransport->OpenOutputStream(nsITransport::OPEN_BLOCKING,

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

@ -305,8 +305,11 @@ nsInputStreamChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
if (mContentLength == -1)
mContentStream->Available((PRUint32 *) &mContentLength);
// XXX Once nsIChannel and nsIInputStream (in some future revision)
// support 64-bit content lengths, mContentLength should be made 64-bit
nsresult rv = NS_NewInputStreamPump(getter_AddRefs(mPump), mContentStream,
-1, mContentLength, 0, 0, PR_TRUE);
nsInt64(-1), nsInt64(mContentLength),
0, 0, PR_TRUE);
if (NS_FAILED(rv)) return rv;
rv = mPump->AsyncRead(this, nsnull);
@ -384,8 +387,11 @@ nsInputStreamChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
rv = mListener->OnDataAvailable(this, mListenerContext, stream, offset, count);
// XXX need real 64-bit math here! (probably needs new streamlistener and
// channel ifaces)
if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND))
mProgressSink->OnProgress(this, nsnull, offset + count, mContentLength);
mProgressSink->OnProgress(this, nsnull, nsUint64(offset + count),
nsUint64(mContentLength));
return rv; // let the pump cancel on failure
}

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

@ -214,15 +214,15 @@ nsInputStreamPump::SetLoadGroup(nsILoadGroup *aLoadGroup)
NS_IMETHODIMP
nsInputStreamPump::Init(nsIInputStream *stream,
PRInt32 streamPos, PRInt32 streamLen,
PRInt64 streamPos, PRInt64 streamLen,
PRUint32 segsize, PRUint32 segcount,
PRBool closeWhenDone)
{
NS_ENSURE_TRUE(mState == STATE_IDLE, NS_ERROR_IN_PROGRESS);
mStreamOffset = streamPos;
if (streamLen >= 0)
mStreamLength = streamLen;
mStreamOffset = PRUint64(streamPos);
if (nsInt64(streamLen) >= nsInt64(0))
mStreamLength = PRUint64(streamLen);
mStream = stream;
mSegSize = segsize;
mSegCount = segcount;
@ -271,7 +271,9 @@ nsInputStreamPump::AsyncRead(nsIStreamListener *listener, nsISupports *ctxt)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> transport;
rv = sts->CreateInputTransport(mStream, mStreamOffset, mStreamLength,
// Note: The casts to PRUint64 are needed to cast to PRInt64, as
// nsUint64 can't directly be cast to PRInt64
rv = sts->CreateInputTransport(mStream, PRUint64(mStreamOffset), PRUint64(mStreamLength),
mCloseWhenDone, getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;

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

@ -60,7 +60,7 @@ public:
NS_DECL_NSIINPUTSTREAMCALLBACK
nsInputStreamPump();
virtual ~nsInputStreamPump();
~nsInputStreamPump();
protected:

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

@ -50,6 +50,7 @@
#include "nsAutoLock.h"
#include "nsCOMPtr.h"
#include "netCore.h"
#include "nsInt64.h"
#include "prmem.h"
#include "pratom.h"
#include "plstr.h"
@ -847,7 +848,7 @@ nsSocketTransport::SendStatus(nsresult status)
LOG(("nsSocketTransport::SendStatus [this=%x status=%x]\n", this, status));
nsCOMPtr<nsITransportEventSink> sink;
PRUint32 progress;
PRUint64 progress;
{
nsAutoLock lock(mLock);
sink = mEventSink;
@ -864,7 +865,7 @@ nsSocketTransport::SendStatus(nsresult status)
}
}
if (sink)
sink->OnTransportStatus(this, status, progress, PR_UINT32_MAX);
sink->OnTransportStatus(this, status, progress, LL_MAXUINT);
}
nsresult

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

@ -45,6 +45,7 @@
#include "nsSocketTransportService2.h"
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsInt64.h"
#include "nsISocketTransport.h"
#include "nsIInterfaceRequestor.h"
@ -73,7 +74,7 @@ public:
PRBool IsReferenced() { return mReaderRefCnt > 0; }
nsresult Condition() { return mCondition; }
PRUint32 ByteCount() { return mByteCount; }
PRUint64 ByteCount() { return mByteCount; }
// called by the socket transport on the socket thread...
void OnSocketReady(nsresult condition);
@ -86,7 +87,7 @@ private:
nsresult mCondition;
nsCOMPtr<nsIInputStreamCallback> mCallback;
PRUint32 mCallbackFlags;
PRUint32 mByteCount;
nsUint64 mByteCount;
};
//-----------------------------------------------------------------------------
@ -103,7 +104,7 @@ public:
PRBool IsReferenced() { return mWriterRefCnt > 0; }
nsresult Condition() { return mCondition; }
PRUint32 ByteCount() { return mByteCount; }
PRUint64 ByteCount() { return mByteCount; }
// called by the socket transport on the socket thread...
void OnSocketReady(nsresult condition);
@ -120,7 +121,7 @@ private:
nsresult mCondition;
nsCOMPtr<nsIOutputStreamCallback> mCallback;
PRUint32 mCallbackFlags;
PRUint32 mByteCount;
nsUint64 mByteCount;
};
//-----------------------------------------------------------------------------

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

@ -38,6 +38,7 @@
#include "nsStreamTransportService.h"
#include "nsNetSegmentUtils.h"
#include "nsAutoLock.h"
#include "nsInt64.h"
#include "nsTransportUtils.h"
#include "nsStreamUtils.h"
#include "nsNetError.h"
@ -70,8 +71,8 @@ public:
NS_DECL_NSIINPUTSTREAM
nsInputStreamTransport(nsIInputStream *source,
PRUint32 offset,
PRUint32 limit,
PRUint64 offset,
PRUint64 limit,
PRBool closeWhenDone)
: mSource(source)
, mOffset(offset)
@ -93,8 +94,8 @@ private:
// nsIInputStream implementation.
nsCOMPtr<nsITransportEventSink> mEventSink;
nsCOMPtr<nsIInputStream> mSource;
PRUint32 mOffset;
PRUint32 mLimit;
nsUint64 mOffset;
nsUint64 mLimit;
PRPackedBool mCloseWhenDone;
PRPackedBool mFirstTime;
@ -207,12 +208,14 @@ nsInputStreamTransport::Read(char *buf, PRUint32 count, PRUint32 *result)
{
if (mFirstTime) {
mFirstTime = PR_FALSE;
if (mOffset) {
if (mOffset == nsUint64(0)) {
// read from current position if offset equal to max
if (mOffset != PR_UINT32_MAX) {
if (mOffset != LL_MAXUINT) {
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mSource);
// Note: The casts to PRUint64 are needed to cast to PRInt64, as
// nsUint64 can't directly be cast to PRInt64
if (seekable)
seekable->Seek(nsISeekableStream::NS_SEEK_SET, mOffset);
seekable->Seek(nsISeekableStream::NS_SEEK_SET, PRUint64(mOffset));
}
// reset offset to zero so we can use it to enforce limit
mOffset = 0;
@ -270,8 +273,8 @@ public:
NS_DECL_NSIOUTPUTSTREAM
nsOutputStreamTransport(nsIOutputStream *sink,
PRUint32 offset,
PRUint32 limit,
PRUint64 offset,
PRUint64 limit,
PRBool closeWhenDone)
: mSink(sink)
, mOffset(offset)
@ -293,8 +296,8 @@ private:
// nsIOutputStream implementation.
nsCOMPtr<nsITransportEventSink> mEventSink;
nsCOMPtr<nsIOutputStream> mSink;
PRUint32 mOffset;
PRUint32 mLimit;
nsUint64 mOffset;
nsUint64 mLimit;
PRPackedBool mCloseWhenDone;
PRPackedBool mFirstTime;
@ -407,12 +410,14 @@ nsOutputStreamTransport::Write(const char *buf, PRUint32 count, PRUint32 *result
{
if (mFirstTime) {
mFirstTime = PR_FALSE;
if (mOffset) {
if (!!mOffset) {
// write to current position if offset equal to max
if (mOffset != PR_UINT32_MAX) {
if (mOffset != LL_MAXUINT) {
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mSink);
// Note: The casts to PRUint64 are needed to cast to PRInt64, as
// nsUint64 can't directly be cast to PRInt64
if (seekable)
seekable->Seek(nsISeekableStream::NS_SEEK_SET, mOffset);
seekable->Seek(nsISeekableStream::NS_SEEK_SET, PRUint64(mOffset));
}
// reset offset to zero so we can use it to enforce limit
mOffset = 0;
@ -467,8 +472,8 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsStreamTransportService, nsIStreamTransportServic
NS_IMETHODIMP
nsStreamTransportService::CreateInputTransport(nsIInputStream *stream,
PRInt32 offset,
PRInt32 limit,
PRInt64 offset,
PRInt64 limit,
PRBool closeWhenDone,
nsITransport **result)
{
@ -482,8 +487,8 @@ nsStreamTransportService::CreateInputTransport(nsIInputStream *stream,
NS_IMETHODIMP
nsStreamTransportService::CreateOutputTransport(nsIOutputStream *stream,
PRInt32 offset,
PRInt32 limit,
PRInt64 offset,
PRInt64 limit,
PRBool closeWhenDone,
nsITransport **result)
{

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

@ -87,8 +87,8 @@ public:
nsTransportStatusEvent(nsTransportEventSinkProxy *proxy,
nsITransport *transport,
nsresult status,
PRUint32 progress,
PRUint32 progressMax)
PRUint64 progress,
PRUint64 progressMax)
: mTransport(transport)
, mStatus(status)
, mProgress(progress)
@ -133,8 +133,8 @@ public:
// parameters to OnTransportStatus
nsCOMPtr<nsITransport> mTransport;
nsresult mStatus;
PRUint32 mProgress;
PRUint32 mProgressMax;
PRUint64 mProgress;
PRUint64 mProgressMax;
};
NS_IMPL_THREADSAFE_ISUPPORTS1(nsTransportEventSinkProxy, nsITransportEventSink)
@ -142,8 +142,8 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsTransportEventSinkProxy, nsITransportEventSink)
NS_IMETHODIMP
nsTransportEventSinkProxy::OnTransportStatus(nsITransport *transport,
nsresult status,
PRUint32 progress,
PRUint32 progressMax)
PRUint64 progress,
PRUint64 progressMax)
{
nsresult rv = NS_OK;
PLEvent *event;

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

@ -41,6 +41,7 @@
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsILoadGroup.h"
#include "plbase64.h"
#include "prmem.h"
@ -348,7 +349,7 @@ nsDataChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
mListener = aListener;
mOpened = PR_TRUE;
nsresult rv = mPump->Init(mDataStream, -1, -1, 0, 0, PR_FALSE);
nsresult rv = mPump->Init(mDataStream, nsInt64(-1), nsInt64(-1), 0, 0, PR_FALSE);
if (NS_FAILED(rv))
return rv;

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

@ -398,8 +398,11 @@ nsFileChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
//
// create asynchronous output stream wrapping file output stream.
//
// XXX 64-bit upload length would be nice; it would require a new
// nsIUploadChannel, though.
nsCOMPtr<nsITransport> transport;
rv = sts->CreateOutputTransport(fileOut, -1, mUploadLength, PR_TRUE,
rv = sts->CreateOutputTransport(fileOut, nsInt64(-1),
nsInt64(mUploadLength), PR_TRUE,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
@ -439,7 +442,7 @@ nsFileChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
// create asynchronous input stream wrapping file input stream.
//
nsCOMPtr<nsITransport> transport;
rv = sts->CreateInputTransport(mStream, -1, -1, PR_TRUE,
rv = sts->CreateInputTransport(mStream, nsInt64(-1), nsInt64(-1), PR_TRUE,
getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
@ -563,7 +566,7 @@ nsFileChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
NS_IMETHODIMP
nsFileChannel::OnTransportStatus(nsITransport *trans, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
// suppress status notification if channel is no longer pending!
if (mProgressSink && NS_SUCCEEDED(mStatus) && mRequest && !(mLoadFlags & LOAD_BACKGROUND)) {

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

@ -376,7 +376,7 @@ nsFTPChannel::AsyncOpenAt(nsIStreamListener *listener, nsISupports *ctxt,
}
nsresult
nsFTPChannel::SetupState(PRUint32 startPos, const nsACString& entityID)
nsFTPChannel::SetupState(PRUint64 startPos, const nsACString& entityID)
{
nsCOMPtr<nsIPrompt> prompt;
nsCOMPtr<nsIAuthPrompt> authPrompt;
@ -565,7 +565,7 @@ nsFTPChannel::OnStatus(nsIRequest *request, nsISupports *aContext,
NS_IMETHODIMP
nsFTPChannel::OnProgress(nsIRequest *request, nsISupports* aContext,
PRUint32 aProgress, PRUint32 aProgressMax)
PRUint64 aProgress, PRUint64 aProgressMax)
{
if (!mEventSink || (mLoadFlags & LOAD_BACKGROUND) || !mIsPending)
return NS_OK;

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

@ -103,7 +103,7 @@ public:
nsIProxyInfo* proxyInfo,
nsICacheSession* session);
nsresult SetupState(PRUint32 startPos, const nsACString& entityID);
nsresult SetupState(PRUint64 startPos, const nsACString& entityID);
nsresult GenerateCacheKey(nsACString &cacheKey);
nsresult AsyncOpenAt(nsIStreamListener *listener, nsISupports *ctxt,

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

@ -114,7 +114,7 @@ NS_IMPL_ISUPPORTS1(TransportEventForwarder, nsITransportEventSink)
NS_IMETHODIMP
TransportEventForwarder::OnTransportStatus(nsITransport *transport, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
// We only want to forward the resolving and connecting states of the
// control connection and report the data connection for the rest of the
@ -156,7 +156,7 @@ public:
NS_FORWARD_NSICHANNEL(mFTPChannel->)
NS_FORWARD_NSIFTPCHANNEL(mFTPChannel->)
PRUint32 GetBytesTransfered() {return mBytesTransfered;}
PRUint64 GetBytesTransfered() {return mBytesTransfered;}
void Uploading(PRBool value, PRUint32 uploadCount);
void SetRetrying(PRBool retry);
@ -169,8 +169,8 @@ protected:
nsCOMPtr<nsICacheEntryDescriptor> mCacheEntry;
nsCString mEntityID;
PRUint32 mBytesTransfered;
PRUint32 mBytesToUpload;
nsUint64 mBytesTransfered;
nsUint64 mBytesToUpload;
PRPackedBool mDelayedOnStartFired;
PRPackedBool mUploading;
PRPackedBool mRetrying;
@ -369,6 +369,7 @@ DataRequestForwarder::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, ns
if (NS_FAILED(rv)) return rv;
}
// XXX mBytesTransfered will get truncated from 64-bit to 32-bit
rv = mListener->OnDataAvailable(this, ctxt, input, mBytesTransfered, count);
if (NS_SUCCEEDED(rv))
mBytesTransfered += count;
@ -378,7 +379,7 @@ DataRequestForwarder::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, ns
// nsITransportEventSink methods
NS_IMETHODIMP
DataRequestForwarder::OnTransportStatus(nsITransport *transport, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
if (mEventSink) {
mEventSink->OnStatus(nsnull, nsnull, status, nsnull);
@ -386,8 +387,8 @@ DataRequestForwarder::OnTransportStatus(nsITransport *transport, nsresult status
if (status == nsISocketTransport::STATUS_RECEIVING_FROM ||
status == nsISocketTransport::STATUS_SENDING_TO) {
// compute progress based on whether we are uploading or receiving...
PRUint32 count = mUploading ? progress : mBytesTransfered;
PRUint32 max = mUploading ? mBytesToUpload : progressMax;
PRUint64 count = mUploading ? progress : PRUint64(mBytesTransfered);
PRUint64 max = mUploading ? PRUint64(mBytesToUpload) : progressMax;
mEventSink->OnProgress(this, nsnull, count, max);
}
}
@ -427,7 +428,7 @@ nsFtpState::nsFtpState()
mControlConnection = nsnull;
mDRequestForwarder = nsnull;
mFileSize = LL_MaxUint();
mFileSize = LL_MAXUINT;
// make sure handler stays around
NS_ADDREF(gFtpHandler);
@ -1438,7 +1439,7 @@ nsFtpState::R_mdtm() {
}
// We weren't asked to resume
if (mStartPos == PRUint32(-1))
if (mStartPos == LL_MAXUINT)
return FTP_S_RETR;
//if (our entityID == supplied one (if any))
@ -1497,9 +1498,9 @@ nsFtpState::S_list() {
// dir listings aren't resumable
NS_ASSERTION(mSuppliedEntityID.IsEmpty(),
"Entity ID given to directory request");
NS_ASSERTION(mStartPos == PRUint32(-1) || mStartPos == 0,
NS_ASSERTION(mStartPos == LL_MAXUINT || mStartPos == nsUint64(0),
"Non-initial start position given to directory request");
if (!mSuppliedEntityID.IsEmpty() || (mStartPos != PRUint32(-1) && mStartPos != 0)) {
if (!mSuppliedEntityID.IsEmpty() || (mStartPos != LL_MAXUINT && mStartPos != nsUint64(0))) {
// If we reach this code, then the caller is in error
return NS_ERROR_NOT_RESUMABLE;
}
@ -1596,7 +1597,8 @@ nsresult
nsFtpState::S_rest() {
nsCAutoString restString("REST ");
restString.AppendInt(mStartPos, 10);
// The PRInt64 cast is needed to avoid ambiguity
restString.AppendInt(PRInt64(PRUint64(mStartPos)), 10);
restString.Append(CRLF);
return SendFTPCommand(restString);
@ -1913,7 +1915,8 @@ nsFtpState::R_pasv() {
// pump data to the request forwarder...
nsCOMPtr<nsIInputStreamPump> pump;
rv = NS_NewInputStreamPump(getter_AddRefs(pump), input, -1, -1, 0, 0, PR_TRUE);
rv = NS_NewInputStreamPump(getter_AddRefs(pump), input, nsInt64(-1),
nsInt64(-1), 0, 0, PR_TRUE);
if (NS_FAILED(rv)) {
LOG(("(%x) NS_NewInputStreamPump failed (rv=%x)\n", this, rv));
return FTP_ERROR;
@ -2159,7 +2162,7 @@ nsFtpState::Init(nsIFTPChannel* aChannel,
nsIFTPEventSink* sink,
nsICacheEntryDescriptor* cacheEntry,
nsIProxyInfo* proxyInfo,
PRUint32 startPos,
PRUint64 startPos,
const nsACString& entity)
{
// Build a proxy for the FTP event sink since we may need to call

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

@ -40,6 +40,7 @@
#define __nsFtpState__h_
#include "ftpCore.h"
#include "nsInt64.h"
#include "nsIThread.h"
#include "nsIRunnable.h"
#include "nsISocketTransportService.h"
@ -121,7 +122,7 @@ public:
nsIFTPEventSink *sink,
nsICacheEntryDescriptor* cacheEntry,
nsIProxyInfo* proxyInfo,
PRUint32 startPos,
PRUint64 startPos,
const nsACString& entity);
// use this to provide a stream to be written to the server.
@ -240,7 +241,7 @@ private:
nsCOMPtr<nsICacheEntryDescriptor> mCacheEntry;
PRUint32 mStartPos;
nsUint64 mStartPos;
nsCString mSuppliedEntityID;
nsCString mEntityID;
};

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

@ -718,11 +718,11 @@ nsGopherChannel::PushStreamConverters(nsIStreamListener *listener, nsIStreamList
NS_IMETHODIMP
nsGopherChannel::OnTransportStatus(nsITransport *trans, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
// suppress status notification if channel is no longer pending!
if (mProgressSink && NS_SUCCEEDED(mStatus) && mPump && !(mLoadFlags & LOAD_BACKGROUND)) {
NS_ConvertUTF8toUCS2 host(mHost);
NS_ConvertUTF8toUTF16 host(mHost);
mProgressSink->OnStatus(this, nsnull, status, host.get());
if (status == nsISocketTransport::STATUS_RECEIVING_FROM ||

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

@ -65,7 +65,7 @@ public:
virtual void GetSecurityCallbacks(nsIInterfaceRequestor **) = 0;
// called to report socket status (see nsITransportEventSink)
virtual void OnTransportStatus(nsresult status, PRUint32 progress) = 0;
virtual void OnTransportStatus(nsresult status, PRUint64 progress) = 0;
// called to check the transaction status.
virtual PRBool IsDone() = 0;
@ -89,7 +89,7 @@ public:
#define NS_DECL_NSAHTTPTRANSACTION \
void SetConnection(nsAHttpConnection *); \
void GetSecurityCallbacks(nsIInterfaceRequestor **); \
void OnTransportStatus(nsresult status, PRUint32 progress); \
void OnTransportStatus(nsresult status, PRUint64 progress); \
PRBool IsDone(); \
nsresult Status(); \
PRUint32 Available(); \

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

@ -1568,7 +1568,8 @@ nsHttpChannel::ReadFromCache()
if (NS_FAILED(rv)) return rv;
rv = NS_NewInputStreamPump(getter_AddRefs(mCachePump),
stream, -1, -1, 0, 0, PR_TRUE);
stream, nsInt64(-1), nsInt64(-1), 0, 0,
PR_TRUE);
if (NS_FAILED(rv)) return rv;
return mCachePump->AsyncRead(this, mListenerContext);
@ -3857,11 +3858,11 @@ nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
NS_IMETHODIMP
nsHttpChannel::OnTransportStatus(nsITransport *trans, nsresult status,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
// block socket status event after Cancel or OnStopRequest has been called.
if (mProgressSink && NS_SUCCEEDED(mStatus) && mIsPending && !(mLoadFlags & LOAD_BACKGROUND)) {
LOG(("sending status notification [this=%x status=%x progress=%u/%u]\n",
LOG(("sending status notification [this=%x status=%x progress=%llu/%llu]\n",
this, status, progress, progressMax));
NS_ConvertASCIItoUCS2 host(mConnectionInfo->Host());

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

@ -579,7 +579,8 @@ nsHttpConnection::OnSocketWritable()
// here to reflect the fact that we are waiting. this message will be
// trumped (overwritten) if the server responds quickly.
//
mTransaction->OnTransportStatus(nsISocketTransport::STATUS_WAITING_FOR, 0);
mTransaction->OnTransportStatus(nsISocketTransport::STATUS_WAITING_FOR,
LL_ZERO);
rv = mSocketIn->AsyncWait(this, 0, 0, nsnull); // start reading
again = PR_FALSE;
@ -770,8 +771,8 @@ nsHttpConnection::OnOutputStreamReady(nsIAsyncOutputStream *out)
NS_IMETHODIMP
nsHttpConnection::OnTransportStatus(nsITransport *trans,
nsresult status,
PRUint32 progress,
PRUint32 progressMax)
PRUint64 progress,
PRUint64 progressMax)
{
if (mTransaction)
mTransaction->OnTransportStatus(status, progress);

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

@ -323,9 +323,9 @@ nsHttpPipeline::GetSecurityCallbacks(nsIInterfaceRequestor **result)
}
void
nsHttpPipeline::OnTransportStatus(nsresult status, PRUint32 progress)
nsHttpPipeline::OnTransportStatus(nsresult status, PRUint64 progress)
{
LOG(("nsHttpPipeline::OnStatus [this=%x status=%x progress=%u]\n",
LOG(("nsHttpPipeline::OnStatus [this=%x status=%x progress=%llu]\n",
this, status, progress));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");

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

@ -286,9 +286,9 @@ nsHttpTransaction::GetSecurityCallbacks(nsIInterfaceRequestor **cb)
}
void
nsHttpTransaction::OnTransportStatus(nsresult status, PRUint32 progress)
nsHttpTransaction::OnTransportStatus(nsresult status, PRUint64 progress)
{
LOG(("nsHttpTransaction::OnSocketStatus [this=%x status=%x progress=%u]\n",
LOG(("nsHttpTransaction::OnSocketStatus [this=%x status=%x progress=%llu]\n",
this, status, progress));
if (!mTransportSink)
@ -300,7 +300,7 @@ nsHttpTransaction::OnTransportStatus(nsresult status, PRUint32 progress)
if (status == nsISocketTransport::STATUS_RECEIVING_FROM)
return;
PRUint32 progressMax;
nsUint64 progressMax;
if (status == nsISocketTransport::STATUS_SENDING_TO) {
// suppress progress when only writing request headers
@ -309,10 +309,10 @@ nsHttpTransaction::OnTransportStatus(nsresult status, PRUint32 progress)
// when uploading, we include the request headers in the progress
// notifications.
progressMax = mRequestSize;
progressMax = mRequestSize; // XXX mRequestSize is 32-bit!
}
else {
progress = 0;
progress = LL_ZERO;
progressMax = 0;
}
@ -833,7 +833,7 @@ nsHttpTransaction::HandleContent(char *buf,
if (*contentRead) {
// update count of content bytes read and report progress...
mContentRead += *contentRead;
/*
/* when uncommenting, take care of 64-bit integers w/ PR_MAX...
if (mProgressSink)
mProgressSink->OnProgress(nsnull, nsnull, mContentRead, PR_MAX(0, mContentLength));
*/

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

@ -37,6 +37,7 @@
#include "nsMultiMixedConv.h"
#include "nsMemory.h"
#include "nsInt64.h"
#include "plstr.h"
#include "nsIHttpChannel.h"
#include "nsIServiceManager.h"
@ -80,7 +81,7 @@ class nsPartChannel : public nsIChannel,
public:
nsPartChannel(nsIChannel *aMultipartChannel);
void InitializeByteRange(PRInt32 aStart, PRInt32 aEnd);
void InitializeByteRange(PRInt64 aStart, PRInt64 aEnd);
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUEST
@ -102,16 +103,16 @@ protected:
nsCString mContentType;
nsCString mContentCharset;
nsCString mContentDisposition;
PRInt32 mContentLength;
nsUint64 mContentLength;
PRBool mIsByteRangeRequest;
PRInt32 mByteRangeStart;
PRInt32 mByteRangeEnd;
nsInt64 mByteRangeStart;
nsInt64 mByteRangeEnd;
};
nsPartChannel::nsPartChannel(nsIChannel *aMultipartChannel) :
mStatus(NS_OK),
mContentLength(-1),
mContentLength(LL_MAXUINT),
mIsByteRangeRequest(PR_FALSE),
mByteRangeStart(0),
mByteRangeEnd(0)
@ -128,7 +129,7 @@ nsPartChannel::~nsPartChannel()
{
}
void nsPartChannel::InitializeByteRange(PRInt32 aStart, PRInt32 aEnd)
void nsPartChannel::InitializeByteRange(PRInt64 aStart, PRInt64 aEnd)
{
mIsByteRangeRequest = PR_TRUE;
@ -341,7 +342,7 @@ nsPartChannel::SetContentCharset(const nsACString &aContentCharset)
NS_IMETHODIMP
nsPartChannel::GetContentLength(PRInt32 *aContentLength)
{
*aContentLength = mContentLength;
*aContentLength = mContentLength; // XXX truncates 64-bit value
return NS_OK;
}
@ -380,7 +381,7 @@ nsPartChannel::GetIsByteRangeRequest(PRBool *aIsByteRangeRequest)
NS_IMETHODIMP
nsPartChannel::GetStartRange(PRInt32 *aStartRange)
nsPartChannel::GetStartRange(PRInt64 *aStartRange)
{
*aStartRange = mByteRangeStart;
@ -388,7 +389,7 @@ nsPartChannel::GetStartRange(PRInt32 *aStartRange)
}
NS_IMETHODIMP
nsPartChannel::GetEndRange(PRInt32 *aEndRange)
nsPartChannel::GetEndRange(PRInt64 *aEndRange)
{
*aEndRange = mByteRangeEnd;
return NS_OK;
@ -576,7 +577,7 @@ nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context,
mNewPart = PR_TRUE;
// Reset state so we don't carry it over from part to part
mContentType.Truncate();
mContentLength = -1;
mContentLength = LL_MAXUINT;
mContentDisposition.Truncate();
mIsByteRangeRequest = PR_FALSE;
mByteRangeStart = 0;
@ -719,7 +720,7 @@ nsMultiMixedConv::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
nsMultiMixedConv::nsMultiMixedConv() {
mTokenLen = 0;
mNewPart = PR_TRUE;
mContentLength = -1;
mContentLength = LL_MAXUINT;
mBuffer = nsnull;
mBufLen = 0;
mProcessingHeaders = PR_FALSE;
@ -779,7 +780,7 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) {
rv = mPartChannel->SetContentType(mContentType);
if (NS_FAILED(rv)) return rv;
rv = mPartChannel->SetContentLength(mContentLength);
rv = mPartChannel->SetContentLength(mContentLength); // XXX Truncates 64-bit!
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMultiPartChannel> partChannel(do_QueryInterface(mPartChannel));
@ -835,10 +836,10 @@ nsMultiMixedConv::SendData(char *aBuffer, PRUint32 aLen) {
if (!mPartChannel) return NS_ERROR_FAILURE; // something went wrong w/ processing
if (mContentLength != -1) {
if (mContentLength != LL_MAXUINT) {
// make sure that we don't send more than the mContentLength
// XXX why? perhaps the Content-Length header was actually wrong!!
if ((aLen + mTotalSent) > PRUint32(mContentLength))
if ((nsUint64(aLen) + mTotalSent) > mContentLength)
aLen = mContentLength - mTotalSent;
if (aLen == 0)
@ -887,7 +888,7 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
PRBool done = PR_FALSE;
PRUint32 lineFeedIncrement = 1;
mContentLength = -1; // XXX what if we were already called?
mContentLength = LL_MAXUINT; // XXX what if we were already called?
while (cursorLen && (newLine = (char *) memchr(cursor, nsCRT::LF, cursorLen))) {
// adjust for linefeeds
if ((newLine > cursor) && (newLine[-1] == nsCRT::CR) ) { // CRLF
@ -924,7 +925,7 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
if (headerStr.LowerCaseEqualsLiteral("content-type")) {
mContentType = headerVal;
} else if (headerStr.LowerCaseEqualsLiteral("content-length")) {
mContentLength = atoi(headerVal.get());
mContentLength = atoi(headerVal.get()); // XXX 64-bit math?
} else if (headerStr.LowerCaseEqualsLiteral("content-disposition")) {
mContentDisposition = headerVal;
} else if (headerStr.LowerCaseEqualsLiteral("set-cookie")) {
@ -958,14 +959,14 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
tmpPtr[0] = '\0';
mByteRangeStart = atoi(range);
mByteRangeStart = atoi(range); // XXX want 64-bit conv
tmpPtr++;
mByteRangeEnd = atoi(tmpPtr);
}
mIsByteRangeRequest = PR_TRUE;
if (mContentLength == -1)
mContentLength = mByteRangeEnd - mByteRangeStart + 1;
if (mContentLength == LL_MAXUINT)
mContentLength = PRUint64(PRInt64(mByteRangeEnd - mByteRangeStart + nsInt64(1)));
}
}
*newLine = tmpChar;

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

@ -43,6 +43,7 @@
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsCOMPtr.h"
#include "nsInt64.h"
#include "nsIByteRangeRequest.h"
#define NS_MULTIMIXEDCONVERTER_CID \
@ -123,18 +124,18 @@ protected:
nsCOMPtr<nsISupports> mContext;
nsCString mContentType;
nsCString mContentDisposition;
PRInt32 mContentLength;
nsUint64 mContentLength;
char *mBuffer;
PRUint32 mBufLen;
PRUint32 mTotalSent;
nsUint64 mTotalSent;
PRBool mFirstOnData; // used to determine if we're in our first OnData callback.
// The following members are for tracking the byte ranges in
// multipart/mixed content which specified the 'Content-Range:'
// header...
PRInt32 mByteRangeStart;
PRInt32 mByteRangeEnd;
nsInt64 mByteRangeStart;
nsInt64 mByteRangeEnd;
PRBool mIsByteRangeRequest;
};

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

@ -1,385 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIComponentRegistrar.h"
#include "nsIFileTransportService.h"
#include "nsITransport.h"
#include "nsIProgressEventSink.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIRequest.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsString.h"
#include "nsIFileStreams.h"
#include "nsIStreamListener.h"
#include "nsIEventQueueService.h"
#include "nsIEventQueue.h"
#include "nsILocalFile.h"
#include "nsNetUtil.h"
#include "prlog.h"
////////////////////////////////////////////////////////////////////////////////
#if defined(PR_LOGGING)
static PRLogModuleInfo *gTestFileTransportLog = nsnull;
#define PRINTF(args) PR_LOG(gTestFileTransportLog, PR_LOG_ALWAYS, args)
#else
#define PRINTF(args)
#endif
#undef PRINTF
#define PRINTF(args) printf args
////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
PRBool gDone = PR_FALSE;
nsIEventQueue* gEventQ = nsnull;
////////////////////////////////////////////////////////////////////////////////
class MyProgressEventSink : public nsIProgressEventSink
, public nsIInterfaceRequestor {
public:
NS_DECL_ISUPPORTS
MyProgressEventSink() { }
NS_IMETHOD OnProgress(nsIRequest *request, nsISupports *ctxt,
PRUint32 progress, PRUint32 progressMax) {
PRINTF(("progress: %u/%u\n", progress, progressMax));
return NS_OK;
}
NS_IMETHOD OnStatus(nsIRequest *request, nsISupports *ctxt,
nsresult status, const PRUnichar *statusArg) {
return NS_OK;
}
NS_IMETHOD GetInterface(const nsIID &iid, void **result) {
if (iid.Equals(NS_GET_IID(nsIProgressEventSink)))
return QueryInterface(iid, result);
return NS_ERROR_NO_INTERFACE;
}
};
NS_IMPL_THREADSAFE_ISUPPORTS2(MyProgressEventSink,
nsIProgressEventSink,
nsIInterfaceRequestor)
////////////////////////////////////////////////////////////////////////////////
class MyListener : public nsIStreamListener {
public:
NS_DECL_ISUPPORTS
NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) {
PRINTF(("starting\n"));
return NS_OK;
}
NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt,
nsresult aStatus) {
PRINTF(("ending status=%0x total=%d\n", aStatus, mTotal));
if (--mStopCount == 0)
gDone = PR_TRUE;
return NS_OK;
}
NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
nsIInputStream *inStr, PRUint32 sourceOffset,
PRUint32 count) {
PRINTF(("receiving %d bytes\n", count));
char buf[256];
PRUint32 writeCount, givenCount=count;
nsresult rv;
while (count > 0) {
PRUint32 amt = PR_MIN(count, 256);
PRUint32 readCount;
rv = inStr->Read(buf, amt, &readCount);
if (NS_FAILED(rv)) return rv;
NS_ASSERTION(readCount != 0, "premature EOF");
rv = mOut->Write(buf, readCount, &writeCount);
if (NS_FAILED(rv)) return rv;
NS_ASSERTION(writeCount == readCount, "failed to write all the data");
count -= readCount;
mTotal += readCount;
}
PRINTF(("done reading data [read %u bytes]\n", givenCount - count));
//PRINTF("sleeping for 100 ticks\n");FLUSH();
//PR_Sleep(100);
return NS_OK;
}
MyListener(PRUint32 stopCount = 1) : mTotal(0), mStopCount(stopCount) {
}
nsresult Init(const char* origFile) {
nsresult rv;
nsCOMPtr<nsILocalFile> file;
rv = NS_NewNativeLocalFile(nsDependentCString(origFile), PR_FALSE, getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
nsCAutoString name;
rv = file->GetNativeLeafName(name);
if (NS_FAILED(rv)) return rv;
name.AppendLiteral(".bak");
rv = file->SetNativeLeafName(name);
if (NS_FAILED(rv)) return rv;
rv = NS_NewLocalFileOutputStream(getter_AddRefs(mOut),
file,
PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
0664);
return rv;
}
virtual ~MyListener() {
nsresult rv = mOut->Close();
NS_ASSERTION(NS_SUCCEEDED(rv), "Close failed");
}
protected:
nsCOMPtr<nsIOutputStream> mOut;
PRUint32 mTotal;
PRUint32 mStopCount;
};
NS_IMPL_THREADSAFE_ISUPPORTS2(MyListener, nsIStreamListener, nsIRequestObserver)
////////////////////////////////////////////////////////////////////////////////
nsresult
TestAsyncRead(const char* fileName, PRUint32 offset, PRInt32 length)
{
nsresult rv;
PRINTF(("TestAsyncRead\n"));
nsCOMPtr<nsIFileTransportService> fts =
do_GetService(kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsITransport* fileTrans;
nsCOMPtr<nsILocalFile> file;
rv = NS_NewNativeLocalFile(nsDependentCString(fileName), PR_FALSE, getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(file, PR_RDONLY, 0, PR_TRUE, &fileTrans);
if (NS_FAILED(rv)) return rv;
MyListener* listener = new MyListener();
if (listener == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(listener);
rv = listener->Init(fileName);
if (NS_FAILED(rv)) return rv;
MyProgressEventSink* progressSink = new MyProgressEventSink();
if (progressSink == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(progressSink);
rv = fileTrans->SetNotificationCallbacks(progressSink, PR_FALSE);
if (NS_FAILED(rv)) return rv;
gDone = PR_FALSE;
nsCOMPtr<nsIRequest> request;
rv = fileTrans->AsyncRead(listener, nsnull, offset, length, 0, getter_AddRefs(request));
if (NS_FAILED(rv)) return rv;
while (!gDone) {
PLEvent* event;
rv = gEventQ->WaitForEvent(&event);
if (NS_FAILED(rv)) return rv;
rv = gEventQ->HandleEvent(event);
if (NS_FAILED(rv)) return rv;
}
NS_RELEASE(listener);
NS_RELEASE(fileTrans);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
nsresult
TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length)
{
nsresult rv;
PRINTF(("TestAsyncWrite\n"));
nsCOMPtr<nsIFileTransportService> fts =
do_GetService(kFileTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCAutoString outFile(fileName);
outFile.AppendLiteral(".out");
nsITransport* fileTrans;
nsCOMPtr<nsILocalFile> file;
rv = NS_NewNativeLocalFile(outFile, PR_FALSE, getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
rv = fts->CreateTransport(file,
PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
0664, PR_TRUE, &fileTrans);
if (NS_FAILED(rv)) return rv;
MyListener* listener = new MyListener();
if (listener == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(listener);
rv = listener->Init(outFile.get());
if (NS_FAILED(rv)) return rv;
MyProgressEventSink* progressSink = new MyProgressEventSink();
if (progressSink == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(progressSink);
rv = fileTrans->SetNotificationCallbacks(progressSink, PR_FALSE);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsILocalFile> f;
rv = NS_NewNativeLocalFile(nsDependentCString(fileName), PR_FALSE, getter_AddRefs(f));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIInputStream> inStr;
rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), f);
if (NS_FAILED(rv)) return rv;
gDone = PR_FALSE;
nsCOMPtr<nsIRequest> request;
rv = NS_AsyncWriteFromStream(getter_AddRefs(request), fileTrans, inStr, offset, length, 0, listener);
if (NS_FAILED(rv)) return rv;
while (!gDone) {
PLEvent* event;
rv = gEventQ->WaitForEvent(&event);
if (NS_FAILED(rv)) return rv;
rv = gEventQ->HandleEvent(event);
if (NS_FAILED(rv)) return rv;
}
NS_RELEASE(listener);
NS_RELEASE(fileTrans);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
#if 0
class MyOpenObserver : public nsIRequestObserver
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD OnStartRequest(nsIRequest *request, nsISupports *ctxt) {
nsresult rv;
char* contentType;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
rv = channel->GetContentType(&contentType);
if (NS_FAILED(rv)) return rv;
PRInt32 length;
rv = cr->GetContentLength(&length);
if (NS_FAILED(rv)) return rv;
PRINTF(("stream opened: content type = %s, length = %d\n",
contentType, length));
nsCRT::free(contentType);
return NS_OK;
}
NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports *ctxt,
nsresult aStatus) {
PRINTF(("stream closed: status %x\n", aStatus));
return NS_OK;
}
MyOpenObserver() { }
virtual ~MyOpenObserver() {}
};
NS_IMPL_ISUPPORTS1(MyOpenObserver, nsIRequestObserver)
#endif
////////////////////////////////////////////////////////////////////////////////
int
main(int argc, char* argv[])
{
nsresult rv;
#if defined(PR_LOGGING)
gTestFileTransportLog = PR_NewLogModule("TestFileTransport");
#endif
if (argc < 2) {
printf("usage: %s <file-to-read>\n", argv[0]);
return -1;
}
char* fileName = argv[1];
{
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
if (registrar)
registrar->AutoRegister(nsnull);
nsCOMPtr<nsIEventQueueService> eventQService =
do_GetService(kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
if (NS_FAILED(rv)) return rv;
rv = TestAsyncRead(fileName, 0, -1);
NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncRead failed");
rv = TestAsyncWrite(fileName, 0, -1);
NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncWrite failed");
rv = TestAsyncRead(fileName, 10, 100);
NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncRead failed");
NS_RELEASE(gEventQ);
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
rv = NS_ShutdownXPCOM(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return NS_OK;
}

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

@ -115,9 +115,9 @@ MyNotifications::OnStatus(nsIRequest *req, nsISupports *ctx,
NS_IMETHODIMP
MyNotifications::OnProgress(nsIRequest *req, nsISupports *ctx,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
printf("progress: %u/%u\n", progress, progressMax);
printf("progress: %llu/%llu\n", progress, progressMax);
return NS_OK;
}

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

@ -255,9 +255,11 @@ MyNotifications::OnStatus(nsIRequest *req, nsISupports *ctx,
NS_IMETHODIMP
MyNotifications::OnProgress(nsIRequest *req, nsISupports *ctx,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
//printf("progress: %u/%u\n", progress, progressMax);
// char buf[100];
// PR_snprintf(buf, sizeof(buf), "%llu/%llu\n", progress, progressMax);
// printf("%s", buf);
return NS_OK;
}

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

@ -184,9 +184,9 @@ public:
}
NS_IMETHOD OnProgress(nsIRequest *req, nsISupports *ctx,
PRUint32 progress, PRUint32 progressMax)
PRUint64 progress, PRUint64 progressMax)
{
LOG(("MyCallbacks::OnProgress [progress=%u/%u]\n", progress, progressMax));
LOG(("MyCallbacks::OnProgress [progress=%llu/%llu]\n", progress, progressMax));
return NS_OK;
}
};

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

@ -58,6 +58,7 @@
#include "nsNetUtil.h"
#include "nsAutoLock.h"
#include "prlog.h"
#include "prprf.h"
////////////////////////////////////////////////////////////////////////////////
@ -169,7 +170,7 @@ NS_IMPL_ISUPPORTS2(MyListener,
* asynchronously copy file.
*/
static nsresult
RunTest(nsIFile *file, PRInt32 offset, PRInt32 length)
RunTest(nsIFile *file, PRInt64 offset, PRInt64 length)
{
nsresult rv;
@ -213,8 +214,18 @@ main(int argc, char* argv[])
return -1;
}
char* fileName = argv[1];
PRInt32 offset = atoi(argv[2]);
PRInt32 length = atoi(argv[3]);
PRInt64 offset, length;
int err = PR_sscanf(argv[2], "%lld", &offset);
if (err == -1) {
printf("Start offset must be an integer!\n");
return 1;
}
err = PR_sscanf(argv[3], "%lld", &length);
if (err == -1) {
printf("Length must be an integer!\n");
return 1;
}
{
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);

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

@ -260,11 +260,13 @@ RunTest(nsIFile *srcFile, nsIFile *destFile)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> srcTransport;
rv = sts->CreateInputTransport(srcStr, -1, -1, PR_TRUE, getter_AddRefs(srcTransport));
rv = sts->CreateInputTransport(srcStr, nsInt64(-1), nsInt64(-1), PR_TRUE,
getter_AddRefs(srcTransport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> destTransport;
rv = sts->CreateOutputTransport(destStr, -1, -1, PR_TRUE, getter_AddRefs(destTransport));
rv = sts->CreateOutputTransport(destStr, nsInt64(-1), nsInt64(-1), PR_TRUE,
getter_AddRefs(destTransport));
if (NS_FAILED(rv)) return rv;
MyCopier *copier = new MyCopier();
@ -311,7 +313,8 @@ RunBlockingTest(nsIFile *srcFile, nsIFile *destFile)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> destTransport;
rv = sts->CreateOutputTransport(fileOut, -1, -1, PR_TRUE, getter_AddRefs(destTransport));
rv = sts->CreateOutputTransport(fileOut, nsInt64(-1), nsInt64(-1),
PR_TRUE, getter_AddRefs(destTransport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIOutputStream> destOut;

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

@ -1537,11 +1537,13 @@ nsXPIProgressListener::OnStateChange(PRUint32 aIndex, PRInt16 aState, PRInt32 aV
}
NS_IMETHODIMP
nsXPIProgressListener::OnProgress(PRUint32 aIndex, PRUint32 aValue, PRUint32 aMaxValue)
nsXPIProgressListener::OnProgress(PRUint32 aIndex, PRUint64 aValue, PRUint64 aMaxValue)
{
nsCOMPtr<nsIWebProgressListener> wpl(do_QueryElementAt(mDownloads, aIndex));
// XXX truncates 64-bit to 32 bit
if (wpl)
return wpl->OnProgressChange(nsnull, nsnull, 0, 0, aValue, aMaxValue);
return wpl->OnProgressChange(nsnull, nsnull, 0, 0, nsUint64(aValue),
nsUint64(aMaxValue));
return NS_OK;
}

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

@ -99,8 +99,8 @@ struct nsRequestInfo : public PLDHashEntryHdr
}
const void* mKey; // Must be first for the pldhash stubs to work
PRInt32 mCurrentProgress;
PRInt32 mMaxProgress;
nsInt64 mCurrentProgress;
nsInt64 mMaxProgress;
PRBool mUploading;
};
@ -551,10 +551,9 @@ nsDocLoader::OnStopRequest(nsIRequest *aRequest,
// this will allow a more accurate estimation of the max progress (in case
// the old value was unknown ie. -1)
//
nsRequestInfo *info;
info = GetRequestInfo(aRequest);
nsRequestInfo *info = GetRequestInfo(aRequest);
if (info) {
PRInt32 oldMax = info->mMaxProgress;
nsInt64 oldMax = info->mMaxProgress;
info->mMaxProgress = info->mCurrentProgress;
//
@ -562,7 +561,7 @@ nsDocLoader::OnStopRequest(nsIRequest *aRequest,
// finished loading, then use this new data to try to calculate a
// mMaxSelfProgress...
//
if ((oldMax < 0) && (mMaxSelfProgress < 0)) {
if ((oldMax < nsInt64(0)) && (mMaxSelfProgress < nsInt64(0))) {
mMaxSelfProgress = CalculateMaxProgress();
}
@ -574,7 +573,7 @@ nsDocLoader::OnStopRequest(nsIRequest *aRequest,
// nsRequestInfo::mCurrentProgress are both 0, then the
// STATE_TRANSFERRING notification has not been fired yet...
//
if ((oldMax == 0) && (info->mCurrentProgress == 0)) {
if ((oldMax == LL_ZERO) && (info->mCurrentProgress == LL_ZERO)) {
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
// Only fire a TRANSFERRING notification if the request is also a
@ -836,17 +835,6 @@ void nsDocLoader::doStopDocumentLoad(nsIRequest *request,
// The following section contains support for nsIWebProgress and related stuff
////////////////////////////////////////////////////////////////////////////////////
// get web progress returns our web progress listener or if
// we don't have one, it will look up the doc loader hierarchy
// to see if one of our parent doc loaders has one.
nsresult nsDocLoader::GetParentWebProgressListener(nsDocLoader * aDocLoader, nsIWebProgressListener ** aWebProgress)
{
// if we got here, there is no web progress to return
*aWebProgress = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsDocLoader::AddProgressListener(nsIWebProgressListener *aListener,
PRUint32 aNotifyMask)
@ -903,53 +891,49 @@ nsDocLoader::GetIsLoadingDocument(PRBool *aIsLoadingDocument)
return NS_OK;
}
PRInt32 nsDocLoader::GetMaxTotalProgress()
PRInt64 nsDocLoader::GetMaxTotalProgress()
{
PRInt32 count = 0;
PRInt32 individualProgress, newMaxTotal;
nsInt64 newMaxTotal = 0;
newMaxTotal = 0;
count = mChildList.Count();
PRInt32 count = mChildList.Count();
nsCOMPtr<nsIWebProgress> webProgress;
nsCOMPtr<nsIDocumentLoader> docloader;
for (PRInt32 i=0; i < count; i++)
{
individualProgress = 0;
docloader = ChildAt(i);
nsInt64 individualProgress = 0;
nsIDocumentLoader* docloader = ChildAt(i);
if (docloader)
{
// Cast is safe since all children are nsDocLoader too
individualProgress = ((nsDocLoader *) docloader.get())->GetMaxTotalProgress();
individualProgress = ((nsDocLoader *) docloader)->GetMaxTotalProgress();
}
if (individualProgress < 0) // if one of the elements doesn't know it's size
// then none of them do
if (individualProgress < nsInt64(0)) // if one of the elements doesn't know it's size
// then none of them do
{
newMaxTotal = -1;
newMaxTotal = nsInt64(-1);
break;
}
else
newMaxTotal += individualProgress;
}
PRInt32 progress = -1;
if (mMaxSelfProgress >= 0 && newMaxTotal >= 0)
nsInt64 progress = -1;
if (mMaxSelfProgress >= nsInt64(0) && newMaxTotal >= nsInt64(0))
progress = newMaxTotal + mMaxSelfProgress;
return progress;
}
////////////////////////////////////////////////////////////////////////////////////
// The following section contains support for nsIEventProgressSink which is used to
// The following section contains support for nsIProgressEventSink which is used to
// pass progress and status between the actual request and the doc loader. The doc loader
// then turns around and makes the right web progress calls based on this information.
////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest *aRequest, nsISupports* ctxt,
PRUint32 aProgress, PRUint32 aProgressMax)
PRUint64 aProgress, PRUint64 aProgressMax)
{
nsRequestInfo *info;
PRInt32 progressDelta = 0;
nsInt64 progressDelta = 0;
//
// Update the RequestInfo entry with the new progress data
@ -957,7 +941,7 @@ NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest *aRequest, nsISupports* ctxt,
info = GetRequestInfo(aRequest);
if (info) {
// suppress sending STATE_TRANSFERRING if this is upload progress (see bug 240053)
if (!info->mUploading && (0 == info->mCurrentProgress) && (0 == info->mMaxProgress)) {
if (!info->mUploading && (nsInt64(0) == info->mCurrentProgress) && (nsInt64(0) == info->mMaxProgress)) {
//
// If we receive an OnProgress event from a toplevel channel that the URI Loader
// has not yet targeted, then we must suppress the event. This is necessary to
@ -978,12 +962,12 @@ NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest *aRequest, nsISupports* ctxt,
// so update mMaxSelfProgress... Otherwise, set it to -1 to indicate
// that the content-length is no longer known.
//
if (aProgressMax != (PRUint32)-1) {
mMaxSelfProgress += aProgressMax;
info->mMaxProgress = aProgressMax;
if (nsUint64(aProgressMax) != LL_MAXUINT) {
mMaxSelfProgress += PRInt64(aProgressMax);
info->mMaxProgress = PRInt64(aProgressMax);
} else {
mMaxSelfProgress = -1;
info->mMaxProgress = -1;
mMaxSelfProgress = nsInt64(-1);
info->mMaxProgress = nsInt64(-1);
}
// Send a STATE_TRANSFERRING notification for the request.
@ -1005,10 +989,10 @@ NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest *aRequest, nsISupports* ctxt,
}
// Update the current progress count...
progressDelta = aProgress - info->mCurrentProgress;
progressDelta = nsInt64(PRInt64(aProgress)) - info->mCurrentProgress;
mCurrentSelfProgress += progressDelta;
info->mCurrentProgress = aProgress;
info->mCurrentProgress = PRInt64(aProgress);
}
//
// The request is not part of the load group, so ignore its progress
@ -1054,11 +1038,11 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsISupports* ctxt,
// submission in mind, where an upload is performed followed by download
// of possibly several documents.
if (info->mUploading != uploading) {
mCurrentSelfProgress = mMaxSelfProgress = 0;
mCurrentTotalProgress = mMaxTotalProgress = 0;
mCurrentSelfProgress = mMaxSelfProgress = LL_ZERO;
mCurrentTotalProgress = mMaxTotalProgress = LL_ZERO;
info->mUploading = uploading;
info->mCurrentProgress = 0;
info->mMaxProgress = 0;
info->mCurrentProgress = LL_ZERO;
info->mMaxProgress = LL_ZERO;
}
}
@ -1077,8 +1061,8 @@ void nsDocLoader::ClearInternalProgress()
{
ClearRequestInfoHash();
mCurrentSelfProgress = mMaxSelfProgress = 0;
mCurrentTotalProgress = mMaxTotalProgress = 0;
mCurrentSelfProgress = mMaxSelfProgress = LL_ZERO;
mCurrentTotalProgress = mMaxTotalProgress = LL_ZERO;
mProgressStateFlags = nsIWebProgressListener::STATE_STOP;
}
@ -1086,11 +1070,11 @@ void nsDocLoader::ClearInternalProgress()
void nsDocLoader::FireOnProgressChange(nsDocLoader *aLoadInitiator,
nsIRequest *request,
PRInt32 aProgress,
PRInt32 aProgressMax,
PRInt32 aProgressDelta,
PRInt32 aTotalProgress,
PRInt32 aMaxTotalProgress)
PRInt64 aProgress,
PRInt64 aProgressMax,
PRInt64 aProgressDelta,
PRInt64 aTotalProgress,
PRInt64 aMaxTotalProgress)
{
if (mIsLoadingDocument) {
mCurrentTotalProgress += aProgressDelta;
@ -1134,9 +1118,10 @@ void nsDocLoader::FireOnProgressChange(nsDocLoader *aLoadInitiator,
continue;
}
// XXX truncates 64-bit to 32-bit
listener->OnProgressChange(aLoadInitiator,request,
aProgress, aProgressMax,
aTotalProgress, aMaxTotalProgress);
PRInt32(aProgress), PRInt32(aProgressMax),
PRInt32(aTotalProgress), PRInt32(aMaxTotalProgress));
}
mListenerInfoList.Compact();
@ -1374,10 +1359,10 @@ CalcMaxProgressCallback(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
const nsRequestInfo *info = NS_STATIC_CAST(const nsRequestInfo *, hdr);
PRInt32 *max = NS_STATIC_CAST(PRInt32 *, arg);
nsInt64 *max = NS_STATIC_CAST(nsInt64 *, arg);
if (info->mMaxProgress < info->mCurrentProgress) {
*max = -1;
*max = nsInt64(-1);
return PL_DHASH_STOP;
}
@ -1387,9 +1372,9 @@ CalcMaxProgressCallback(PLDHashTable *table, PLDHashEntryHdr *hdr,
return PL_DHASH_NEXT;
}
PRInt32 nsDocLoader::CalculateMaxProgress()
PRInt64 nsDocLoader::CalculateMaxProgress()
{
PRInt32 max = 0;
nsInt64 max = 0;
PL_DHashTableEnumerate(&mRequestInfoHash, CalcMaxProgressCallback, &max);
return max;
}

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

@ -56,6 +56,7 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIHttpEventSink.h"
#include "nsISecurityEventSink.h"
#include "nsInt64.h"
#include "nsCOMPtr.h"
#include "pldhash.h"
@ -146,11 +147,11 @@ protected:
void FireOnProgressChange(nsDocLoader* aLoadInitiator,
nsIRequest *request,
PRInt32 aProgress,
PRInt32 aProgressMax,
PRInt32 aProgressDelta,
PRInt32 aTotalProgress,
PRInt32 aMaxTotalProgress);
PRInt64 aProgress,
PRInt64 aProgressMax,
PRInt64 aProgressDelta,
PRInt64 aTotalProgress,
PRInt64 aMaxTotalProgress);
void FireOnStateChange(nsIWebProgress *aProgress,
nsIRequest* request,
@ -171,11 +172,6 @@ protected:
void doStopURLLoad(nsIRequest *request, nsresult aStatus);
void doStopDocumentLoad(nsIRequest *request, nsresult aStatus);
// get web progress returns our web progress listener or if
// we don't have one, it will look up the doc loader hierarchy
// to see if one of our parent doc loaders has one.
nsresult GetParentWebProgressListener(nsDocLoader * aDocLoader, nsIWebProgressListener ** aWebProgres);
protected:
// IMPORTANT: The ownership implicit in the following member
// variables has been explicitly checked and set using nsCOMPtr
@ -203,23 +199,23 @@ protected:
// feedback interfaces that travis cooked up.
PRInt32 mProgressStateFlags;
PRInt32 mCurrentSelfProgress;
PRInt32 mMaxSelfProgress;
nsInt64 mCurrentSelfProgress;
nsInt64 mMaxSelfProgress;
PRInt32 mCurrentTotalProgress;
PRInt32 mMaxTotalProgress;
nsInt64 mCurrentTotalProgress;
nsInt64 mMaxTotalProgress;
PLDHashTable mRequestInfoHash;
private:
nsListenerInfo *GetListenerInfo(nsIWebProgressListener* aListener);
PRInt32 GetMaxTotalProgress();
PRInt64 GetMaxTotalProgress();
nsresult AddRequestInfo(nsIRequest* aRequest);
nsRequestInfo *GetRequestInfo(nsIRequest* aRequest);
void ClearRequestInfoHash();
PRInt32 CalculateMaxProgress();
PRInt64 CalculateMaxProgress();
/// void DumpChannelInfo(void);
// used to clear our internal progress state between loads...

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

@ -1,5 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -96,6 +95,7 @@
#include "nsCWebBrowser.h"
#include "nsUnicharUtils.h"
#include "nsInt64.h"
#include "nsIParser.h"
#include "nsEditorMode.h"
@ -1857,7 +1857,7 @@ nsBrowserWindow::ShowMenuBar(PRBool aShow)
NS_IMETHODIMP
nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt,
PRUint32 aProgress, PRUint32 aProgressMax)
PRUint64 aProgress, PRUint64 aProgressMax)
{
nsresult rv;
@ -1874,10 +1874,10 @@ nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt,
AppendUTF8toUTF16(str, url);
}
url.AppendLiteral(": progress ");
url.AppendInt(aProgress, 10);
if (0 != aProgressMax) {
url.AppendInt(PRInt64(aProgress), 10);
if (nsUint64(0) != aProgressMax) {
url.AppendLiteral(" (out of ");
url.AppendInt(aProgressMax, 10);
url.AppendInt(PRInt64(aProgressMax), 10);
url.Append(NS_LITERAL_STRING(")"));
}
PRUint32 size;

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

@ -272,6 +272,11 @@ public:
return LL_EQ(mValue, aObject2.mValue);
}
inline PRBool
operator ==(T aValue) const {
return LL_EQ(mValue, aValue);
}
/**
* Determine if two 64-bit integers are not equal
*/
@ -280,6 +285,10 @@ public:
return LL_NE(mValue, aObject2.mValue);
}
inline PRBool
operator !=(T aValue) const {
return LL_NE(mValue, aValue);
}
/**
* Perform a bitwise AND of two 64-bit integers
@ -339,6 +348,15 @@ public:
LL_XOR(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Allow doing if (!some_nsInt64)
*/
PRBool operator!() const {
return LL_IS_ZERO(mValue);
}
};
typedef nsTInt64<PRInt64> nsInt64;

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

@ -42,7 +42,7 @@
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(8cdf1192-8709-4428-ab97-c5b6ceecd7e9)]
[scriptable, uuid(ce8f744e-d5a5-41b3-911f-0fee3008b64e)]
interface nsIXPIProgressDialog : nsISupports
{
/**
@ -78,5 +78,5 @@ interface nsIXPIProgressDialog : nsISupports
* @param value number of bytes downloaded
* @param maxValue the total size
*/
void onProgress( in unsigned long index, in unsigned long value, in unsigned long maxValue );
void onProgress( in unsigned long index, in unsigned long long value, in unsigned long long maxValue );
};

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

@ -39,6 +39,7 @@
#include "nscore.h"
#include "pratom.h"
#include "prmem.h"
#include "nsInt64.h"
#include "nsISupports.h"
#include "nsIServiceManager.h"
@ -1016,7 +1017,7 @@ nsXPInstallManager::OnDataAvailable(nsIRequest* request, nsISupports *ctxt,
NS_IMETHODIMP
nsXPInstallManager::OnProgress(nsIRequest* request, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax)
nsXPInstallManager::OnProgress(nsIRequest* request, nsISupports *ctxt, PRUint64 aProgress, PRUint64 aProgressMax)
{
nsresult rv = NS_OK;
@ -1031,7 +1032,8 @@ nsXPInstallManager::OnProgress(nsIRequest* request, nsISupports *ctxt, PRUint32
if (NS_FAILED(rv)) return rv;
}
mLastUpdate = now;
rv = mDlg->OnProgress( mNextItem-1, aProgress, mContentLength );
// XXX once channels support that, use 64-bit contentlength
rv = mDlg->OnProgress( mNextItem-1, aProgress, nsUint64(mContentLength) );
}
return rv;