Bug 460751 - Progress events should use long long, not long for .total and .loaded, r=chris.double, sr=sicking

This commit is contained in:
Olli Pettay 2008-10-21 12:06:53 +03:00
parent 3ba81f6270
commit d5328ab301
9 changed files with 31 additions and 29 deletions

View File

@ -2583,7 +2583,9 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
} }
mUploadComplete = PR_FALSE; mUploadComplete = PR_FALSE;
postDataStream->Available(&mUploadTotal); PRUint32 uploadTotal = 0;
postDataStream->Available(&uploadTotal);
mUploadTotal = uploadTotal;
rv = uploadChannel->SetUploadStream(postDataStream, contentType, -1); rv = uploadChannel->SetUploadStream(postDataStream, contentType, -1);
// Reset the method to its original value // Reset the method to its original value
if (httpChannel) { if (httpChannel) {
@ -3152,7 +3154,7 @@ nsXMLHttpRequest::OnProgress(nsIRequest *aRequest, nsISupports *aContext, PRUint
PRBool lengthComputable = (aProgressMax != LL_MAXUINT); PRBool lengthComputable = (aProgressMax != LL_MAXUINT);
if (upload) { if (upload) {
if (lengthComputable) { if (lengthComputable) {
PRUint32 headerSize = aProgressMax - mUploadTotal; PRUint64 headerSize = aProgressMax - mUploadTotal;
loaded -= headerSize; loaded -= headerSize;
total -= headerSize; total -= headerSize;
} }
@ -3179,7 +3181,7 @@ nsXMLHttpRequest::OnProgress(nsIRequest *aRequest, nsISupports *aContext, PRUint
aProgress, aProgressMax); aProgress, aProgressMax);
if (upload && mUpload && !mUploadComplete) { if (upload && mUpload && !mUploadComplete) {
NS_WARN_IF_FALSE(mUploadTotal == PRUint32(total), "Wrong upload total?"); NS_WARN_IF_FALSE(mUploadTotal == total, "Wrong upload total?");
DispatchProgressEvent(mUpload, progress, PR_TRUE, lengthComputable, loaded, DispatchProgressEvent(mUpload, progress, PR_TRUE, lengthComputable, loaded,
lengthComputable ? total : 0, aProgress, aProgressMax); lengthComputable ? total : 0, aProgress, aProgressMax);
} }

View File

@ -449,8 +449,8 @@ protected:
PRUint32 mState; PRUint32 mState;
nsRefPtr<nsXMLHttpRequestUpload> mUpload; nsRefPtr<nsXMLHttpRequestUpload> mUpload;
PRUint32 mUploadTransferred; PRUint64 mUploadTransferred;
PRUint32 mUploadTotal; PRUint64 mUploadTotal;
PRPackedBool mUploadComplete; PRPackedBool mUploadComplete;
PRUint64 mUploadProgress; // For legacy PRUint64 mUploadProgress; // For legacy
PRUint64 mUploadProgressMax; // For legacy PRUint64 mUploadProgressMax; // For legacy

View File

@ -56,14 +56,14 @@ nsDOMProgressEvent::GetLengthComputable(PRBool* aLengthComputable)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMProgressEvent::GetLoaded(PRUint32* aLoaded) nsDOMProgressEvent::GetLoaded(PRUint64* aLoaded)
{ {
*aLoaded = mLoaded; *aLoaded = mLoaded;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMProgressEvent::GetTotal(PRUint32* aTotal) nsDOMProgressEvent::GetTotal(PRUint64* aTotal)
{ {
*aTotal = mTotal; *aTotal = mTotal;
return NS_OK; return NS_OK;
@ -74,8 +74,8 @@ nsDOMProgressEvent::InitProgressEvent(const nsAString& aType,
PRBool aCanBubble, PRBool aCanBubble,
PRBool aCancelable, PRBool aCancelable,
PRBool aLengthComputable, PRBool aLengthComputable,
PRUint32 aLoaded, PRUint64 aLoaded,
PRUint32 aTotal) PRUint64 aTotal)
{ {
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable); nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View File

@ -66,8 +66,8 @@ public:
private: private:
PRBool mLengthComputable; PRBool mLengthComputable;
PRUint32 mLoaded; PRUint64 mLoaded;
PRUint32 mTotal; PRUint64 mTotal;
}; };
#endif // nsDOMProgressEvent_h__ #endif // nsDOMProgressEvent_h__

View File

@ -130,7 +130,7 @@ class nsMediaDecoder : public nsIObserver
// Return the current number of bytes loaded from the video file. // Return the current number of bytes loaded from the video file.
// This is used for progress events. // This is used for progress events.
virtual PRUint32 GetBytesLoaded() = 0; virtual PRUint64 GetBytesLoaded() = 0;
// Return the size of the video file in bytes. Return 0 if the // Return the size of the video file in bytes. Return 0 if the
// size is unknown or the stream is infinite. // size is unknown or the stream is infinite.
@ -152,7 +152,7 @@ class nsMediaDecoder : public nsIObserver
virtual void Progress(); virtual void Progress();
// Keep track of the number of bytes downloaded // Keep track of the number of bytes downloaded
virtual void UpdateBytesDownloaded(PRUint32 aBytes) = 0; virtual void UpdateBytesDownloaded(PRUint64 aBytes) = 0;
// Cleanup internal data structures. Must be called on the main // Cleanup internal data structures. Must be called on the main
// thread by the owning object before that object disposes of this object. // thread by the owning object before that object disposes of this object.

View File

@ -326,7 +326,7 @@ class nsOggDecoder : public nsMediaDecoder
void GetCurrentURI(nsIURI** aURI); void GetCurrentURI(nsIURI** aURI);
nsIPrincipal* GetCurrentPrincipal(); nsIPrincipal* GetCurrentPrincipal();
virtual void UpdateBytesDownloaded(PRUint32 aBytes); virtual void UpdateBytesDownloaded(PRUint64 aBytes);
// Called when the video file has completed downloading. // Called when the video file has completed downloading.
// Call on the main thread only. // Call on the main thread only.
@ -378,7 +378,7 @@ protected:
// Return the current number of bytes loaded from the video file. // Return the current number of bytes loaded from the video file.
// This is used for progress events. // This is used for progress events.
virtual PRUint32 GetBytesLoaded(); virtual PRUint64 GetBytesLoaded();
// Return the size of the video file in bytes. // Return the size of the video file in bytes.
// This is used for progress events. // This is used for progress events.
@ -411,7 +411,7 @@ private:
* The following members should be accessed on the main thread only * The following members should be accessed on the main thread only
******/ ******/
// Total number of bytes downloaded so far. // Total number of bytes downloaded so far.
PRUint32 mBytesDownloaded; PRUint64 mBytesDownloaded;
// The URI of the current resource // The URI of the current resource
nsCOMPtr<nsIURI> mURI; nsCOMPtr<nsIURI> mURI;

View File

@ -1315,7 +1315,7 @@ NS_IMETHODIMP nsOggDecoder::Observe(nsISupports *aSubjet,
return NS_OK; return NS_OK;
} }
PRUint32 nsOggDecoder::GetBytesLoaded() PRUint64 nsOggDecoder::GetBytesLoaded()
{ {
return mBytesDownloaded; return mBytesDownloaded;
} }
@ -1330,7 +1330,7 @@ void nsOggDecoder::SetTotalBytes(PRInt64 aBytes)
mContentLength = aBytes; mContentLength = aBytes;
} }
void nsOggDecoder::UpdateBytesDownloaded(PRUint32 aBytes) void nsOggDecoder::UpdateBytesDownloaded(PRUint64 aBytes)
{ {
mBytesDownloaded = aBytes; mBytesDownloaded = aBytes;
} }

View File

@ -45,16 +45,16 @@
* the specification is complete and is compatible with the WebKit ProgressEvent. * the specification is complete and is compatible with the WebKit ProgressEvent.
*/ */
[scriptable, uuid(3fa16b05-81a0-4a17-ab06-98c3a5a5be09)] [scriptable, uuid(6af7022c-d7f8-414c-a11f-a7918f14052b)]
interface nsIDOMProgressEvent : nsIDOMEvent interface nsIDOMProgressEvent : nsIDOMEvent
{ {
readonly attribute boolean lengthComputable; readonly attribute boolean lengthComputable;
readonly attribute unsigned long loaded; readonly attribute unsigned long long loaded;
readonly attribute unsigned long total; readonly attribute unsigned long long total;
void initProgressEvent(in DOMString typeArg, void initProgressEvent(in DOMString typeArg,
in boolean canBubbleArg, in boolean canBubbleArg,
in boolean cancelableArg, in boolean cancelableArg,
in boolean lengthComputableArg, in boolean lengthComputableArg,
in unsigned long loadedArg, in unsigned long long loadedArg,
in unsigned long totalArg); in unsigned long long totalArg);
}; };

View File

@ -199,8 +199,8 @@ protected:
nsCString mStatusText; nsCString mStatusText;
nsresult mStatus; nsresult mStatus;
PRInt32 mReadyState; PRInt32 mReadyState;
PRUint32 mLoaded; PRUint64 mLoaded;
PRUint32 mTotal; PRUint64 mTotal;
PRInt32 mChannelID; PRInt32 mChannelID;
PRPackedBool mBubbles; PRPackedBool mBubbles;
PRPackedBool mCancelable; PRPackedBool mCancelable;
@ -453,7 +453,7 @@ nsDOMWorkerXHREvent::GetLengthComputable(PRBool* aLengthComputable)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMWorkerXHREvent::GetLoaded(PRUint32* aLoaded) nsDOMWorkerXHREvent::GetLoaded(PRUint64* aLoaded)
{ {
NS_ENSURE_ARG_POINTER(aLoaded); NS_ENSURE_ARG_POINTER(aLoaded);
*aLoaded = mLoaded; *aLoaded = mLoaded;
@ -461,7 +461,7 @@ nsDOMWorkerXHREvent::GetLoaded(PRUint32* aLoaded)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMWorkerXHREvent::GetTotal(PRUint32* aTotal) nsDOMWorkerXHREvent::GetTotal(PRUint64* aTotal)
{ {
NS_ENSURE_ARG_POINTER(aTotal); NS_ENSURE_ARG_POINTER(aTotal);
*aTotal = mTotal; *aTotal = mTotal;
@ -473,8 +473,8 @@ nsDOMWorkerXHREvent::InitProgressEvent(const nsAString_internal& aTypeArg,
PRBool aCanBubbleArg, PRBool aCanBubbleArg,
PRBool aCancelableArg, PRBool aCancelableArg,
PRBool aLengthComputableArg, PRBool aLengthComputableArg,
PRUint32 aLoadedArg, PRUint64 aLoadedArg,
PRUint32 aTotalArg) PRUint64 aTotalArg)
{ {
NS_WARNING("InitProgressEvent doesn't do anything here!"); NS_WARNING("InitProgressEvent doesn't do anything here!");
return NS_OK; return NS_OK;