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 "nsIStreamListener.idl" michael@0: michael@0: interface nsIFile; michael@0: interface nsIDownloadObserver; michael@0: michael@0: /** michael@0: * nsIDownloader michael@0: * michael@0: * A downloader is a special implementation of a nsIStreamListener that will michael@0: * make the contents of the stream available as a file. This may utilize the michael@0: * disk cache as an optimization to avoid an extra copy of the data on disk. michael@0: * The resulting file is valid from the time the downloader completes until michael@0: * the last reference to the downloader is released. michael@0: */ michael@0: [scriptable, uuid(fafe41a9-a531-4d6d-89bc-588a6522fb4e)] michael@0: interface nsIDownloader : nsIStreamListener michael@0: { michael@0: /** michael@0: * Initialize this downloader michael@0: * michael@0: * @param observer michael@0: * the observer to be notified when the download completes. michael@0: * @param downloadLocation michael@0: * the location where the stream contents should be written. michael@0: * if null, the downloader will select a location and the michael@0: * resulting file will be deleted (or otherwise made invalid) michael@0: * when the downloader object is destroyed. if an explicit michael@0: * download location is specified then the resulting file will michael@0: * not be deleted, and it will be the callers responsibility michael@0: * to keep track of the file, etc. michael@0: */ michael@0: void init(in nsIDownloadObserver observer, michael@0: in nsIFile downloadLocation); michael@0: }; michael@0: michael@0: [scriptable, uuid(44b3153e-a54e-4077-a527-b0325e40924e)] michael@0: interface nsIDownloadObserver : nsISupports michael@0: { michael@0: /** michael@0: * Called to signal a download that has completed. michael@0: */ michael@0: void onDownloadComplete(in nsIDownloader downloader, michael@0: in nsIRequest request, michael@0: in nsISupports ctxt, michael@0: in nsresult status, michael@0: in nsIFile result); michael@0: };