Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 :
6 : #ifndef nsAboutCacheEntry_h__
7 : #define nsAboutCacheEntry_h__
8 :
9 : #include "nsIAboutModule.h"
10 : #include "nsICacheEntryOpenCallback.h"
11 : #include "nsICacheEntry.h"
12 : #include "nsIStreamListener.h"
13 : #include "nsString.h"
14 : #include "nsCOMPtr.h"
15 :
16 : class nsIAsyncOutputStream;
17 : class nsIInputStream;
18 : class nsILoadContextInfo;
19 : class nsIURI;
20 : class nsCString;
21 :
22 0 : class nsAboutCacheEntry final : public nsIAboutModule
23 : {
24 : public:
25 : NS_DECL_ISUPPORTS
26 : NS_DECL_NSIABOUTMODULE
27 :
28 : private:
29 0 : virtual ~nsAboutCacheEntry() {}
30 :
31 : class Channel final : public nsICacheEntryOpenCallback
32 : , public nsICacheEntryMetaDataVisitor
33 : , public nsIStreamListener
34 : , public nsIChannel
35 : {
36 : public:
37 : NS_DECL_ISUPPORTS
38 : NS_DECL_NSICACHEENTRYOPENCALLBACK
39 : NS_DECL_NSICACHEENTRYMETADATAVISITOR
40 : NS_DECL_NSIREQUESTOBSERVER
41 : NS_DECL_NSISTREAMLISTENER
42 0 : NS_FORWARD_SAFE_NSICHANNEL(mChannel)
43 0 : NS_FORWARD_SAFE_NSIREQUEST(mChannel)
44 :
45 0 : Channel()
46 0 : : mBuffer(nullptr)
47 : , mWaitingForData(false)
48 0 : , mHexDumpState(0)
49 0 : {}
50 :
51 : private:
52 0 : virtual ~Channel() {}
53 :
54 : public:
55 : MOZ_MUST_USE nsresult Init(nsIURI* uri, nsILoadInfo* aLoadInfo);
56 :
57 : MOZ_MUST_USE nsresult GetContentStream(nsIURI *, nsIInputStream **);
58 : MOZ_MUST_USE nsresult OpenCacheEntry(nsIURI *);
59 : MOZ_MUST_USE nsresult OpenCacheEntry();
60 : MOZ_MUST_USE nsresult WriteCacheEntryDescription(nsICacheEntry *);
61 : MOZ_MUST_USE nsresult WriteCacheEntryUnavailable();
62 : MOZ_MUST_USE nsresult ParseURI(nsIURI *uri, nsACString &storageName,
63 : nsILoadContextInfo **loadInfo,
64 : nsCString &enahnceID,
65 : nsIURI **cacheUri);
66 : void CloseContent();
67 :
68 : static MOZ_MUST_USE nsresult
69 : PrintCacheData(nsIInputStream *aInStream,
70 : void *aClosure,
71 : const char *aFromSegment,
72 : uint32_t aToOffset,
73 : uint32_t aCount,
74 : uint32_t *aWriteCount);
75 :
76 : private:
77 : nsCString mStorageName, mEnhanceId;
78 : nsCOMPtr<nsILoadContextInfo> mLoadInfo;
79 : nsCOMPtr<nsIURI> mCacheURI;
80 :
81 : nsCString *mBuffer;
82 : nsCOMPtr<nsIAsyncOutputStream> mOutputStream;
83 : bool mWaitingForData;
84 : uint32_t mHexDumpState;
85 :
86 : nsCOMPtr<nsIChannel> mChannel;
87 : };
88 : };
89 :
90 : #define NS_ABOUT_CACHE_ENTRY_MODULE_CID \
91 : { /* 7fa5237d-b0eb-438f-9e50-ca0166e63788 */ \
92 : 0x7fa5237d, \
93 : 0xb0eb, \
94 : 0x438f, \
95 : {0x9e, 0x50, 0xca, 0x01, 0x66, 0xe6, 0x37, 0x88} \
96 : }
97 :
98 : #endif // nsAboutCacheEntry_h__
|