Bug 1312954 - Part 4: Add a new functoin in nsICacheEntry to allow its loadInfoContext can be fetched. r?mayhemer
--- a/netwerk/cache2/CacheEntry.cpp
+++ b/netwerk/cache2/CacheEntry.cpp
@@ -1547,16 +1547,28 @@ NS_IMETHODIMP CacheEntry::GetDiskStorage
{
if (NS_FAILED(mFileStatus)) {
return NS_ERROR_NOT_AVAILABLE;
}
return mFile->GetDiskStorageSizeInKB(aDiskStorageSize);
}
+NS_IMETHODIMP CacheEntry::GetLoadContextInfo(nsILoadContextInfo** aInfo)
+{
+ nsCOMPtr<nsILoadContextInfo> info = CacheFileUtils::ParseKey(mStorageID);
+ if (!info) {
+ return NS_ERROR_FAILURE;
+ }
+
+ info.forget(aInfo);
+
+ return NS_OK;
+}
+
// nsIRunnable
NS_IMETHODIMP CacheEntry::Run()
{
MOZ_ASSERT(CacheStorageService::IsOnManagementThread());
mozilla::MutexAutoLock lock(mLock);
--- a/netwerk/cache2/OldWrappers.h
+++ b/netwerk/cache2/OldWrappers.h
@@ -130,16 +130,20 @@ public:
NS_IMETHOD GetExpirationTime(uint32_t *aExpirationTime) override
{
return mOldInfo->GetExpirationTime(aExpirationTime);
}
nsresult GetDataSize(uint32_t *aDataSize)
{
return mOldInfo->GetDataSize(aDataSize);
}
+ NS_IMETHOD GetLoadContextInfo(nsILoadContextInfo** aInfo) override
+ {
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
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;
--- a/netwerk/cache2/nsICacheEntry.idl
+++ b/netwerk/cache2/nsICacheEntry.idl
@@ -7,16 +7,17 @@
interface nsIInputStream;
interface nsIOutputStream;
interface nsICacheEntryDoomCallback;
interface nsICacheListener;
interface nsIFile;
interface nsICacheEntryMetaDataVisitor;
+interface nsILoadContextInfo;
[scriptable, uuid(607c2a2c-0a48-40b9-a956-8cf2bb9857cf)]
interface nsICacheEntry : nsISupports
{
/**
* Placeholder for the initial value of expiration time.
*/
const unsigned long NO_EXPIRATION_TIME = 0xFFFFFFFF;
@@ -228,16 +229,21 @@ interface nsICacheEntry : nsISupports
* If this call is made while writing alt-data is still in progress, it is
* still possible to read content from the input stream as it's being written.
* @throws
* - NS_ERROR_NOT_AVAILABLE if the alt-data representation doesn't exist at
* all or if alt-data of the given type doesn't exist.
*/
nsIInputStream openAlternativeInputStream(in ACString type);
+ /**
+ * Get the nsILoadContextInfo of the cache entry
+ */
+ readonly attribute nsILoadContextInfo loadContextInfo;
+
/****************************************************************************
* The following methods might be added to some nsICacheEntryInternal
* interface since we want to remove them as soon as the old cache backend is
* completely removed.
*/
/**
* @deprecated