nsIAsyncStreamCopier.idl 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. // You should prefer nsIAsyncStreamCopier2
  10. [scriptable, uuid(5a19ca27-e041-4aca-8287-eb248d4c50c0)]
  11. interface nsIAsyncStreamCopier : nsIRequest
  12. {
  13. /**
  14. * Initialize the stream copier.
  15. *
  16. * @param aSource
  17. * contains the data to be copied.
  18. * @param aSink
  19. * specifies the destination for the data.
  20. * @param aTarget
  21. * specifies the thread on which the copy will occur. a null value
  22. * is permitted and will cause the copy to occur on an unspecified
  23. * background thread.
  24. * @param aSourceBuffered
  25. * true if aSource implements ReadSegments.
  26. * @param aSinkBuffered
  27. * true if aSink implements WriteSegments.
  28. * @param aChunkSize
  29. * specifies how many bytes to read/write at a time. this controls
  30. * the granularity of the copying. it should match the segment size
  31. * of the "buffered" streams involved.
  32. * @param aCloseSource
  33. * true if aSource should be closed after copying.
  34. * @param aCloseSink
  35. * true if aSink should be closed after copying.
  36. *
  37. * NOTE: at least one of the streams must be buffered. If you do not know
  38. * whether your streams are buffered, you should use nsIAsyncStreamCopier2
  39. * instead.
  40. */
  41. void init(in nsIInputStream aSource,
  42. in nsIOutputStream aSink,
  43. in nsIEventTarget aTarget,
  44. in boolean aSourceBuffered,
  45. in boolean aSinkBuffered,
  46. in unsigned long aChunkSize,
  47. in boolean aCloseSource,
  48. in boolean aCloseSink);
  49. /**
  50. * asyncCopy triggers the start of the copy. The observer will be notified
  51. * when the copy completes.
  52. *
  53. * @param aObserver
  54. * receives notifications.
  55. * @param aObserverContext
  56. * passed to observer methods.
  57. */
  58. void asyncCopy(in nsIRequestObserver aObserver,
  59. in nsISupports aObserverContext);
  60. };