StreamList.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_StreamList_h
  6. #define mozilla_dom_cache_StreamList_h
  7. #include "mozilla/dom/cache/Context.h"
  8. #include "mozilla/dom/cache/Types.h"
  9. #include "mozilla/RefPtr.h"
  10. #include "nsTArray.h"
  11. class nsIInputStream;
  12. namespace mozilla {
  13. namespace dom {
  14. namespace cache {
  15. class CacheStreamControlParent;
  16. class Manager;
  17. class StreamList final : public Context::Activity
  18. {
  19. public:
  20. StreamList(Manager* aManager, Context* aContext);
  21. void SetStreamControl(CacheStreamControlParent* aStreamControl);
  22. void RemoveStreamControl(CacheStreamControlParent* aStreamControl);
  23. void Activate(CacheId aCacheId);
  24. void Add(const nsID& aId, nsIInputStream* aStream);
  25. already_AddRefed<nsIInputStream> Extract(const nsID& aId);
  26. void NoteClosed(const nsID& aId);
  27. void NoteClosedAll();
  28. void Close(const nsID& aId);
  29. void CloseAll();
  30. // Context::Activity methods
  31. virtual void Cancel() override;
  32. virtual bool MatchesCacheId(CacheId aCacheId) const override;
  33. private:
  34. ~StreamList();
  35. struct Entry
  36. {
  37. nsID mId;
  38. nsCOMPtr<nsIInputStream> mStream;
  39. };
  40. RefPtr<Manager> mManager;
  41. RefPtr<Context> mContext;
  42. CacheId mCacheId;
  43. CacheStreamControlParent* mStreamControl;
  44. nsTArray<Entry> mList;
  45. bool mActivated;
  46. public:
  47. NS_INLINE_DECL_REFCOUNTING(cache::StreamList)
  48. };
  49. } // namespace cache
  50. } // namespace dom
  51. } // namespace mozilla
  52. #endif // mozilla_dom_cache_StreamList_h