AltDataOutputStreamParent.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* -*- Mode: C++; tab-width: 8; 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 mozilla_net_AltDataOutputStreamParent_h
  6. #define mozilla_net_AltDataOutputStreamParent_h
  7. #include "mozilla/net/PAltDataOutputStreamParent.h"
  8. #include "nsIOutputStream.h"
  9. namespace mozilla {
  10. namespace net {
  11. // Forwards data received from the content process to an output stream.
  12. class AltDataOutputStreamParent
  13. : public PAltDataOutputStreamParent
  14. , public nsISupports
  15. {
  16. public:
  17. NS_DECL_ISUPPORTS
  18. // Called from NeckoParent::AllocPAltDataOutputStreamParent which also opens
  19. // the output stream.
  20. // aStream may be null
  21. explicit AltDataOutputStreamParent(nsIOutputStream* aStream);
  22. // Called when data is received from the content process.
  23. // We proceed to write that data to the output stream.
  24. virtual bool RecvWriteData(const nsCString& data) override;
  25. // Called when AltDataOutputStreamChild::Close() is
  26. // Closes and nulls the output stream.
  27. virtual bool RecvClose() override;
  28. virtual void ActorDestroy(ActorDestroyReason aWhy) override;
  29. // Sets an error that will be reported to the content process.
  30. void SetError(nsresult status) { mStatus = status; }
  31. private:
  32. virtual ~AltDataOutputStreamParent();
  33. nsCOMPtr<nsIOutputStream> mOutputStream;
  34. // In case any error occurs mStatus will be != NS_OK, and this status code will
  35. // be sent to the content process asynchronously.
  36. nsresult mStatus;
  37. };
  38. } // namespace net
  39. } // namespace mozilla
  40. #endif // mozilla_net_AltDataOutputStreamParent_h