2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-09-13 10:10:03 +04:00
|
|
|
|
|
|
|
#ifndef nsAboutCache_h__
|
|
|
|
#define nsAboutCache_h__
|
|
|
|
|
|
|
|
#include "nsIAboutModule.h"
|
2014-05-01 15:28:12 +04:00
|
|
|
#include "nsICacheStorageVisitor.h"
|
|
|
|
#include "nsICacheStorage.h"
|
2000-09-13 10:10:03 +04:00
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIOutputStream.h"
|
2014-05-01 15:28:12 +04:00
|
|
|
#include "nsILoadContextInfo.h"
|
2000-09-13 10:10:03 +04:00
|
|
|
|
2001-03-10 12:35:44 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2014-05-01 15:28:12 +04:00
|
|
|
#include "nsTArray.h"
|
2000-09-13 10:10:03 +04:00
|
|
|
|
2016-06-01 08:20:17 +03:00
|
|
|
#define NS_FORWARD_SAFE_NSICHANNEL_SUBSET(_to) \
|
|
|
|
NS_IMETHOD GetOriginalURI(nsIURI * *aOriginalURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOriginalURI(aOriginalURI); } \
|
|
|
|
NS_IMETHOD SetOriginalURI(nsIURI *aOriginalURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOriginalURI(aOriginalURI); } \
|
|
|
|
NS_IMETHOD GetURI(nsIURI * *aURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetURI(aURI); } \
|
|
|
|
NS_IMETHOD GetOwner(nsISupports * *aOwner) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOwner(aOwner); } \
|
|
|
|
NS_IMETHOD SetOwner(nsISupports *aOwner) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOwner(aOwner); } \
|
|
|
|
NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetNotificationCallbacks(aNotificationCallbacks); } \
|
|
|
|
NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor *aNotificationCallbacks) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetNotificationCallbacks(aNotificationCallbacks); } \
|
|
|
|
NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSecurityInfo(aSecurityInfo); } \
|
|
|
|
NS_IMETHOD GetContentType(nsACString & aContentType) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentType(aContentType); } \
|
|
|
|
NS_IMETHOD SetContentType(const nsACString & aContentType) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentType(aContentType); } \
|
|
|
|
NS_IMETHOD GetContentCharset(nsACString & aContentCharset) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentCharset(aContentCharset); } \
|
|
|
|
NS_IMETHOD SetContentCharset(const nsACString & aContentCharset) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentCharset(aContentCharset); } \
|
|
|
|
NS_IMETHOD GetContentLength(int64_t *aContentLength) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentLength(aContentLength); } \
|
|
|
|
NS_IMETHOD SetContentLength(int64_t aContentLength) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentLength(aContentLength); } \
|
|
|
|
NS_IMETHOD GetContentDisposition(uint32_t *aContentDisposition) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentDisposition(aContentDisposition); } \
|
|
|
|
NS_IMETHOD SetContentDisposition(uint32_t aContentDisposition) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentDisposition(aContentDisposition); } \
|
|
|
|
NS_IMETHOD GetContentDispositionFilename(nsAString & aContentDispositionFilename) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentDispositionFilename(aContentDispositionFilename); } \
|
|
|
|
NS_IMETHOD SetContentDispositionFilename(const nsAString & aContentDispositionFilename) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentDispositionFilename(aContentDispositionFilename); } \
|
|
|
|
NS_IMETHOD GetContentDispositionHeader(nsACString & aContentDispositionHeader) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentDispositionHeader(aContentDispositionHeader); } \
|
|
|
|
NS_IMETHOD GetLoadInfo(nsILoadInfo * *aLoadInfo) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetLoadInfo(aLoadInfo); } \
|
|
|
|
NS_IMETHOD SetLoadInfo(nsILoadInfo *aLoadInfo) override { return !_to ? NS_ERROR_NULL_POINTER : _to->SetLoadInfo(aLoadInfo); } \
|
2017-04-20 05:15:06 +03:00
|
|
|
NS_IMETHOD GetIsDocument(bool *aIsDocument) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsDocument(aIsDocument); }; \
|
2016-06-01 08:20:17 +03:00
|
|
|
|
2015-03-21 21:35:18 +03:00
|
|
|
class nsAboutCache final : public nsIAboutModule
|
2000-09-13 10:10:03 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIABOUTMODULE
|
|
|
|
|
2003-01-09 01:35:09 +03:00
|
|
|
nsAboutCache() {}
|
2000-09-13 10:10:03 +04:00
|
|
|
|
2016-10-03 09:53:30 +03:00
|
|
|
static MOZ_MUST_USE nsresult
|
2000-09-13 10:10:03 +04:00
|
|
|
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
|
|
|
|
2016-10-03 09:53:30 +03:00
|
|
|
static MOZ_MUST_USE nsresult
|
2014-05-01 15:28:12 +04:00
|
|
|
GetStorage(nsACString const & storageName, nsILoadContextInfo* loadInfo,
|
|
|
|
nsICacheStorage **storage);
|
|
|
|
|
2000-09-13 10:10:03 +04:00
|
|
|
protected:
|
2014-06-24 20:36:44 +04:00
|
|
|
virtual ~nsAboutCache() {}
|
|
|
|
|
2016-05-17 12:20:00 +03:00
|
|
|
class Channel final : public nsIChannel
|
|
|
|
, public nsICacheStorageVisitor
|
|
|
|
{
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICACHESTORAGEVISITOR
|
|
|
|
NS_FORWARD_SAFE_NSIREQUEST(mChannel)
|
2016-06-01 08:20:17 +03:00
|
|
|
NS_FORWARD_SAFE_NSICHANNEL_SUBSET(mChannel)
|
|
|
|
NS_IMETHOD AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) override;
|
|
|
|
NS_IMETHOD AsyncOpen2(nsIStreamListener *aListener) override;
|
|
|
|
NS_IMETHOD Open(nsIInputStream * *_retval) override;
|
|
|
|
NS_IMETHOD Open2(nsIInputStream * *_retval) override;
|
2016-05-17 12:20:00 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~Channel() {}
|
|
|
|
|
|
|
|
public:
|
2016-10-03 09:53:30 +03:00
|
|
|
MOZ_MUST_USE nsresult Init(nsIURI* aURI, nsILoadInfo* aLoadInfo);
|
|
|
|
MOZ_MUST_USE nsresult ParseURI(nsIURI * uri, nsACString & storage);
|
2016-05-17 12:20:00 +03:00
|
|
|
|
|
|
|
// Finds a next storage we wish to visit (we use this method
|
|
|
|
// even there is a specified storage name, which is the only
|
|
|
|
// one in the list then.) Posts FireVisitStorage() when found.
|
2016-10-03 09:53:30 +03:00
|
|
|
MOZ_MUST_USE nsresult VisitNextStorage();
|
2016-05-17 12:20:00 +03:00
|
|
|
// Helper method that calls VisitStorage() for the current storage.
|
2016-06-01 08:20:17 +03:00
|
|
|
// When it fails, OnCacheEntryVisitCompleted is simulated to close
|
2016-05-17 12:20:00 +03:00
|
|
|
// the output stream and thus the about:cache channel.
|
|
|
|
void FireVisitStorage();
|
|
|
|
// Kiks the visit cycle for the given storage, names can be:
|
|
|
|
// "disk", "memory", "appcache"
|
|
|
|
// Note: any newly added storage type has to be manually handled here.
|
2016-10-03 09:53:30 +03:00
|
|
|
MOZ_MUST_USE nsresult VisitStorage(nsACString const & storageName);
|
2016-05-17 12:20:00 +03:00
|
|
|
|
|
|
|
// Writes content of mBuffer to mStream and truncates
|
2016-05-12 17:19:00 +03:00
|
|
|
// the buffer. It may fail when the input stream is closed by canceling
|
|
|
|
// the input stream channel. It can be used to stop the cache iteration
|
|
|
|
// process.
|
2016-10-03 09:53:30 +03:00
|
|
|
MOZ_MUST_USE nsresult FlushBuffer();
|
2016-05-17 12:20:00 +03:00
|
|
|
|
|
|
|
// Whether we are showing overview status of all available
|
|
|
|
// storages.
|
|
|
|
bool mOverview;
|
|
|
|
|
|
|
|
// Flag initially false, that indicates the entries header has
|
|
|
|
// been added to the output HTML.
|
|
|
|
bool mEntriesHeaderAdded;
|
|
|
|
|
2016-05-12 17:19:00 +03:00
|
|
|
// Cancelation flag
|
|
|
|
bool mCancel;
|
|
|
|
|
2016-05-17 12:20:00 +03:00
|
|
|
// The context we are working with.
|
|
|
|
nsCOMPtr<nsILoadContextInfo> mLoadInfo;
|
|
|
|
nsCString mContextString;
|
|
|
|
|
|
|
|
// The list of all storage names we want to visit
|
|
|
|
nsTArray<nsCString> mStorageList;
|
|
|
|
nsCString mStorageName;
|
|
|
|
nsCOMPtr<nsICacheStorage> mStorage;
|
|
|
|
|
|
|
|
// Output data buffering and streaming output
|
|
|
|
nsCString mBuffer;
|
|
|
|
nsCOMPtr<nsIOutputStream> mStream;
|
|
|
|
|
|
|
|
// The input stream channel, the one that actually does the job
|
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
|
|
|
};
|
2000-09-13 10:10:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NS_ABOUT_CACHE_MODULE_CID \
|
|
|
|
{ /* 9158c470-86e4-11d4-9be2-00e09872a416 */ \
|
|
|
|
0x9158c470, \
|
|
|
|
0x86e4, \
|
|
|
|
0x11d4, \
|
|
|
|
{0x9b, 0xe2, 0x00, 0xe0, 0x98, 0x72, 0xa4, 0x16} \
|
|
|
|
}
|
|
|
|
|
2001-03-13 23:06:42 +03:00
|
|
|
#endif // nsAboutCache_h__
|