mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Fix - download progress resets to zero momentarily on download items when a new download begins
- Downloads window displays "0%" in the title bar progress briefly after a download completes.
This commit is contained in:
parent
4280a92fa2
commit
846cdb01d1
@ -529,6 +529,13 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType,
|
||||
nsCOMPtr<nsIRDFResource> downloadRes;
|
||||
gRDFService->GetUnicodeResource(path, getter_AddRefs(downloadRes));
|
||||
|
||||
// Save state of existing downloads NOW... because inserting the new
|
||||
// download resource into the container will cause the FE to rebuild and all
|
||||
// the active downloads will have their progress reset (since progress is held
|
||||
// mostly by the FE and not the datasource) until they get another progress
|
||||
// notification (which could be a while for slow downloads).
|
||||
SaveState();
|
||||
|
||||
// if the resource is in the container already (the user has already
|
||||
// downloaded this file), remove it
|
||||
PRInt32 itemIndex;
|
||||
|
@ -407,6 +407,7 @@ function onUpdateProgress()
|
||||
var numActiveDownloads = gActiveDownloads.length;
|
||||
if (numActiveDownloads == 0) {
|
||||
window.title = document.documentElement.getAttribute("statictitle");
|
||||
gLastComputedMean = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -419,6 +420,15 @@ function onUpdateProgress()
|
||||
}
|
||||
|
||||
mean = Math.round(mean / numActiveDownloads);
|
||||
|
||||
// At the end of a download, progress is set from 100% to 0% for
|
||||
// some reason. We can identify this case because at this point the
|
||||
// mean progress will be zero but the last computed mean will be
|
||||
// greater than zero.
|
||||
if (mean == 0 && gLastComputedMean > 0) {
|
||||
window.title = document.documentElement.getAttribute("statictitle");
|
||||
return;
|
||||
}
|
||||
if (mean != gLastComputedMean) {
|
||||
gLastComputedMean = mean;
|
||||
var strings = document.getElementById("downloadStrings");
|
||||
|
Loading…
Reference in New Issue
Block a user