[Gaia][System] Download Manager API Design

RESOLVED FIXED in 1.3 Sprint 6 - 12/6


Firefox OS
5 years ago
5 years ago


(Reporter: aus, Assigned: aus)


1.3 Sprint 6 - 12/6
Gonk (Firefox OS)
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [systemsfe])


(1 attachment)



5 years ago
As part of the download manager work for 1.3 we'll be designing a new Download Manager API.

This API will enable downloads to be triggered from any application.

This API will enable applications to list all active downloads.

This API will enable applications to interact with active and completed downloads.

The API may reuse existing Gecko Download Manager objects.

Basic API proposal from Fabrice (designed a while back):

interface DownloadManager : EventTarget { // ondownloadstart, etc.
  Promise<Download[]> getDownloads();
  ... // other misc functions like clearDone() ?

interface Download : EventTarget { // onprogress, onload, etc.
  long size;
  long downloaded;
  DOMString state; // "running", "paused", "canceled"
  DOMString uri;
  void cancel();
  void pause();
  void resume();
Created attachment 822075 [details] [diff] [review]
patch 1

This patch makes the changes needed to let downloads end up in the default storage area (either the internal storage or the sdcard) and neither block on a confirmation prompt.
I may understand why a download API is needed for iterating/pausing/resuming/.. downloads, and this is fine.

But can we additionaly bind the html5 download attribute to triggers downloads as well. Then websites/bookmarks will be able to opt-in in a cross-browser compatible way.

For example with the download attribute you can do:
 <a href="foo.pdf" download="save_as_bar.pdf">

This will launch the file foo.pdf and save it as save_as_bar.pdf.
I assume that if someone wants to trigger that with JS directly you can just do an xhr or a bit more ugly:
 var a = document.createElement('a');
 a.href = 'foo.pdf';
 a.download = 'save_as_bar.pdf';

Or something similar.
This is a little bit ugly but at least it should work all over the place, and websites/bookmars/applications will not need to know anything about a special API that will mostly be used to manage downloads.

Does it makes sense or did I missed some dependencies of this bug that was looking to do that?
Blocks: 926955
Vivien, this api is explicitely only about *managing* downloads, not starting them. The usual ways to trigger downloads are supported:
- download attribute,
- content-disposition http header,
- unknown mime type.
Depends on: 934677
Blocks: 936342
No longer blocks: 936342
Depends on: 938023
Whiteboard: [systemsfe]

Comment 4

5 years ago
This is done as far as I know.
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.3 Sprint 6 - 12/6
You need to log in before you can comment on or make changes to this bug.