dom/webidl/Downloads.webidl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 4 * You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5 */
michael@0 6
michael@0 7 // Represents the state of a download.
michael@0 8 // "downloading": The resource is actively transfering.
michael@0 9 // "stopped" : No network tranfer is happening.
michael@0 10 // "succeeded" : The resource has been downloaded successfully.
michael@0 11 // "finalized" : We won't try to download this resource, but the DOM
michael@0 12 // object is still alive.
michael@0 13 enum DownloadState {
michael@0 14 "downloading",
michael@0 15 "stopped",
michael@0 16 "succeeded",
michael@0 17 "finalized"
michael@0 18 };
michael@0 19
michael@0 20 //
michael@0 21 // XXXTODO: When we have a generic way to do feature detection in marketplace
michael@0 22 // we will *STOP* using the pref and use the function like DOMDownload
michael@0 23 // and DownloadEvent.
michael@0 24 //
michael@0 25 [NoInterfaceObject,
michael@0 26 NavigatorProperty="mozDownloadManager",
michael@0 27 JSImplementation="@mozilla.org/downloads/manager;1",
michael@0 28 Pref="dom.mozDownloads.enabled"]
michael@0 29 interface DOMDownloadManager : EventTarget {
michael@0 30 // This promise returns an array of downloads with all the current
michael@0 31 // download objects.
michael@0 32 Promise getDownloads();
michael@0 33
michael@0 34 // Removes one download from the downloads set. Returns a promise resolved
michael@0 35 // with the finalized download.
michael@0 36 Promise remove(DOMDownload download);
michael@0 37
michael@0 38 // Removes all the completed downloads from the set.
michael@0 39 Promise clearAllDone();
michael@0 40
michael@0 41 // Fires when a new download starts.
michael@0 42 attribute EventHandler ondownloadstart;
michael@0 43 };
michael@0 44
michael@0 45 [JSImplementation="@mozilla.org/downloads/download;1",
michael@0 46 Func="Navigator::HasDownloadsSupport"]
michael@0 47 interface DOMDownload : EventTarget {
michael@0 48 // The full size of the resource.
michael@0 49 readonly attribute long long totalBytes;
michael@0 50
michael@0 51 // The number of bytes that we have currently downloaded.
michael@0 52 readonly attribute long long currentBytes;
michael@0 53
michael@0 54 // The url of the resource.
michael@0 55 readonly attribute DOMString url;
michael@0 56
michael@0 57 // The path in local storage where the file will end up once the download
michael@0 58 // is complete.
michael@0 59 readonly attribute DOMString path;
michael@0 60
michael@0 61 // The state of the download.
michael@0 62 readonly attribute DownloadState state;
michael@0 63
michael@0 64 // The mime type for this resource.
michael@0 65 readonly attribute DOMString contentType;
michael@0 66
michael@0 67 // The timestamp this download started.
michael@0 68 readonly attribute Date startTime;
michael@0 69
michael@0 70 // An opaque identifier for this download. All instances of the same
michael@0 71 // download (eg. in different windows) will have the same id.
michael@0 72 readonly attribute DOMString id;
michael@0 73
michael@0 74 // A DOM error object, that will be not null when a download is stopped
michael@0 75 // because something failed.
michael@0 76 readonly attribute DOMError? error;
michael@0 77
michael@0 78 // Pauses the download.
michael@0 79 Promise pause();
michael@0 80
michael@0 81 // Resumes the download. This resolves only once the download has
michael@0 82 // succeeded.
michael@0 83 Promise resume();
michael@0 84
michael@0 85 // This event is triggered anytime a property of the object changes:
michael@0 86 // - when the transfer progresses, updating currentBytes.
michael@0 87 // - when the state and/or error attributes change.
michael@0 88 attribute EventHandler onstatechange;
michael@0 89 };

mercurial