nsIncrementalStreamLoader.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsIncrementalStreamLoader_h__
  6. #define nsIncrementalStreamLoader_h__
  7. #include "nsIThreadRetargetableStreamListener.h"
  8. #include "nsIIncrementalStreamLoader.h"
  9. #include "nsCOMPtr.h"
  10. #include "mozilla/Attributes.h"
  11. #include "mozilla/Vector.h"
  12. class nsIRequest;
  13. class nsIncrementalStreamLoader final : public nsIIncrementalStreamLoader
  14. , public nsIThreadRetargetableStreamListener
  15. {
  16. public:
  17. NS_DECL_THREADSAFE_ISUPPORTS
  18. NS_DECL_NSIINCREMENTALSTREAMLOADER
  19. NS_DECL_NSIREQUESTOBSERVER
  20. NS_DECL_NSISTREAMLISTENER
  21. NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
  22. nsIncrementalStreamLoader();
  23. static nsresult
  24. Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
  25. protected:
  26. ~nsIncrementalStreamLoader();
  27. static nsresult WriteSegmentFun(nsIInputStream *, void *, const char *,
  28. uint32_t, uint32_t, uint32_t *);
  29. // Utility method to free mData, if present, and update other state to
  30. // reflect that no data has been allocated.
  31. void ReleaseData();
  32. nsCOMPtr<nsIIncrementalStreamLoaderObserver> mObserver;
  33. nsCOMPtr<nsISupports> mContext; // the observer's context
  34. nsCOMPtr<nsIRequest> mRequest;
  35. // Buffer to accumulate incoming data. We preallocate if contentSize is
  36. // available.
  37. mozilla::Vector<uint8_t, 0> mData;
  38. // Number of bytes read, which may differ from the number of bytes in mData,
  39. // since we incrementally remove from there.
  40. mozilla::Atomic<uint32_t, mozilla::Relaxed> mBytesRead;
  41. };
  42. #endif // nsIncrementalStreamLoader_h__