Bug 1312954 - Part 4: Add a new functoin in nsICacheEntry to allow its loadInfoContext can be fetched. r?mayhemer draft
authorTim Huang <tihuang@mozilla.com>
Thu, 19 Jan 2017 16:03:12 +0800
changeset 465998 28df254d2795448d156e43135183ec8954126f8a
parent 465997 4c0095a9055cb5b6c365b1a09712f8fc23ac03f5
child 465999 64f4bdb1f22ad3da332a30feea2ca41b3a0cbdd8
push id42767
push userbmo:tihuang@mozilla.com
push dateWed, 25 Jan 2017 04:18:41 +0000
reviewersmayhemer
bugs1312954
milestone54.0a1
Bug 1312954 - Part 4: Add a new functoin in nsICacheEntry to allow its loadInfoContext can be fetched. r?mayhemer
netwerk/cache2/CacheEntry.cpp
netwerk/cache2/OldWrappers.h
netwerk/cache2/nsICacheEntry.idl
--- 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