michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsIRequest.idl" michael@0: michael@0: interface nsIURI; michael@0: interface nsIFile; michael@0: interface nsIRequestObserver; michael@0: michael@0: /** michael@0: * An incremental download object attempts to fetch a file piecemeal over time michael@0: * in an effort to minimize network bandwidth usage. michael@0: * michael@0: * Canceling a background download does not cause the file on disk to be michael@0: * deleted. michael@0: */ michael@0: [scriptable, uuid(6687823f-56c4-461d-93a1-7f6cb7dfbfba)] michael@0: interface nsIIncrementalDownload : nsIRequest michael@0: { michael@0: /** michael@0: * Initialize the incremental download object. If the destination file michael@0: * already exists, then only the remaining portion of the file will be michael@0: * fetched. michael@0: * michael@0: * NOTE: The downloader will create the destination file if it does not michael@0: * already exist. It will create the file with the permissions 0600 if michael@0: * needed. To affect the permissions of the file, consumers of this michael@0: * interface may create an empty file at the specified destination prior to michael@0: * starting the incremental download. michael@0: * michael@0: * NOTE: Since this class may create a temporary file at the specified michael@0: * destination, it is advisable for the consumer of this interface to specify michael@0: * a file name for the destination that would not tempt the user into michael@0: * double-clicking it. For example, it might be wise to append a file michael@0: * extension like ".part" to the end of the destination to protect users from michael@0: * accidentally running "blah.exe" before it is a complete file. michael@0: * michael@0: * @param uri michael@0: * The URI to fetch. michael@0: * @param destination michael@0: * The location where the file is to be stored. michael@0: * @param chunkSize michael@0: * The size of the chunks to fetch. A non-positive value results in michael@0: * the default chunk size being used. michael@0: * @param intervalInSeconds michael@0: * The amount of time to wait between fetching chunks. Pass a michael@0: * negative to use the default interval, or 0 to fetch the remaining michael@0: * part of the file in one chunk. michael@0: */ michael@0: void init(in nsIURI uri, in nsIFile destination, in long chunkSize, michael@0: in long intervalInSeconds); michael@0: michael@0: /** michael@0: * The URI being fetched. michael@0: */ michael@0: readonly attribute nsIURI URI; michael@0: michael@0: /** michael@0: * The URI being fetched after any redirects have been followed. This michael@0: * attribute is set just prior to calling OnStartRequest on the observer michael@0: * passed to the start method. michael@0: */ michael@0: readonly attribute nsIURI finalURI; michael@0: michael@0: /** michael@0: * The file where the download is being written. michael@0: */ michael@0: readonly attribute nsIFile destination; michael@0: michael@0: /** michael@0: * The total number of bytes for the requested file. This attribute is set michael@0: * just prior to calling OnStartRequest on the observer passed to the start michael@0: * method. michael@0: * michael@0: * This attribute has a value of -1 if the total size is unknown. michael@0: */ michael@0: readonly attribute long long totalSize; michael@0: michael@0: /** michael@0: * The current number of bytes downloaded so far. This attribute is set just michael@0: * prior to calling OnStartRequest on the observer passed to the start michael@0: * method. michael@0: * michael@0: * This attribute has a value of -1 if the current size is unknown. michael@0: */ michael@0: readonly attribute long long currentSize; michael@0: michael@0: /** michael@0: * Start the incremental download. michael@0: * michael@0: * @param observer michael@0: * An observer to be notified of various events. OnStartRequest is michael@0: * called when finalURI and totalSize have been determined or when an michael@0: * error occurs. OnStopRequest is called when the file is completely michael@0: * downloaded or when an error occurs. If this object implements michael@0: * nsIProgressEventSink, then its OnProgress method will be called as michael@0: * data is written to the destination file. If this object implements michael@0: * nsIInterfaceRequestor, then it will be assigned as the underlying michael@0: * channel's notification callbacks, which allows it to provide a michael@0: * nsIAuthPrompt implementation if needed by the channel, for example. michael@0: * @param ctxt michael@0: * User defined object forwarded to the observer's methods. michael@0: */ michael@0: void start(in nsIRequestObserver observer, michael@0: in nsISupports ctxt); michael@0: };