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