#ifndef FuzzingStreamListener_h_
#define FuzzingStreamListener_h_

#include "mozilla/SpinEventLoopUntil.h"
#include "nsCOMPtr.h"
#include "nsIStreamListener.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsString.h"

namespace mozilla {
namespace net {

class FuzzingStreamListener final : public nsIStreamListener {
 public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIREQUESTOBSERVER
  NS_DECL_NSISTREAMLISTENER

  FuzzingStreamListener() = default;

  void waitUntilDone() {
    SpinEventLoopUntil("net::FuzzingStreamListener::waitUntilDone"_ns,
                       [&]() { return mChannelDone; });
  }

  bool isDone() { return mChannelDone; }

 private:
  ~FuzzingStreamListener() = default;
  bool mChannelDone = false;
};

}  // namespace net
}  // namespace mozilla

#endif
