nsIAsyncStreamCopier2.idl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "nsIRequest.idl"
  5. interface nsIInputStream;
  6. interface nsIOutputStream;
  7. interface nsIRequestObserver;
  8. interface nsIEventTarget;
  9. [scriptable, uuid(a5b2decf-4ede-4801-8b38-e5fe5db46bf2)]
  10. interface nsIAsyncStreamCopier2 : nsIRequest
  11. {
  12. /**
  13. * Initialize the stream copier.
  14. *
  15. * If neither the source nor the sink are buffered, buffering will
  16. * be automatically added to the sink.
  17. *
  18. *
  19. * @param aSource
  20. * contains the data to be copied.
  21. * @param aSink
  22. * specifies the destination for the data.
  23. * @param aTarget
  24. * specifies the thread on which the copy will occur. a null value
  25. * is permitted and will cause the copy to occur on an unspecified
  26. * background thread.
  27. * @param aChunkSize
  28. * specifies how many bytes to read/write at a time. this controls
  29. * the granularity of the copying. it should match the segment size
  30. * of the "buffered" streams involved.
  31. * @param aCloseSource
  32. * true if aSource should be closed after copying (this is generally
  33. * the desired behavior).
  34. * @param aCloseSink
  35. * true if aSink should be closed after copying (this is generally
  36. * the desired behavior).
  37. */
  38. void init(in nsIInputStream aSource,
  39. in nsIOutputStream aSink,
  40. in nsIEventTarget aTarget,
  41. in unsigned long aChunkSize,
  42. in boolean aCloseSource,
  43. in boolean aCloseSink);
  44. /**
  45. * asyncCopy triggers the start of the copy. The observer will be notified
  46. * when the copy completes.
  47. *
  48. * @param aObserver
  49. * receives notifications.
  50. * @param aObserverContext
  51. * passed to observer methods.
  52. */
  53. void asyncCopy(in nsIRequestObserver aObserver,
  54. in nsISupports aObserverContext);
  55. };