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"
17 namespace mozilla::dom::cache
{
19 class CacheStreamControlParent
;
22 class StreamList final
: public Context::Activity
,
23 public SafeRefCounted
<StreamList
> {
25 StreamList(SafeRefPtr
<Manager
> aManager
, SafeRefPtr
<Context
> aContext
);
27 Manager
& GetManager() const;
28 bool ShouldOpenStreamFor(const nsID
& aId
) const;
30 void SetStreamControl(CacheStreamControlParent
* aStreamControl
);
31 void RemoveStreamControl(CacheStreamControlParent
* aStreamControl
);
33 void Activate(CacheId aCacheId
);
35 void Add(const nsID
& aId
, nsCOMPtr
<nsIInputStream
>&& aStream
);
36 already_AddRefed
<nsIInputStream
> Extract(const nsID
& aId
);
38 void NoteClosed(const nsID
& aId
);
42 // Context::Activity methods
43 virtual void Cancel() override
;
44 virtual bool MatchesCacheId(CacheId aCacheId
) const override
;
48 explicit Entry(const nsID
& aId
, nsCOMPtr
<nsIInputStream
>&& aStream
)
49 : mId(aId
), mStream(std::move(aStream
)) {}
52 nsCOMPtr
<nsIInputStream
> mStream
;
54 SafeRefPtr
<Manager
> mManager
;
55 SafeRefPtr
<Context
> mContext
;
57 CacheStreamControlParent
* mStreamControl
;
58 nsTArray
<Entry
> mList
;
65 MOZ_DECLARE_REFCOUNTED_TYPENAME(cache::StreamList
)
68 } // namespace mozilla::dom::cache
70 #endif // mozilla_dom_cache_StreamList_h