CacheStreamControlParent.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_dom_cache_CacheStreamControlParent_h
  6. #define mozilla_dom_cache_CacheStreamControlParent_h
  7. #include "mozilla/dom/cache/PCacheStreamControlParent.h"
  8. #include "mozilla/dom/cache/StreamControl.h"
  9. #include "nsTObserverArray.h"
  10. namespace mozilla {
  11. namespace ipc {
  12. class AutoIPCStream;
  13. } // namespace ipc
  14. namespace dom {
  15. namespace cache {
  16. class ReadStream;
  17. class StreamList;
  18. class CacheStreamControlParent final : public PCacheStreamControlParent
  19. , public StreamControl
  20. {
  21. public:
  22. CacheStreamControlParent();
  23. ~CacheStreamControlParent();
  24. void SetStreamList(StreamList* aStreamList);
  25. void Close(const nsID& aId);
  26. void CloseAll();
  27. void Shutdown();
  28. // StreamControl methods
  29. virtual void
  30. SerializeControl(CacheReadStream* aReadStreamOut) override;
  31. virtual void
  32. SerializeStream(CacheReadStream* aReadStreamOut, nsIInputStream* aStream,
  33. nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList) override;
  34. private:
  35. virtual void
  36. NoteClosedAfterForget(const nsID& aId) override;
  37. #ifdef DEBUG
  38. virtual void
  39. AssertOwningThread() override;
  40. #endif
  41. // PCacheStreamControlParent methods
  42. virtual void ActorDestroy(ActorDestroyReason aReason) override;
  43. virtual bool RecvNoteClosed(const nsID& aId) override;
  44. void NotifyClose(const nsID& aId);
  45. void NotifyCloseAll();
  46. // Cycle with StreamList via a weak-ref to us. Cleanup occurs when the actor
  47. // is deleted by the PBackground manager. ActorDestroy() then calls
  48. // StreamList::RemoveStreamControl() to clear the weak ref.
  49. RefPtr<StreamList> mStreamList;
  50. NS_DECL_OWNINGTHREAD
  51. };
  52. } // namespace cache
  53. } // namespace dom
  54. } // namespace mozilla
  55. #endif // mozilla_dom_cache_CacheStreamControlParent_h