Bug 722034 - Part 3 - Convert HttpBaseChannel::mRedirectedCachekeys to nsAutoPtr<nsTArray<nsCString> >, r=biesi
authorBrian Smith <bsmith@mozilla.com>
Thu, 31 May 2012 15:20:05 -0700
changeset 97636 a2c43de46e331c1c28fc4aabb7a4d2e3267e6ead
parent 97635 4de9e540c40f0cbbe3ee8cc36db153bcb0c21180
child 97637 3860eb758cbc5e99440f4818ad17f6cf742cf7be
push idunknown
push userunknown
push dateunknown
reviewersbiesi
bugs722034
milestone15.0a1
Bug 722034 - Part 3 - Convert HttpBaseChannel::mRedirectedCachekeys to nsAutoPtr<nsTArray<nsCString> >, r=biesi
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpBaseChannel.h
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -45,17 +45,16 @@ HttpBaseChannel::HttpBaseChannel()
   , mInheritApplicationCache(true)
   , mChooseApplicationCache(false)
   , mLoadedFromApplicationCache(false)
   , mChannelIsForDownload(false)
   , mTracingEnabled(true)
   , mTimingEnabled(false)
   , mAllowSpdy(true)
   , mSuspendCount(0)
-  , mRedirectedCachekeys(nsnull)
 {
   LOG(("Creating HttpBaseChannel @%x\n", this));
 
   // grab a reference to the handler to ensure that it doesn't go away.
   NS_ADDREF(gHttpHandler);
 
   // Subfields of unions cannot be targeted in an initializer list
   mSelfAddr.raw.family = PR_AF_UNSPEC;
@@ -1621,18 +1620,17 @@ HttpBaseChannel::SetupReplacementChannel
     else
       httpInternal->SetDocumentURI(mDocumentURI);
 
     // if there is a chain of keys for redirect-responses we transfer it to
     // the new channel (see bug #561276)
     if (mRedirectedCachekeys) {
         LOG(("HttpBaseChannel::SetupReplacementChannel "
              "[this=%p] transferring chain of redirect cache-keys", this));
-        httpInternal->SetCacheKeysRedirectChain(mRedirectedCachekeys);
-        mRedirectedCachekeys = nsnull;
+        httpInternal->SetCacheKeysRedirectChain(mRedirectedCachekeys.forget());
     }
   }
   
   // transfer application cache information
   nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
     do_QueryInterface(newChannel);
   if (appCacheChannel) {
     appCacheChannel->SetApplicationCache(mApplicationCache);
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -135,20 +135,17 @@ public:
   NS_IMETHOD GetLocalPort(PRInt32* port);
   NS_IMETHOD GetRemoteAddress(nsACString& addr);
   NS_IMETHOD GetRemotePort(PRInt32* port);
   NS_IMETHOD GetAllowSpdy(bool *aAllowSpdy);
   NS_IMETHOD SetAllowSpdy(bool aAllowSpdy);
   
   inline void CleanRedirectCacheChainIfNecessary()
   {
-      if (mRedirectedCachekeys) {
-          delete mRedirectedCachekeys;
-          mRedirectedCachekeys = nsnull;
-      }
+      mRedirectedCachekeys = nsnull;
   }
   NS_IMETHOD HTTPUpgrade(const nsACString & aProtocolName,
                          nsIHttpUpgradeListener *aListener); 
 
   // nsISupportsPriority
   NS_IMETHOD GetPriority(PRInt32 *value);
   NS_IMETHOD AdjustPriority(PRInt32 delta);
 
@@ -267,17 +264,17 @@ protected:
   PRUint32                          mTracingEnabled             : 1;
   // True if timing collection is enabled
   PRUint32                          mTimingEnabled              : 1;
   PRUint32                          mAllowSpdy                  : 1;
 
   // Current suspension depth for this channel object
   PRUint32                          mSuspendCount;
 
-  nsTArray<nsCString>              *mRedirectedCachekeys;
+  nsAutoPtr<nsTArray<nsCString> >   mRedirectedCachekeys;
 };
 
 // Share some code while working around C++'s absurd inability to handle casting
 // of member functions between base/derived types.
 // - We want to store member function pointer to call at resume time, but one
 //   such function--HandleAsyncAbort--we want to share between the
 //   nsHttpChannel/HttpChannelChild.  Can't define it in base class, because
 //   then we'd have to cast member function ptr between base/derived class