nsAboutCacheEntry.h 3.1 KB

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