Bug 1044584 - Fix incorrect computation of mUploadTransferred. r=bz, a=lmandel
authorAxel Viala <axel.viala@darnuria.eu>
Mon, 28 Jul 2014 17:19:51 +0200
changeset 217472 0da4b7a32afb21abb42871abf3380435a7f85a1f
parent 217471 ab1d62c9f92c7703446ae667d9877700af260eea
child 217473 22da5e9d92e9b00780fc07320d33bc9acfcc33a8
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lmandel
bugs1044584
milestone33.0a2
Bug 1044584 - Fix incorrect computation of mUploadTransferred. r=bz, a=lmandel
content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -3589,21 +3589,23 @@ nsXMLHttpRequest::OnProgress(nsIRequest 
 {
   // We're uploading if our state is XML_HTTP_REQUEST_OPENED or
   // XML_HTTP_REQUEST_SENT
   bool upload = !!((XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_SENT) & mState);
   // When uploading, OnProgress reports also headers in aProgress and aProgressMax.
   // So, try to remove the headers, if possible.
   bool lengthComputable = (aProgressMax != UINT64_MAX);
   if (upload) {
-    mUploadTransferred = aProgress;
+    uint64_t loaded = aProgress;
     if (lengthComputable) {
-      mUploadTransferred = aProgressMax - mUploadTotal;
+      uint64_t headerSize = aProgressMax - mUploadTotal;
+      loaded -= headerSize;
     }
     mUploadLengthComputable = lengthComputable;
+    mUploadTransferred = loaded;
     mProgressSinceLastProgressEvent = true;
 
     MaybeDispatchProgressEvents(false);
   } else {
     mLoadLengthComputable = lengthComputable;
     mLoadTotal = lengthComputable ? aProgressMax : 0;
     
     // Don't dispatch progress events here. OnDataAvailable will take care