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 209389 cfec8a16880a39bd20f405012b9cb4d1d4fd9042
parent 209388 d4e47ec57f06a2b3aa413c700bb9fd0c4d5fbd51
child 209390 51f60a8620895cb1f5fdc5d4d275656fdfea4c7c
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lmandel
bugs1044584
milestone32.0
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
@@ -3586,21 +3586,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