2013-09-20 13:11:25 +04:00
|
|
|
// Stuff to link the old imp to the new api - will go away!
|
|
|
|
|
|
|
|
#ifndef OLDWRAPPERS__H__
|
|
|
|
#define OLDWRAPPERS__H__
|
|
|
|
|
|
|
|
#include "nsICacheEntry.h"
|
|
|
|
#include "nsICacheListener.h"
|
|
|
|
#include "nsICacheStorage.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsICacheEntryOpenCallback.h"
|
|
|
|
#include "nsICacheEntryDescriptor.h"
|
2014-05-01 15:28:12 +04:00
|
|
|
#include "nsICacheStorageVisitor.h"
|
2013-09-20 13:11:25 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2013-09-26 23:37:03 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
class nsIURI;
|
|
|
|
class nsICacheEntryOpenCallback;
|
2014-04-24 20:50:46 +04:00
|
|
|
class nsICacheStorageConsumptionObserver;
|
2013-09-20 13:11:25 +04:00
|
|
|
class nsIApplicationCache;
|
|
|
|
class nsILoadContextInfo;
|
|
|
|
|
|
|
|
namespace mozilla { namespace net {
|
|
|
|
|
|
|
|
class CacheStorage;
|
|
|
|
|
|
|
|
class _OldCacheEntryWrapper : public nsICacheEntry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2014-08-21 21:47:38 +04:00
|
|
|
|
|
|
|
// nsICacheEntryDescriptor
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetExpirationTime(uint32_t expirationTime) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->SetExpirationTime(expirationTime);
|
|
|
|
}
|
2015-01-02 18:26:32 +03:00
|
|
|
nsresult OpenInputStream(uint32_t offset, nsIInputStream * *_retval)
|
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->OpenInputStream(offset, _retval);
|
|
|
|
}
|
|
|
|
nsresult OpenOutputStream(uint32_t offset, nsIOutputStream * *_retval)
|
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->OpenOutputStream(offset, _retval);
|
|
|
|
}
|
2016-04-11 06:17:02 +03:00
|
|
|
NS_IMETHOD OpenAlternativeOutputStream(const nsACString & type, nsIOutputStream * *_retval) override
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHOD OpenAlternativeInputStream(const nsACString & type, nsIInputStream * *_retval) override
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetPredictedDataSize(int64_t *aPredictedDataSize) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->GetPredictedDataSize(aPredictedDataSize);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetPredictedDataSize(int64_t aPredictedDataSize) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->SetPredictedDataSize(aPredictedDataSize);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->GetSecurityInfo(aSecurityInfo);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetSecurityInfo(nsISupports *aSecurityInfo) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->SetSecurityInfo(aSecurityInfo);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetStorageDataSize(uint32_t *aStorageDataSize) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->GetStorageDataSize(aStorageDataSize);
|
|
|
|
}
|
2015-01-02 09:24:13 +03:00
|
|
|
nsresult AsyncDoom(nsICacheListener *listener)
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->AsyncDoom(listener);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD MarkValid(void) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->MarkValid();
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Close(void) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->Close();
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetMetaDataElement(const char * key, char * *_retval) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->GetMetaDataElement(key, _retval);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetMetaDataElement(const char * key, const char * value) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return !mOldDesc ? NS_ERROR_NULL_POINTER :
|
|
|
|
mOldDesc->SetMetaDataElement(key, value);
|
|
|
|
}
|
|
|
|
|
2016-11-10 18:14:34 +03:00
|
|
|
NS_IMETHOD GetDiskStorageSizeInKB(uint32_t *aDiskStorageSize) override
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-08-21 21:47:38 +04:00
|
|
|
// nsICacheEntryInfo
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetKey(nsACString & aKey) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return mOldInfo->GetKey(aKey);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetFetchCount(int32_t *aFetchCount) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return mOldInfo->GetFetchCount(aFetchCount);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetLastFetched(uint32_t *aLastFetched) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return mOldInfo->GetLastFetched(aLastFetched);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetLastModified(uint32_t *aLastModified) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return mOldInfo->GetLastModified(aLastModified);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetExpirationTime(uint32_t *aExpirationTime) override
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return mOldInfo->GetExpirationTime(aExpirationTime);
|
|
|
|
}
|
2015-01-02 09:24:13 +03:00
|
|
|
nsresult GetDataSize(uint32_t *aDataSize)
|
2014-08-21 21:47:38 +04:00
|
|
|
{
|
|
|
|
return mOldInfo->GetDataSize(aDataSize);
|
|
|
|
}
|
2017-03-28 07:02:45 +03:00
|
|
|
NS_IMETHOD GetOnStartTime(uint64_t *aTime) override
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHOD GetOnStopTime(uint64_t *aTime) override
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHOD SetNetworkTimes(uint64_t aOnStartTime, uint64_t aOnStopTime) override
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2017-02-03 06:15:00 +03:00
|
|
|
NS_IMETHOD GetLoadContextInfo(nsILoadContextInfo** aInfo) override
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD AsyncDoom(nsICacheEntryDoomCallback* listener) override;
|
|
|
|
NS_IMETHOD GetPersistent(bool *aPersistToDisk) override;
|
|
|
|
NS_IMETHOD GetIsForcedValid(bool *aIsForcedValid) override;
|
|
|
|
NS_IMETHOD ForceValidFor(uint32_t aSecondsToTheFuture) override;
|
|
|
|
NS_IMETHOD SetValid() override { return NS_OK; }
|
|
|
|
NS_IMETHOD MetaDataReady() override { return NS_OK; }
|
|
|
|
NS_IMETHOD Recreate(bool, nsICacheEntry**) override;
|
|
|
|
NS_IMETHOD GetDataSize(int64_t *size) override;
|
2016-09-27 11:26:00 +03:00
|
|
|
NS_IMETHOD GetAltDataSize(int64_t *size) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD OpenInputStream(int64_t offset, nsIInputStream * *_retval) override;
|
|
|
|
NS_IMETHOD OpenOutputStream(int64_t offset, nsIOutputStream * *_retval) override;
|
|
|
|
NS_IMETHOD MaybeMarkValid() override;
|
|
|
|
NS_IMETHOD HasWriteAccess(bool aWriteOnly, bool *aWriteAccess) override;
|
|
|
|
NS_IMETHOD VisitMetaData(nsICacheEntryMetaDataVisitor*) override;
|
2013-09-20 13:11:25 +04:00
|
|
|
|
2014-08-05 17:20:24 +04:00
|
|
|
explicit _OldCacheEntryWrapper(nsICacheEntryDescriptor* desc);
|
|
|
|
explicit _OldCacheEntryWrapper(nsICacheEntryInfo* info);
|
2013-09-20 13:11:25 +04:00
|
|
|
|
2014-06-24 20:36:44 +04:00
|
|
|
private:
|
2013-09-20 13:11:25 +04:00
|
|
|
virtual ~_OldCacheEntryWrapper();
|
|
|
|
|
2015-01-07 02:35:02 +03:00
|
|
|
_OldCacheEntryWrapper() = delete;
|
2013-09-20 13:11:25 +04:00
|
|
|
nsICacheEntryDescriptor* mOldDesc; // ref holded in mOldInfo
|
|
|
|
nsCOMPtr<nsICacheEntryInfo> mOldInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class _OldCacheLoad : public Runnable
|
2013-09-20 13:11:25 +04:00
|
|
|
, public nsICacheListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
NS_DECL_NSICACHELISTENER
|
|
|
|
|
2017-06-20 12:19:52 +03:00
|
|
|
_OldCacheLoad(const nsACString& aScheme,
|
|
|
|
const nsACString& aCacheKey,
|
2013-09-20 13:11:25 +04:00
|
|
|
nsICacheEntryOpenCallback* aCallback,
|
|
|
|
nsIApplicationCache* aAppCache,
|
|
|
|
nsILoadContextInfo* aLoadInfo,
|
|
|
|
bool aWriteToDisk,
|
|
|
|
uint32_t aFlags);
|
|
|
|
|
|
|
|
nsresult Start();
|
|
|
|
|
2014-07-09 01:23:18 +04:00
|
|
|
protected:
|
|
|
|
virtual ~_OldCacheLoad();
|
|
|
|
|
2013-09-20 13:11:25 +04:00
|
|
|
private:
|
|
|
|
void Check();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEventTarget> mCacheThread;
|
|
|
|
|
2013-11-21 02:20:17 +04:00
|
|
|
nsCString const mScheme;
|
|
|
|
nsCString const mCacheKey;
|
2013-09-20 13:11:25 +04:00
|
|
|
nsCOMPtr<nsICacheEntryOpenCallback> mCallback;
|
|
|
|
nsCOMPtr<nsILoadContextInfo> mLoadInfo;
|
2013-11-21 02:20:17 +04:00
|
|
|
uint32_t const mFlags;
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
bool const mWriteToDisk : 1;
|
|
|
|
bool mNew : 1;
|
2013-11-21 02:20:17 +04:00
|
|
|
bool mOpening : 1;
|
|
|
|
bool mSync : 1;
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsICacheEntry> mCacheEntry;
|
|
|
|
nsresult mStatus;
|
|
|
|
uint32_t mRunCount;
|
|
|
|
nsCOMPtr<nsIApplicationCache> mAppCache;
|
2013-09-26 23:37:03 +04:00
|
|
|
|
|
|
|
mozilla::TimeStamp mLoadStart;
|
2013-09-20 13:11:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class _OldStorage : public nsICacheStorage
|
|
|
|
{
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSICACHESTORAGE
|
|
|
|
|
|
|
|
public:
|
|
|
|
_OldStorage(nsILoadContextInfo* aInfo,
|
|
|
|
bool aAllowDisk,
|
|
|
|
bool aLookupAppCache,
|
|
|
|
bool aOfflineStorage,
|
|
|
|
nsIApplicationCache* aAppCache);
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~_OldStorage();
|
2013-11-21 02:20:16 +04:00
|
|
|
nsresult AssembleCacheKey(nsIURI *aURI, nsACString const & aIdExtension,
|
|
|
|
nsACString & aCacheKey, nsACString & aScheme);
|
2017-06-20 12:19:52 +03:00
|
|
|
nsresult ChooseApplicationCache(const nsACString& cacheKey, nsIApplicationCache** aCache);
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsILoadContextInfo> mLoadInfo;
|
|
|
|
nsCOMPtr<nsIApplicationCache> mAppCache;
|
|
|
|
bool const mWriteToDisk : 1;
|
|
|
|
bool const mLookupAppCache : 1;
|
|
|
|
bool const mOfflineStorage : 1;
|
|
|
|
};
|
|
|
|
|
2014-05-01 15:28:12 +04:00
|
|
|
class _OldVisitCallbackWrapper : public nsICacheVisitor
|
|
|
|
{
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSICACHEVISITOR
|
|
|
|
|
|
|
|
_OldVisitCallbackWrapper(char const * deviceID,
|
|
|
|
nsICacheStorageVisitor * cb,
|
|
|
|
bool visitEntries,
|
|
|
|
nsILoadContextInfo * aInfo)
|
|
|
|
: mCB(cb)
|
|
|
|
, mVisitEntries(visitEntries)
|
|
|
|
, mDeviceID(deviceID)
|
|
|
|
, mLoadInfo(aInfo)
|
|
|
|
, mHit(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~_OldVisitCallbackWrapper();
|
|
|
|
nsCOMPtr<nsICacheStorageVisitor> mCB;
|
|
|
|
bool mVisitEntries;
|
|
|
|
char const * mDeviceID;
|
|
|
|
nsCOMPtr<nsILoadContextInfo> mLoadInfo;
|
|
|
|
bool mHit; // set to true when the device was found
|
|
|
|
};
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class _OldGetDiskConsumption : public Runnable,
|
2014-04-24 20:50:46 +04:00
|
|
|
public nsICacheVisitor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static nsresult Get(nsICacheStorageConsumptionObserver* aCallback);
|
|
|
|
|
|
|
|
private:
|
2014-08-05 17:20:24 +04:00
|
|
|
explicit _OldGetDiskConsumption(nsICacheStorageConsumptionObserver* aCallback);
|
2014-04-24 20:50:46 +04:00
|
|
|
virtual ~_OldGetDiskConsumption() {}
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSICACHEVISITOR
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
|
|
|
nsCOMPtr<nsICacheStorageConsumptionObserver> mCallback;
|
|
|
|
int64_t mSize;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
#endif
|