Bug 661583: Hold onto the cache token if our response blob is backed by a cache file. r=sicking
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Thu, 30 Jun 2011 14:41:39 -0700
changeset 72660 8c8d3b22ea79b99f5e8c38ffe3f2c3fe23bd0e37
parent 72659 38e14b78ac76645197ed8cfb1aeefaabb979a897
child 72661 84bbc200e89aa5197d1c3980197ba8e1afe003a2
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs661583
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 661583: Hold onto the cache token if our response blob is backed by a cache file. r=sicking
content/base/public/nsDOMFile.h
content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/public/nsDOMFile.h
+++ b/content/base/public/nsDOMFile.h
@@ -67,30 +67,33 @@ class nsDOMFile : public nsIDOMFile,
                   public nsIJSNativeInitializer
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMBLOB
   NS_DECL_NSIDOMFILE
   NS_DECL_NSIXHRSENDABLE
 
-  nsDOMFile(nsIFile *aFile, const nsAString& aContentType)
+  nsDOMFile(nsIFile *aFile, const nsAString& aContentType,
+            nsISupports *aCacheToken = nsnull)
     : mFile(aFile),
+      mCacheToken(aCacheToken),
       mContentType(aContentType),
       mIsFullFile(true)
   {}
 
   nsDOMFile(nsIFile *aFile)
     : mFile(aFile),
       mIsFullFile(true)
   {}
 
   nsDOMFile(const nsDOMFile* aOther, PRUint64 aStart, PRUint64 aLength,
             const nsAString& aContentType)
     : mFile(aOther->mFile),
+      mCacheToken(aOther->mCacheToken),
       mStart(aOther->mIsFullFile ? aStart :
                                    (aOther->mStart + aStart)),
       mLength(aLength),
       mContentType(aContentType),
       mIsFullFile(false)
   {
     NS_ASSERTION(mFile, "must have file");
     // Ensure non-null mContentType
@@ -107,16 +110,17 @@ public:
                         jsval* aArgv);
 
   // DOMClassInfo constructor (for File("foo"))
   static nsresult
   NewFile(nsISupports* *aNewObject);
 
 protected:
   nsCOMPtr<nsIFile> mFile;
+  nsCOMPtr<nsISupports> mCacheToken;
 
   // start and length in 
   PRUint64 mStart;
   PRUint64 mLength;
 
   nsString mContentType;
   
   bool mIsFullFile;
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -1611,18 +1611,23 @@ void nsXMLHttpRequest::CreateResponseBlo
     nsCOMPtr<nsIFileChannel> fc = do_QueryInterface(request);
     if (fc) {
       fc->GetFile(getter_AddRefs(file));
     }
   }
   if (file) {
     nsCAutoString contentType;
     mChannel->GetContentType(contentType);
+    nsCOMPtr<nsISupports> cacheToken;
+    if (cc) {
+      cc->GetCacheToken(getter_AddRefs(cacheToken));
+    }
     mResponseBlob = new nsDOMFile(file,
-                                  NS_ConvertASCIItoUTF16(contentType));
+                                  NS_ConvertASCIItoUTF16(contentType),
+                                  cacheToken);
     mResponseBody.Truncate();
     mResponseBodyUnicode.SetIsVoid(PR_TRUE);
   }
 }
 
 /* void onDataAvailable (in nsIRequest request, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */
 NS_IMETHODIMP
 nsXMLHttpRequest::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)