relanding fix for bug 262116 that got accidentally backed out by previous landing.
authordwitte@stanford.edu
Sat, 05 Jan 2008 17:07:16 -0800
changeset 9890 e5b11400fcaecc5be1d1ea8e166767d78be91ee1
parent 9889 6e960bd32059acecfd04e63afe2167fe3c5f5060
child 9891 9078721e8ef5f7a8ed6320370cd4ce509163254b
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs262116
milestone1.9b3pre
relanding fix for bug 262116 that got accidentally backed out by previous landing.
netwerk/cache/src/nsDiskCacheEntry.cpp
netwerk/cache/src/nsDiskCacheMap.cpp
--- a/netwerk/cache/src/nsDiskCacheEntry.cpp
+++ b/netwerk/cache/src/nsDiskCacheEntry.cpp
@@ -41,16 +41,18 @@
 
 #include "nsDiskCache.h"
 #include "nsDiskCacheEntry.h"
 #include "nsDiskCacheBinding.h"
 #include "nsCRT.h"
 
 #include "nsCache.h"
 
+#include "nsISerializable.h"
+#include "nsSerializationHelper.h"
 
 /******************************************************************************
  *  nsDiskCacheEntry
  *****************************************************************************/
 
 /**
  *  CreateCacheEntry()
  *
@@ -75,17 +77,25 @@ nsDiskCacheEntry::CreateCacheEntry(nsCac
     // XXX why does nsCacheService have to fill out device in BindEntry()?
     entry->SetDataSize(mDataSize);
     
     rv = entry->UnflattenMetaData(MetaData(), mMetaDataSize);
     if (NS_FAILED(rv)) {
         delete entry;
         return nsnull;
     }
-    
+
+    // Restore security info, if present
+    const char* info = entry->GetMetaDataElement("security-info");
+    if (info) {
+        nsCOMPtr<nsISupports> infoObj;
+        NS_DeserializeObject(nsDependentCString(info), getter_AddRefs(infoObj));
+        entry->SetSecurityInfo(infoObj);
+    }
+
     return entry;                      
 }
 
 
 /******************************************************************************
  *  nsDiskCacheEntryInfo
  *****************************************************************************/
 
--- a/netwerk/cache/src/nsDiskCacheMap.cpp
+++ b/netwerk/cache/src/nsDiskCacheMap.cpp
@@ -44,16 +44,18 @@
 #include "nsDiskCacheMap.h"
 #include "nsDiskCacheBinding.h"
 #include "nsDiskCacheEntry.h"
 
 #include "nsCache.h"
 
 #include <string.h>
 
+#include "nsISerializable.h"
+#include "nsSerializationHelper.h"
 
 /******************************************************************************
  *  nsDiskCacheMap
  *****************************************************************************/
 
 /**
  *  File operations
  */
@@ -730,16 +732,25 @@ nsDiskCacheMap::ReadDiskCacheEntry(nsDis
  */
 nsDiskCacheEntry *
 nsDiskCacheMap::CreateDiskCacheEntry(nsDiskCacheBinding *  binding,
                                      PRUint32 * aSize)
 {
     nsCacheEntry * entry = binding->mCacheEntry;
     if (!entry)  return nsnull;
     
+    // Store security info, if it is serializable
+    nsCOMPtr<nsISerializable> serializable =
+        do_QueryInterface(entry->SecurityInfo());
+    if (serializable) {
+        nsCString info;
+        NS_SerializeToString(serializable, info);
+        entry->SetMetaDataElement("security-info", info.get());
+    }
+
     PRUint32  keySize  = entry->Key()->Length() + 1;
     PRUint32  metaSize = entry->MetaDataSize();
     PRUint32  size     = sizeof(nsDiskCacheEntry) + keySize + metaSize;
     
     if (aSize) *aSize = size;
     
     nsresult rv = EnsureBuffer(size);
     if (NS_FAILED(rv)) return nsnull;