Bug 1733673 [wpt PR 31066] - Annotate CSS Transforms WPT reftests as fuzzy where...
[gecko.git] / dom / cache / StreamList.h
blob5b1868ffb19d460ad22112bba1de2d8e7823d900
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_cache_StreamList_h
8 #define mozilla_dom_cache_StreamList_h
10 #include "mozilla/dom/SafeRefPtr.h"
11 #include "mozilla/dom/cache/Context.h"
12 #include "mozilla/dom/cache/Types.h"
13 #include "nsTArray.h"
15 class nsIInputStream;
17 namespace mozilla {
18 namespace dom {
19 namespace cache {
21 class CacheStreamControlParent;
22 class Manager;
24 class StreamList final : public Context::Activity,
25 public SafeRefCounted<StreamList> {
26 public:
27 StreamList(SafeRefPtr<Manager> aManager, SafeRefPtr<Context> aContext);
29 Manager& GetManager() const;
30 bool ShouldOpenStreamFor(const nsID& aId) const;
32 void SetStreamControl(CacheStreamControlParent* aStreamControl);
33 void RemoveStreamControl(CacheStreamControlParent* aStreamControl);
35 void Activate(CacheId aCacheId);
37 void Add(const nsID& aId, nsCOMPtr<nsIInputStream>&& aStream);
38 already_AddRefed<nsIInputStream> Extract(const nsID& aId);
40 void NoteClosed(const nsID& aId);
41 void NoteClosedAll();
42 void CloseAll();
44 // Context::Activity methods
45 virtual void Cancel() override;
46 virtual bool MatchesCacheId(CacheId aCacheId) const override;
48 private:
49 struct Entry {
50 explicit Entry(const nsID& aId, nsCOMPtr<nsIInputStream>&& aStream)
51 : mId(aId), mStream(std::move(aStream)) {}
53 nsID mId;
54 nsCOMPtr<nsIInputStream> mStream;
56 SafeRefPtr<Manager> mManager;
57 SafeRefPtr<Context> mContext;
58 CacheId mCacheId;
59 CacheStreamControlParent* mStreamControl;
60 nsTArray<Entry> mList;
61 bool mActivated;
63 public:
64 ~StreamList();
66 NS_DECL_OWNINGTHREAD
67 MOZ_DECLARE_REFCOUNTED_TYPENAME(cache::StreamList)
70 } // namespace cache
71 } // namespace dom
72 } // namespace mozilla
74 #endif // mozilla_dom_cache_StreamList_h