netwerk/base/public/nsIIncrementalDownload.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/public/nsIIncrementalDownload.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsIRequest.idl"
    1.11 +
    1.12 +interface nsIURI;
    1.13 +interface nsIFile;
    1.14 +interface nsIRequestObserver;
    1.15 +
    1.16 +/**
    1.17 + * An incremental download object attempts to fetch a file piecemeal over time
    1.18 + * in an effort to minimize network bandwidth usage.
    1.19 + *
    1.20 + * Canceling a background download does not cause the file on disk to be
    1.21 + * deleted.
    1.22 + */
    1.23 +[scriptable, uuid(6687823f-56c4-461d-93a1-7f6cb7dfbfba)]
    1.24 +interface nsIIncrementalDownload : nsIRequest
    1.25 +{
    1.26 +  /**
    1.27 +   * Initialize the incremental download object.  If the destination file
    1.28 +   * already exists, then only the remaining portion of the file will be
    1.29 +   * fetched.
    1.30 +   *
    1.31 +   * NOTE: The downloader will create the destination file if it does not
    1.32 +   * already exist.  It will create the file with the permissions 0600 if
    1.33 +   * needed.  To affect the permissions of the file, consumers of this
    1.34 +   * interface may create an empty file at the specified destination prior to
    1.35 +   * starting the incremental download.
    1.36 +   *
    1.37 +   * NOTE: Since this class may create a temporary file at the specified
    1.38 +   * destination, it is advisable for the consumer of this interface to specify
    1.39 +   * a file name for the destination that would not tempt the user into
    1.40 +   * double-clicking it.  For example, it might be wise to append a file
    1.41 +   * extension like ".part" to the end of the destination to protect users from
    1.42 +   * accidentally running "blah.exe" before it is a complete file.
    1.43 +   *
    1.44 +   * @param uri
    1.45 +   *        The URI to fetch.
    1.46 +   * @param destination
    1.47 +   *        The location where the file is to be stored.
    1.48 +   * @param chunkSize
    1.49 +   *        The size of the chunks to fetch.  A non-positive value results in
    1.50 +   *        the default chunk size being used.
    1.51 +   * @param intervalInSeconds
    1.52 +   *        The amount of time to wait between fetching chunks.  Pass a
    1.53 +   *        negative to use the default interval, or 0 to fetch the remaining
    1.54 +   *        part of the file in one chunk.
    1.55 +   */
    1.56 +  void init(in nsIURI uri, in nsIFile destination, in long chunkSize,
    1.57 +            in long intervalInSeconds);
    1.58 +
    1.59 +  /**
    1.60 +   * The URI being fetched.
    1.61 +   */
    1.62 +  readonly attribute nsIURI URI;
    1.63 +
    1.64 +  /**
    1.65 +   * The URI being fetched after any redirects have been followed.  This
    1.66 +   * attribute is set just prior to calling OnStartRequest on the observer
    1.67 +   * passed to the start method.
    1.68 +   */
    1.69 +  readonly attribute nsIURI finalURI;
    1.70 +
    1.71 +  /**
    1.72 +   * The file where the download is being written.
    1.73 +   */
    1.74 +  readonly attribute nsIFile destination;
    1.75 +
    1.76 +  /**
    1.77 +   * The total number of bytes for the requested file.  This attribute is set
    1.78 +   * just prior to calling OnStartRequest on the observer passed to the start
    1.79 +   * method.
    1.80 +   *
    1.81 +   * This attribute has a value of -1 if the total size is unknown.
    1.82 +   */
    1.83 +  readonly attribute long long totalSize;
    1.84 +
    1.85 +  /**
    1.86 +   * The current number of bytes downloaded so far.  This attribute is set just
    1.87 +   * prior to calling OnStartRequest on the observer passed to the start
    1.88 +   * method.
    1.89 +   *
    1.90 +   * This attribute has a value of -1 if the current size is unknown.
    1.91 +   */
    1.92 +  readonly attribute long long currentSize;
    1.93 +
    1.94 +  /**
    1.95 +   * Start the incremental download.
    1.96 +   *
    1.97 +   * @param observer
    1.98 +   *        An observer to be notified of various events.  OnStartRequest is
    1.99 +   *        called when finalURI and totalSize have been determined or when an
   1.100 +   *        error occurs.  OnStopRequest is called when the file is completely
   1.101 +   *        downloaded or when an error occurs.  If this object implements
   1.102 +   *        nsIProgressEventSink, then its OnProgress method will be called as
   1.103 +   *        data is written to the destination file.  If this object implements
   1.104 +   *        nsIInterfaceRequestor, then it will be assigned as the underlying
   1.105 +   *        channel's notification callbacks, which allows it to provide a
   1.106 +   *        nsIAuthPrompt implementation if needed by the channel, for example.
   1.107 +   * @param ctxt
   1.108 +   *        User defined object forwarded to the observer's methods.
   1.109 +   */
   1.110 +  void start(in nsIRequestObserver observer,
   1.111 +             in nsISupports ctxt);
   1.112 +};

mercurial