nsIDownloader.idl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsIStreamListener.idl"
  5. interface nsIFile;
  6. interface nsIDownloadObserver;
  7. /**
  8. * nsIDownloader
  9. *
  10. * A downloader is a special implementation of a nsIStreamListener that will
  11. * make the contents of the stream available as a file. This may utilize the
  12. * disk cache as an optimization to avoid an extra copy of the data on disk.
  13. * The resulting file is valid from the time the downloader completes until
  14. * the last reference to the downloader is released.
  15. */
  16. [scriptable, uuid(fafe41a9-a531-4d6d-89bc-588a6522fb4e)]
  17. interface nsIDownloader : nsIStreamListener
  18. {
  19. /**
  20. * Initialize this downloader
  21. *
  22. * @param observer
  23. * the observer to be notified when the download completes.
  24. * @param downloadLocation
  25. * the location where the stream contents should be written.
  26. * if null, the downloader will select a location and the
  27. * resulting file will be deleted (or otherwise made invalid)
  28. * when the downloader object is destroyed. if an explicit
  29. * download location is specified then the resulting file will
  30. * not be deleted, and it will be the callers responsibility
  31. * to keep track of the file, etc.
  32. */
  33. void init(in nsIDownloadObserver observer,
  34. in nsIFile downloadLocation);
  35. };
  36. [scriptable, uuid(44b3153e-a54e-4077-a527-b0325e40924e)]
  37. interface nsIDownloadObserver : nsISupports
  38. {
  39. /**
  40. * Called to signal a download that has completed.
  41. */
  42. void onDownloadComplete(in nsIDownloader downloader,
  43. in nsIRequest request,
  44. in nsISupports ctxt,
  45. in nsresult status,
  46. in nsIFile result);
  47. };