Closed
Bug 916430
Opened 12 years ago
Closed 12 years ago
General Downloads API review
Categories
(Toolkit :: Downloads API, defect)
Toolkit
Downloads API
Tracking
()
RESOLVED
FIXED
mozilla27
People
(Reporter: Paolo, Assigned: Paolo)
References
Details
(Whiteboard: [qa-])
Attachments
(1 file, 1 obsolete file)
|
48.86 KB,
patch
|
Gavin
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
We decided to implement some changes to the API early, to pave the way for
future improvements, as well as clarify the usage of some methods.
In particular, the DownloadList methods should return completion promises.
The simpleDownload method will be renamed to something clearer.
| Assignee | ||
Comment 1•12 years ago
|
||
I've renamed simpleDownload to startDirect, or we may call it just "start".
The fact that calling "yield download.start()" waits for the download to be finished still look weird, but I haven't found a better name or alternate API
that hasn't more drawbacks than benefits.
Attachment #804873 -
Flags: review?(mak77)
| Assignee | ||
Comment 2•12 years ago
|
||
Note that I've not changed the download directory name getters in this patch, as those methods are still unused and we still have to examine how they are supposed to work exactly.
| Assignee | ||
Updated•12 years ago
|
Attachment #804873 -
Flags: review?(mak77) → review?(enndeakin)
Comment 3•12 years ago
|
||
Comment on attachment 804873 [details] [diff] [review]
The patch
function DownloadAutoSaveView(aList, aStore) {
+ this._list = aList;
this._store = aStore;
this._downloadsMap = new Map();
-
- // We set _initialized to true after adding the view, so that onDownloadAdded
- // doesn't cause a save to occur.
- aList.addView(this);
- this._initialized = true;
}
Add a comment to indicate that the caller needs to call initialize() on this object. Maybe the list and the store should be passed to initialize() rather than to the constructor.
>DownloadSummary.prototype = {
...
> /**
> * Removes a view that was previously added using addView. The removed view
> * will not receive any more notifications after this method returns.
> *
You should remove the last sentence from this DownloadSummary.remove comment.
diff --git a/toolkit/components/jsdownloads/test/unit/head.js b/toolkit/components/jsdownloads/test/unit/head.js
// When the download object is ready, make it available to the caller.
- deferred.resolve(aDownload);
+ promise.then(() => deferred.resolve(aDownload))
+ .then(null, do_report_unexpected_exception);
},
@@ -416,26 +417,27 @@ function promiseStartExternalHelperAppSe
// When the download object is ready, make it available to the caller.
- deferred.resolve(aDownload);
+ promise.then(() => deferred.resolve(aDownload))
+ .then(null, do_report_unexpected_exception);
},
What exception would occur here that would warrant two separate then() calls?
Attachment #804873 -
Flags: review?(enndeakin) → review+
| Assignee | ||
Comment 4•12 years ago
|
||
(In reply to Neil Deakin from comment #3)
> Add a comment to indicate that the caller needs to call initialize() on this
> object. Maybe the list and the store should be passed to initialize() rather
> than to the constructor.
Added the comment, passing the list and the store in the constructor still seems more similar to what we do in other similar objects.
> - deferred.resolve(aDownload);
> + promise.then(() => deferred.resolve(aDownload))
> + .then(null, do_report_unexpected_exception);
> },
>
> What exception would occur here that would warrant two separate then() calls?
Most probably none ("deferred" can't become null), I've updated this.
| Assignee | ||
Comment 5•12 years ago
|
||
The recent try run on the previous patch is mostly green until now:
https://tbpl.mozilla.org/?tree=Try&rev=bc019bdb5589
| Assignee | ||
Comment 6•12 years ago
|
||
Comment on attachment 804873 [details] [diff] [review]
The patch
This bug makes some changes to make the Downloads API clearer. We should
ensure it gets into the first Aurora build so that add-on developers do not
have to deal with a different API in different Aurora builds.
Testing completed on try, not landed on fx-team yet because of a tree closure:
https://tbpl.mozilla.org/?tree=Try&rev=bc019bdb5589
Attachment #804873 -
Flags: approval-mozilla-aurora?
Comment 7•12 years ago
|
||
Comment on attachment 804873 [details] [diff] [review]
The patch
Review of attachment 804873 [details] [diff] [review]:
-----------------------------------------------------------------
::: browser/base/content/test/browser_sanitize-timespans.js
@@ +686,1 @@
>
while here you may remove the trailing spaces
@@ +698,1 @@
>
while here you may remove the trailing spaces
::: toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ +224,3 @@
> new DownloadHistoryObserver(aList);
> +
> + //
leftover
::: toolkit/components/jsdownloads/src/Downloads.jsm
@@ +131,5 @@
> * @return {Promise}
> * @resolves When the download has finished successfully.
> * @rejects JavaScript exception if the download failed.
> */
> + startDirect: function (aSource, aTarget, aOptions) {
The concept of a "direct" download is fancy, what is an indirect download?
At that point a straight start() looks better.
We may play with adjectives, but nothing I can think of can well describe an unmanageable and silent download. At a maximum startInBackground, but it's not the others are not in background.
Alternatively, I may think of replacing start() with fetch(), since if you yield on it you get everything. Downloads.fetch(sourceUrl, targetFile) sounds good to me and it's clear you are not creating a Download.
Comment 8•12 years ago
|
||
Did you file a separate bug for the Temporary/User/System folders naming?
| Assignee | ||
Comment 9•12 years ago
|
||
(In reply to Marco Bonardo [:mak] from comment #7)
> Alternatively, I may think of replacing start() with fetch(), since if you
> yield on it you get everything. Downloads.fetch(sourceUrl, targetFile)
> sounds good to me and it's clear you are not creating a Download.
That sounds good to me too. Too bad I *just* checked in the current patch:
https://hg.mozilla.org/integration/fx-team/rev/cf4d664a0756
I'll make a follow-up patch to change the name.
| Assignee | ||
Comment 10•12 years ago
|
||
| Assignee | ||
Comment 11•12 years ago
|
||
Attachment #804873 -
Attachment is obsolete: true
Attachment #804873 -
Flags: approval-mozilla-aurora?
Attachment #805888 -
Flags: approval-mozilla-aurora?
| Assignee | ||
Comment 12•12 years ago
|
||
(In reply to Marco Bonardo [:mak] from comment #8)
> Did you file a separate bug for the Temporary/User/System folders naming?
Just filed bug 917217, thanks for the reminder!
Comment 13•12 years ago
|
||
Unfortunately this conflicted with the backout of bug 913110, so a bunch of things, including this had to be backed out for now:
remote: https://hg.mozilla.org/integration/fx-team/rev/5736f23d8a22
remote: https://hg.mozilla.org/integration/fx-team/rev/fd257eef04b2
remote: https://hg.mozilla.org/integration/fx-team/rev/00593fe07777
remote: https://hg.mozilla.org/integration/fx-team/rev/ea0b23759685
remote: https://hg.mozilla.org/integration/fx-team/rev/cbc7af0a20c4
| Assignee | ||
Comment 14•12 years ago
|
||
Comment 15•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
Comment 16•12 years ago
|
||
Same as with bug 913110 - please fill out a proper approval request that addresses the risks/reward of uplifting this.
Updated•12 years ago
|
Attachment #805888 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment 17•12 years ago
|
||
Apologies for the flag mid-air, hadn't seen Lukas' comments before approving. I posted some reasoning in bug 913110 comment 23.
| Assignee | ||
Comment 18•12 years ago
|
||
Updated•12 years ago
|
Comment 19•12 years ago
|
||
Marking as [qa-] based on the existing mochitest on the patch and on the in testsuite flag.
Whiteboard: [qa-]
You need to log in
before you can comment on or make changes to this bug.
Description
•