зеркало из https://github.com/mozilla/gecko-dev.git
Bug 390748 - When downloading multiple files, Download Manager doesn't show files it has queued. r=mano, a=blocking-firefox3
This commit is contained in:
Родитель
d40efddf8c
Коммит
3cedd5720a
|
@ -51,10 +51,11 @@ interface nsIDownloadProgressListener;
|
|||
interface nsISimpleEnumerator;
|
||||
interface mozIStorageConnection;
|
||||
|
||||
[scriptable, uuid(0e8ded0d-c6e4-4b67-9d1e-42fe3d405491)]
|
||||
[scriptable, uuid(b0ba9b75-2aad-4293-8680-3fc66b13e546)]
|
||||
interface nsIDownloadManager : nsISupports {
|
||||
// Download States
|
||||
const short DOWNLOAD_NOTSTARTED = -1;
|
||||
const short DOWNLOAD_QUEUED = 5;
|
||||
const short DOWNLOAD_DOWNLOADING = 0;
|
||||
const short DOWNLOAD_FINISHED = 1;
|
||||
const short DOWNLOAD_FAILED = 2;
|
||||
|
|
|
@ -740,6 +740,7 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType,
|
|||
dl->mID = id;
|
||||
|
||||
rv = AddToCurrentDownloads(dl);
|
||||
(void)dl->SetState(nsIDownloadManager::DOWNLOAD_QUEUED);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ADDREF(*aDownload = dl);
|
||||
|
@ -842,8 +843,6 @@ nsDownloadManager::RetryDownload(PRUint32 aID)
|
|||
dl->mDownloadManager = this;
|
||||
|
||||
dl->SetStartTime(PR_Now());
|
||||
rv = dl->SetState(nsIDownloadManager::DOWNLOAD_NOTSTARTED);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPersist> wbp =
|
||||
do_CreateInstance("@mozilla.org/embedding/browser/nsWebBrowserPersist;1", &rv);
|
||||
|
@ -855,12 +854,28 @@ nsDownloadManager::RetryDownload(PRUint32 aID)
|
|||
|
||||
rv = wbp->SetPersistFlags(nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES |
|
||||
nsIWebBrowserPersist::PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
dl->mCancelable = nsnull;
|
||||
(void)wbp->SetProgressListener(nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = AddToCurrentDownloads(dl);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
dl->mCancelable = nsnull;
|
||||
(void)wbp->SetProgressListener(nsnull);
|
||||
return rv;
|
||||
}
|
||||
(void)dl->SetState(nsIDownloadManager::DOWNLOAD_QUEUED);
|
||||
|
||||
return wbp->SaveURI(dl->mSource, nsnull, nsnull, nsnull, nsnull, dl->mTarget);
|
||||
rv = wbp->SaveURI(dl->mSource, nsnull, nsnull, nsnull, nsnull, dl->mTarget);
|
||||
if (NS_FAILED(rv)) {
|
||||
dl->mCancelable = nsnull;
|
||||
(void)wbp->SetProgressListener(nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1337,7 +1352,7 @@ nsDownload::OnProgressChange64(nsIWebProgress *aWebProgress,
|
|||
if (!mRequest)
|
||||
mRequest = aRequest; // used for pause/resume
|
||||
|
||||
if (mDownloadState == nsIDownloadManager::DOWNLOAD_NOTSTARTED) {
|
||||
if (mDownloadState == nsIDownloadManager::DOWNLOAD_QUEUED) {
|
||||
nsresult rv = SetState(nsIDownloadManager::DOWNLOAD_DOWNLOADING);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mDownloadManager->mObserverService->NotifyObservers(this, "dl-start", nsnull);
|
||||
|
|
|
@ -170,6 +170,7 @@ protected:
|
|||
static PRBool IsInProgress(DownloadState aState)
|
||||
{
|
||||
return aState == nsIDownloadManager::DOWNLOAD_NOTSTARTED ||
|
||||
aState == nsIDownloadManager::DOWNLOAD_QUEUED ||
|
||||
aState == nsIDownloadManager::DOWNLOAD_DOWNLOADING ||
|
||||
aState == nsIDownloadManager::DOWNLOAD_PAUSED;
|
||||
}
|
||||
|
|
|
@ -120,6 +120,9 @@ function addDownload()
|
|||
var srcFile = dirSvc.get("ProfD", Ci.nsIFile);
|
||||
srcFile.append("LICENSE");
|
||||
|
||||
// it is part of the active downloads the moment addDownload is called
|
||||
gDownloadCount++;
|
||||
|
||||
var dl = dm.addDownload(nsIDownloadManager.DOWNLOAD_TYPE_DOWNLOAD,
|
||||
createURI("http://localhost:4444/LICENSE"),
|
||||
createURI(destFile), null, null,
|
||||
|
@ -129,9 +132,6 @@ function addDownload()
|
|||
// try catch block
|
||||
var test = dm.getDownload(dl.id);
|
||||
|
||||
// it is part of the active downloads now, even if it hasn't started.
|
||||
gDownloadCount++;
|
||||
|
||||
persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener);
|
||||
persist.saveURI(dl.source, null, null, null, null, dl.targetFile);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ DownloadProgressListener.prototype =
|
|||
{
|
||||
var dl = getDownload(aDownload.id);
|
||||
switch (aDownload.state) {
|
||||
case Ci.nsIDownloadManager.DOWNLOAD_NOTSTARTED:
|
||||
case Ci.nsIDownloadManager.DOWNLOAD_QUEUED:
|
||||
// We'll have at least one active download now
|
||||
gDownloadsActiveTitle.hidden = false;
|
||||
case Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING:
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
var state = parseInt(this.getAttribute("state"));
|
||||
const dl = Components.interfaces.nsIDownloadManager;
|
||||
return state == dl.DOWNLOAD_NOTSTARTED ||
|
||||
state == dl.DOWNLOAD_QUEUED ||
|
||||
state == dl.DOWNLOAD_DOWNLOADING ||
|
||||
state == dl.DOWNLOAD_PAUSED;
|
||||
]]>
|
||||
|
|
Загрузка…
Ссылка в новой задаче