Backed out 2 changesets (bug 1539720) for causing caret related failures. CLOSED...
[gecko.git] / dom / cache / StreamList.h
blob2fe6bb9809fa9567b5e5bcd1a1ad6660c911fc6e
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::dom::cache {
19 class CacheStreamControlParent;
20 class Manager;
22 class StreamList final : public Context::Activity,
23 public SafeRefCounted<StreamList> {
24 public:
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);
39 void NoteClosedAll();
40 void CloseAll();
42 // Context::Activity methods
43 virtual void Cancel() override;
44 virtual bool MatchesCacheId(CacheId aCacheId) const override;
46 private:
47 struct Entry {
48 explicit Entry(const nsID& aId, nsCOMPtr<nsIInputStream>&& aStream)
49 : mId(aId), mStream(std::move(aStream)) {}
51 nsID mId;
52 nsCOMPtr<nsIInputStream> mStream;
54 SafeRefPtr<Manager> mManager;
55 SafeRefPtr<Context> mContext;
56 CacheId mCacheId;
57 CacheStreamControlParent* mStreamControl;
58 nsTArray<Entry> mList;
59 bool mActivated;
61 public:
62 ~StreamList();
64 NS_DECL_OWNINGTHREAD
65 MOZ_DECLARE_REFCOUNTED_TYPENAME(cache::StreamList)
68 } // namespace mozilla::dom::cache
70 #endif // mozilla_dom_cache_StreamList_h