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 208305 cfec8a16880a
parent 208304 d4e47ec57f06
child 208306 51f60a862089
push id3813
push userryanvm@gmail.com
push date2014-08-14 13:03 +0000
treeherdermozilla-beta@cfec8a16880a [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