This commit is contained in:
Brian Smith 2023-09-27 19:24:08 -05:00 • committed by roytam1
commit 3979e4847c
2 changed files with 182 additions and 4 deletions

View file

@ -9,7 +9,9 @@
#include "Fetch.h"
#include "jsapi.h"
#include "nsIAsyncInputStream.h"
#include "nsIObserver.h"
#include "nsISupportsImpl.h"
#include "nsWeakReference.h"
class nsIGlobalObject;
@ -18,16 +20,26 @@ class nsIInputStream;
namespace mozilla {
namespace dom {
namespace workers {
class WorkerHolder;
}
class FetchStream final : public nsIInputStreamCallback
, public nsIObserver
, public nsSupportsWeakReference
{
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIINPUTSTREAMCALLBACK
NS_DECL_NSIOBSERVER
static JSObject*
Create(JSContext* aCx, nsIGlobalObject* aGlobal,
nsIInputStream* aInputStream, ErrorResult& aRv);
void
Close();
private:
FetchStream(nsIGlobalObject* aGlobal, nsIInputStream* aInputStream);
~FetchStream();
@ -63,6 +75,9 @@ private:
void
ErrorPropagation(JSContext* aCx, JS::HandleObject aStream, nsresult aRv);
void
CloseAndReleaseObjects();
// Common methods
enum State {
@ -98,6 +113,8 @@ private:
nsCOMPtr<nsIEventTarget> mOwningEventTarget;
UniquePtr<workers::WorkerHolder> mWorkerHolder;
JS::Heap<JSObject*> mReadableStream;
};