dom/webidl/Downloads.webidl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial